From 29463b1cd6376a0b942a2abe53259f85f1f1e909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Fri, 18 Oct 2024 10:09:28 -0700 Subject: [PATCH] Test --- .github/workflows/test.yml | 30 ++++++++++++++++++++---------- Cargo.toml | 5 ++++- data/config | 8 ++++++++ dev/Cargo.toml | 1 - src/kernel/bpf/prog.rs | 7 +------ src/kernel/bpf/sys.rs | 2 ++ 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30c5a828..6a3a48de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,13 +26,13 @@ jobs: strategy: fail-fast: false matrix: - runs-on: [ubuntu-latest, macos-latest] + runs-on: [ubuntu-latest] rust: [stable] profile: [dev, release] # gsym-in-apk requires `blazesym-dev/generate-unit-test-files` # feature, which requires `llvm-gsymutil` installed. We don't # want that dependency in this large OS spanning matrix. - args: ["--workspace --exclude=gsym-in-apk"] + args: ["--workspace --exclude=blazesym-dev --exclude=gsym-in-apk"] include: - runs-on: ubuntu-latest rust: stable @@ -49,10 +49,10 @@ jobs: rust: stable profile: release args: "--lib --no-default-features" - - runs-on: windows-latest + - runs-on: macos-latest rust: stable - profile: dev - args: "--tests --features=blazesym-dev/dont-generate-unit-test-files" + profile: release + args: "--lib --no-default-features" - runs-on: ubuntu-latest rust: stable profile: dev @@ -135,10 +135,10 @@ jobs: env: LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14 steps: + - name: Install required tools + run: sudo apt-get install -y llvm-14 libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - - name: Install required tools - run: sudo apt-get install -y llvm-14 - name: Check incremental rebuilds env: CARGO_OPTS: --workspace --quiet --tests @@ -157,6 +157,8 @@ jobs: env: LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14 steps: + - name: Install required tools + run: sudo apt-get install -y llvm-14 libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - uses: Swatinem/rust-cache@v2 @@ -164,8 +166,6 @@ jobs: id: py312 with: python-version: '3.12' - - name: Install required tools - run: sudo apt-get install -y llvm-14 - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - name: Install llvm-tools-preview @@ -277,6 +277,8 @@ jobs: env: LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14 steps: + - name: Install development dependencies + run: sudo apt-get install -y libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - uses: Swatinem/rust-cache@v2 @@ -303,6 +305,8 @@ jobs: env: LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14 steps: + - name: Install development dependencies + run: sudo apt-get install -y libelf-dev zlib1g-dev - uses: actions/checkout@v4 - name: Install required tools run: sudo apt-get install -y llvm-14 @@ -316,6 +320,8 @@ jobs: # Stack borrows are very experimental. Disable for now. MIRIFLAGS: '-Zmiri-disable-stacked-borrows' steps: + - name: Install development dependencies + run: sudo apt-get install -y libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: @@ -339,6 +345,8 @@ jobs: env: LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14 steps: + - name: Install development dependencies + run: sudo apt-get install -y libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo run --example backtrace @@ -387,6 +395,8 @@ jobs: name: Lint with clippy runs-on: ubuntu-latest steps: + - name: Install development dependencies + run: sudo apt-get install -y libelf-dev zlib1g-dev - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo clippy --workspace --no-deps --all-targets --features=blazesym-dev/dont-generate-unit-test-files -- -A unknown_lints -D clippy::todo @@ -408,4 +418,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - - run: cargo doc --workspace --no-deps + - run: cargo doc --workspace --exclude=gsym-in-apk --no-deps diff --git a/Cargo.toml b/Cargo.toml index 995943cd..73d6fd98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,9 @@ members = [ "examples/sym-debuginfod", "examples/gsym-in-apk", ] +# We don't want every Cargo command to operate on all members, unless +# --workspace is specified. +default-members = ["."] [package] name = "blazesym" @@ -121,7 +124,7 @@ memmap2 = {version = "0.9", default-features = false} miniz_oxide = {version = "0.8", default-features = false, features = ["simd", "with-alloc"], optional = true} nom = {version = "7", optional = true} rustc-demangle = {version = "0.1.4", optional = true} -tracing = {version = "0.1.27", default-features = false, features = ["attributes"], optional = true} +tracing = {version = "0.1.38", default-features = false, features = ["attributes"], optional = true} zstd = {version = "0.13.1", default-features = false, optional = true} [dev-dependencies] diff --git a/data/config b/data/config index 788febef..8315d99e 100644 --- a/data/config +++ b/data/config @@ -2,6 +2,9 @@ CONFIG_KERNEL_ZSTD=y CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_WATCH_QUEUE=y +CONFIG_BPF_SYSCALL=y +CONFIG_BPF_JIT=y +CONFIG_BPF_JIT_ALWAYS_ON=y CONFIG_CPU_ISOLATION=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y @@ -60,6 +63,7 @@ CONFIG_COMPAT_32=y CONFIG_COMPAT=y CONFIG_VIRTUALIZATION=y CONFIG_JUMP_LABEL=y +CONFIG_MODULES=y CONFIG_BLOCK=y CONFIG_BINFMT_ELF=y CONFIG_COMPAT_BINFMT_ELF=y @@ -128,3 +132,7 @@ CONFIG_NLS=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ASCII=y CONFIG_SYMBOLIC_ERRNAME=y +CONFIG_FTRACE=y +CONFIG_FTRACE_SYSCALLS=y +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_UPROBE_EVENTS=y diff --git a/dev/Cargo.toml b/dev/Cargo.toml index 0f03bbe2..868faa0f 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -16,7 +16,6 @@ zstd = ["dep:zstd"] # Enable this feature to opt in to the generation of unit test files. # Having these test files created is necessary for running tests. generate-unit-test-files = [ - "dep:libbpf-sys", "dep:tempfile", "dump_syms", "libbpf-sys/vendored-libbpf", diff --git a/src/kernel/bpf/prog.rs b/src/kernel/bpf/prog.rs index 326264fd..23704aa5 100644 --- a/src/kernel/bpf/prog.rs +++ b/src/kernel/bpf/prog.rs @@ -7,6 +7,7 @@ use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Result as FmtResult; use std::iter; +use std::mem::size_of; use std::os::fd::AsFd as _; use std::os::fd::AsRawFd as _; use std::os::fd::BorrowedFd; @@ -276,7 +277,6 @@ impl BpfProg { Some(prog) } - #[cfg(feature = "bpf")] fn retrieve_code_info( &self, addr: Addr, @@ -330,11 +330,6 @@ impl BpfProg { Ok(code_info) } - #[cfg(not(feature = "bpf"))] - fn retrieve_code_info(&self, addr: Addr) -> Result>> { - Ok(None) - } - pub fn resolve( &self, addr: Addr, diff --git a/src/kernel/bpf/sys.rs b/src/kernel/bpf/sys.rs index 4e4f2663..7c4fe3c8 100644 --- a/src/kernel/bpf/sys.rs +++ b/src/kernel/bpf/sys.rs @@ -3,6 +3,8 @@ use std::ffi::c_long; use std::ffi::c_uint; use std::io; +use std::mem::size_of; +use std::mem::size_of_val; use std::os::fd::FromRawFd as _; use std::os::fd::OwnedFd; use std::os::fd::RawFd;