Comments (13)
The pending fix addresses the buggy rewrite pass that was mangling the sample you included. However, you will still need to pass &req
, since the prototype for lookup/delete/etc. is a pointer to a key, which therefore should be struct request **
from bcc.
ok, sounds good, thanks.
from bcc.
I really want to use this, but got a build error:
[...]
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.cc: At global scope:
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.cc:437:1: error: prototype for ‘ebpf::BFrontendAction::BFrontendAction(llvm::raw_ostream&, unsigned int)’ does not match any in class ‘ebpf::BFrontendAction’
BFrontendAction::BFrontendAction(llvm::raw_ostream &os, unsigned flags)
^
In file included from /mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.cc:26:0:
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.h:95:7: error: candidates are: ebpf::BFrontendAction::BFrontendAction(ebpf::BFrontendAction&&)
class BFrontendAction : public clang::ASTFrontendAction {
^
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.h:95:7: error: ebpf::BFrontendAction::BFrontendAction(const ebpf::BFrontendAction&)
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.h:99:12: error: ebpf::BFrontendAction::BFrontendAction(llvm::raw_ostream&)
explicit BFrontendAction(llvm::raw_ostream &os);
^
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘virtual void ebpf::BFrontendAction::EndSourceFileAction()’:
/mnt/src/bcc/src/cc/frontends/clang/b_frontend_action.cc:443:7: error: ‘flags_’ was not declared in this scope
if (flags_ & 0x4)
^
make[2]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o] Error 1
make[1]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/all] Error 2
make: *** [all] Error 2
from bcc.
There must be some stale code hanging around somewhere. Did you try the usual suspects, like cleaning the build directory?
from bcc.
Yes, both make clean, and deleting the build directory...
# cksum src/cc/frontends/clang/b_frontend_action.cc tests/cc/test_clang.py
2865925912 18014 src/cc/frontends/clang/b_frontend_action.cc
4147208165 3547 tests/cc/test_clang.py
from bcc.
That's indeed very odd. Nothing comes to mind...let me know how I might help. The build passed on both buildbots, with gcc4.8+ubuntu14.04 and clang+fedora22 variants, as well as my arch linux gcc 5.2 box.
from bcc.
Might have been an older clang (rebuilding). I get further on a newer built system:
# ./disksnoop.py
<bcc-memory-buffer>:24:51: error: cannot take the address of an rvalue of type 'u64' (aka 'unsigned long long')
bpf_map_update_elem((void *)bpf_pseudo_fd(1, 3), &((u64)ctx->di), &ts, BPF_ANY);
^ ~~~~~~~~~~~~
<bcc-memory-buffer>:33:60: error: use of undeclared identifier 'u'
tsp = bpf_map_lookup_elem((void *)bpf_pseudo_fd(1, 3), &((u);
^
<bcc-memory-buffer>:43:2: error: expected '}'
}
^
<bcc-memory-buffer>:30:74: note: to match this '{'
int kprobe__blk_update_request(struct pt_regs *ctx, struct request *req) {
^
3 errors generated.
Traceback (most recent call last):
File "./disksnoop.py", line 19, in <module>
b = BPF(src_file="disksnoop.c")
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 349, in __init__
raise Exception("Failed to compile BPF module %s" % src_file)
Exception: Failed to compile BPF module disksnoop.c
Running:
#include <uapi/linux/ptrace.h>
#include <linux/blkdev.h>
BPF_HASH(start, struct request *);
int kprobe__blk_start_request(struct pt_regs *ctx, struct request *req) {
u64 ts;
// stash start timestamp by request ptr
ts = bpf_ktime_get_ns();
start.update(&req, &ts);
return 0;
}
int kprobe__blk_update_request(struct pt_regs *ctx, struct request *req) {
u64 *tsp, delta;
tsp = start.lookup(&req);
if (tsp != 0) {
delta = bpf_ktime_get_ns() - *tsp;
bpf_trace_printk("%d %x %d\n", req->__data_len,
req->cmd_flags, delta / 1000);
start.delete(&req);
}
return 0;
}
from bcc.
This should have been fixed by this very commit. Have you done make install?
A new parameter with the recent changeset is BPF(..., debug=0x4) which will print the clang-rewritten source. If you see no output when providing that flag, then the old library is still being loaded.
from bcc.
debug=0x4 prints nothing new. I've done a fresh bcc build with https://raw.githubusercontent.com/iovisor/bcc/3c4a29ced84bea80b957d21256d529afb02eb634/src/cc/frontends/clang/b_frontend_action.cc ...
from bcc.
Can you try from HEAD? There is a further fix that went in at 0ac26e8, as well the debug=0x4 flag requires a bunch of extra file changes to pass the flag to BFrontendAction.
from bcc.
I still can't see any debug code...
# clang --version
clang version 3.8.0 (http://llvm.org/git/clang.git 93885ee97cd4a65cc773a654cb2d15b2890c81a2) (http://llvm.org/git/llvm.git 2354b37ae030104dd424149804946722fce72872)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/src/llvm/build/install/bin
from bcc.
Ok, back to the system I rebuilt clang on... that now works with disksnoop.c as listed previously. This works, thanks!
from bcc.
Ok, closing then :)
from bcc.
Related Issues (20)
- tcpretrans causes error on latest Ubuntu HOT 1
- Kernel stack traces HOT 13
- biotop reports all operations as reads HOT 6
- Error: unknown argument: '-fcf-protection' HOT 2
- tool/sslsniff.py
- when I use bpf_attach_tracepoint to attach a uprobe, it cames out error as "perf_event_open(/sys/kernel/tracing/events/uprobes/dmabufAlloc/id): Interrupted system call" HOT 1
- tools/slabratetop: can't find linux/slub_def.h header
- tcpretrans: use of undeclared identifier 'BPF_CGROUP_UNIX_*' HOT 2
- ttysnoop fails on newer kernel HOT 3
- failed to create kprobe 'mutex_lock' using klockstat in kernel 6.7 HOT 1
- When i launch 'sudo opensnoop-bpfcc' the shell is launched for works but unfortunately the program happen three warnings
- Miscalulation of offset with consecutive bitfields HOT 7
- Fail run disksnoop.py example HOT 3
- bcc/libbpf-tools/fsdist.bpf.c:38:12: error: unsupported signed division, please convert to unsigned div/mod.
- /virtual/main.c:18:20: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'u64' (aka 'unsigned long long')
- build fails with python 3.12.1 HOT 4
- 0.29.1 + master (706ec4fe): compile time warnings HOT 2
- wqlat.py fails for 6.7 kernel with -w workqueue selection HOT 2
- error: unknown type name ‘GElf_Versym’; did you mean ‘GElf_Verdef’? HOT 3
- why i use memleak, trace kmalloc tracepoint, run 12hours, but only counted 64 stackid....
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bcc.