rubrikinc / wachy

A UI for eBPF-based performance debugging
https://rubrikinc.github.io/wachy/
Other
551 stars 17 forks source link

bpftrace syntax generated gives error on Debian testing or sid #2

Closed fasterit closed 2 years ago

fasterit commented 2 years ago
wachy --version
wachy 0.1.0-alpha.5

bpftrace --version
bpftrace v0.14.1

wachy generates a eBPF program containing @duration_tmp139[tid] += nsecs - @start139[tid]; which causes:

stdin:1:274-275: ERROR: syntax error, unexpected -, expecting }

(the character count of course varies)

This code works on earlier bpftrace versions, e.g. tested with v0.9.4.

Changing the offending code segment to @duration_tmp139[tid] += (nsecs - @start139[tid]); makes it work again with bpftrace v0.14.1 as found in Debian testing and sid at the moment.

/DLange (@debian.org)

viveksjain commented 2 years ago

Thanks for reporting! Unfortunately I'm not able to reproduce with the same version

bpftrace --version
bpftrace v0.14.1

And I'm not sure why parsing that expression would be different in a newer bpftrace version.

Could you 1) include the full log line (with the full bpftrace expression) that is causing the error and 2) mention any steps you took to get the error? If you can get it to repro on the demo program or some binary that I can also try, that would be best.

fasterit commented 2 years ago
test@debiantesting:~$ git clone --depth 1 https://github.com/rubrikinc/wachy/
Cloning into 'wachy'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 34 (delta 1), reused 23 (delta 1), pack-reused 0
Receiving objects: 100% (34/34), 1.24 MiB | 10.59 MiB/s, done.
Resolving deltas: 100% (1/1), done.
test@debiantesting:~$ cd wachy/demo/
test@debiantesting:~/wachy/demo (master u= origin/master)$ make
c++ -std=c++11 -g demo.cpp -o demo
test@debiantesting:~/wachy/demo (master u= origin/master)$ ./demo &
[1] 1075
test@debiantesting:~/wachy/demo (master u= origin/master)$ sudo wachy ./demo "foo()"
Error: bpftrace command 'BEGIN { @start_time = nsecs; @depth[-1] = 0; @matched_retfilters[-1] = 0; } uprobe:/home/test/wachy/demo/demo:_Z3foov /@depth[tid] == 0/ { @start4[tid] = nsecs; @depth[tid] = 1; } uretprobe:/home/test/wachy/demo/demo:_Z3foov /@depth[tid] == 1/ { @duration_tmp4[tid] += nsecs - @start4[tid]; $duration = @duration_tmp4[tid]; @count_tmp4[tid] += 1; delete(@start4[tid]); @depth[tid] = 0; if (@matched_retfilters[tid] == 0) { @duration4 += @duration_tmp4[tid]; @count4 += @count_tmp4[tid]; } delete(@duration_tmp4[tid]); delete(@count_tmp4[tid]); delete(@matched_retfilters[tid]); } interval:s:1 { printf("{\"time\": %d, \"lines\": {", (nsecs - @start_time) / 1000000000); printf("\"4\": [%lld, %lld]", @duration4, @count4); printf("}}\n"); }' failed, status: ExitStatus(ExitStatus(256)), stderr:
stdin:1:276-277: ERROR: syntax error, unexpected -, expecting }
BEGIN { @start_time = nsecs; @depth[-1] = 0; @matched_retfilters[-1] = 0; } uprobe:/home/test/wachy/demo/demo:_Z3foov /@depth[tid] == 0/ { @start4[tid] = nsecs; @depth[tid] = 1; } uretprobe:/home/test/wachy/demo/demo:_Z3foov /@depth[tid] == 1/ { @duration_tmp4[tid] += nsecs - @start4[tid]; $duration = @duration_tmp4[tid]; @count_tmp4[tid] += 1; delete(@start4[tid]); @depth[tid] = 0; if (@matched_retfilters[tid] == 0) { @duration4 += @duration_tmp4[tid]; @count4 += @count_tmp4[tid]; } delete(@duration_tmp4[tid]); delete(@count_tmp4[tid]); delete(@matched_retfilters[tid]); } interval:s:1 { printf("{\"time\": %d, \"lines\": {", (nsecs - @start_time) / 1000000000); printf("\"4\": [%lld, %lld]", @duration4, @count4); printf("}}\n"); }
                                                                                                                                                                                                                                                                                   ~

test@debiantesting:~/wachy/demo (master u= origin/master)$ kill 1075
[1]+  Terminated                 ./demo
viveksjain commented 2 years ago

Thanks for bearing with me (and also mentioning the fix)! This should now be fixed, let me know if that's not the case.