-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9095cc
commit 15e8bff
Showing
3 changed files
with
241 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BEGIN | ||
{ | ||
printf("Tracing open syscalls... Hit Ctrl-C to end.\n"); | ||
printf("%-6s %-16s %4s %3s %s\n", "PID", "COMM", "FD", "ERR", "PATH"); | ||
} | ||
|
||
tracepoint:syscalls:sys_enter_open, | ||
tracepoint:syscalls:sys_enter_openat | ||
{ | ||
@filename[tid] = args.filename; | ||
} | ||
|
||
tracepoint:syscalls:sys_exit_open, | ||
tracepoint:syscalls:sys_exit_openat | ||
/@filename[tid]/ | ||
{ | ||
$ret = args.ret; | ||
$fd = $ret >= 0 ? $ret : -1; | ||
$errno = $ret >= 0 ? 0 : - $ret; | ||
|
||
printf("%-6d %-16s %4d %3d %s\n", pid, comm, $fd, $errno, | ||
str(@filename[tid])); | ||
delete(@filename[tid]); | ||
} | ||
|
||
END | ||
{ | ||
clear(@filename); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
name: Install and test bpftrace | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["*"] | ||
pull_request: | ||
branches: ['master'] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-runtime: | ||
strategy: | ||
matrix: | ||
enable_jit: | ||
- true | ||
- false | ||
container: | ||
- image: ubuntu-2204 | ||
name: ubuntu | ||
- image: fedora-39 | ||
name: fedora | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}" | ||
options: --privileged | ||
steps: | ||
- uses: actions/checkout@v2 | ||
name: "Clone the latest version" | ||
with: | ||
submodules: 'recursive' | ||
- uses: actions/checkout@v2 | ||
name: "Pull bpftrace" | ||
with: | ||
repository: "bpftrace/bpftrace" | ||
submodules: 'recursive' | ||
path: '/tmp/bpftrace' | ||
- name: Build and install runtime (with llvm-jit) | ||
if: ${{matrix.enable_jit}} | ||
run: | | ||
make release-with-llvm-jit -j | ||
- name: Build and install runtime (without llvm-jit) | ||
if: ${{!matrix.enable_jit}} | ||
run: | | ||
make release -j | ||
- name: Build and install bpftrace | ||
if: ${{!matrix.enable_jit}} | ||
run: | | ||
cd /tmp/bpftrace | ||
cmake -B /bpftrace -DBUILD_TESTING=OFF | ||
make -C /bpftrace -j$(nproc) | ||
cd - | ||
- name: Upload build results (without jit) | ||
uses: actions/upload-artifact@v3 | ||
if: ${{!matrix.enable_jit}} | ||
with: | ||
name: runtime-package-no-jit-${{matrix.container.name}} | ||
path: ~/.bpftime | ||
- name: Upload build results (with jit) | ||
uses: actions/upload-artifact@v3 | ||
if: ${{matrix.enable_jit}} | ||
with: | ||
name: runtime-package-jit-${{matrix.container.name}} | ||
path: ~/.bpftime | ||
- name: Upload built bpftrace | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bpftrace | ||
path: /bpftrace | ||
install-bpftrace-and-test: | ||
runs-on: "ubuntu-latest" | ||
needs: [build-runtime] | ||
strategy: | ||
matrix: | ||
container: | ||
- image: ubuntu-2204 | ||
name: ubuntu | ||
- image: fedora-39 | ||
name: fedora | ||
enable_jit: | ||
- true | ||
- false | ||
bpftrace_tests: | ||
- command: /__w/bpftime/bpftime/.github/script/bpftrace/trace_open_syscalls.bt | ||
expected_output: '^\d+\s+\w+(\s+#\d+)?\s+-?\d+\s+-?\d+\s+\S+$' | ||
victim: 'bash' | ||
is_a_syscall_tracing: true | ||
container: | ||
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}" | ||
options: --privileged -v /sys/kernel/debug/:/sys/kernel/debug:rw -v /sys/kernel/tracing:/sys/kernel/tracing:rw | ||
steps: | ||
- name: Download prebuilt runtime (with jit) | ||
if: ${{matrix.enable_jit}} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: runtime-package-jit-${{matrix.container.name}} | ||
path: /app/.bpftime | ||
- name: Download prebuilt runtime (without jit) | ||
if: ${{!matrix.enable_jit}} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: runtime-package-no-jit-${{matrix.container.name}} | ||
path: /app/.bpftime | ||
- name: Download prebuilt bpftrace | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bpftrace | ||
path: /bpftrace | ||
- name: Set permissions | ||
run: | | ||
chmod +x /app/.bpftime/* | ||
- name: Show downloaded artifacts | ||
run: | | ||
ls /app/.bpftime | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- name: Install bpftrace | ||
run: | | ||
if [ "${{ matrix.container.name }}" = "ubuntu" ]; then | ||
apt-get update && apt-get install -y \ | ||
--no-install-recommends \ | ||
libelf1 \ | ||
libelf-dev \ | ||
zlib1g-dev \ | ||
make \ | ||
cmake \ | ||
git \ | ||
libboost1.74-all-dev \ | ||
binutils-dev \ | ||
libyaml-cpp-dev \ | ||
gcc \ | ||
g++ \ | ||
ca-certificates \ | ||
clang \ | ||
llvm \ | ||
systemtap-sdt-dev \ | ||
libclang-dev \ | ||
liblldb-dev \ | ||
llvm-dev \ | ||
libpcap-dev \ | ||
libiberty-dev \ | ||
libcereal-dev \ | ||
libbpfcc-dev \ | ||
flex \ | ||
build-essential \ | ||
bison \ | ||
asciidoctor \ | ||
libbpf-dev | ||
elif [ "${{ matrix.container.name }}" = "fedora" ]; then | ||
dnf -y update && dnf install -y \ | ||
elfutils-libelf \ | ||
elfutils-libelf-devel \ | ||
zlib-devel \ | ||
make \ | ||
cmake \ | ||
git \ | ||
boost-devel \ | ||
binutils-devel \ | ||
yaml-cpp-devel \ | ||
gcc \ | ||
gcc-c++ \ | ||
ca-certificates \ | ||
clang \ | ||
llvm \ | ||
systemtap-sdt-devel \ | ||
clang-devel \ | ||
lldb-devel \ | ||
llvm-devel \ | ||
libpcap-devel \ | ||
libiberty-devel \ | ||
cereal-devel \ | ||
libbpf-devel \ | ||
flex \ | ||
bison \ | ||
asciidoctor \ | ||
bpftrace \ | ||
kernel-devel | ||
else | ||
echo "Unsupported container type" | ||
exit 1 | ||
fi | ||
- name: Test CLI - attach by running (is_a_syscall_tracing) | ||
if: matrix.bpftrace_tests.is_a_syscall_tracing | ||
shell: bash | ||
run: | | ||
python3 $(pwd)/.github/script/run_example.py "/bpftrace/bpftrace ${{ matrix.bpftrace_tests.command }}" "${{matrix.bpftrace_tests.victim}}" "${{matrix.bpftrace_tests.expected_output}}" "/app/.bpftime/bpftime -i /app/.bpftime" 1 | ||
- name: Test CLI - attach by running (uprobe) | ||
if: '!matrix.bpftrace_tests.is_a_syscall_tracing' | ||
shell: bash | ||
run: | | ||
python3 $(pwd)/.github/script/run_example.py "/bpftrace/bpftrace ${{ matrix.bpftrace_tests.command }}" "${{matrix.bpftrace_tests.victim}}" "${{matrix.bpftrace_tests.expected_output}}" "/app/.bpftime/bpftime -i /app/.bpftime" 0 |