-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare bpftrace for struct arguments to kfuncs #2339
Comments
Personally, I don't like this too much as we'd basically change the type of the argument (non-pointer to pointer). I'd prefer treating it as the struct (which it is) and accessing the members with In fact, the only problem I can see here is the way we handle anonymous structs at the moment. We rely on the type name to fill the correct type defs from ClangParser, which is obviously a problem. It'll be partially eliminated by resolving the structs directly in FieldAnalyser (part of #2315) and we could also store the type under the typedef name for these cases, which would resolve it completely.
Is it? There's a 16-byte load but after that only 8 bytes are stored ( |
Yeah, the store is wrong of course. This assumption needs unwinding, that whole ptrtoint cast would now be wrong:
I'd like to avoid storing it under the typedef name, if possible, just to keep things similar to btf. Maybe we can internally refer to the type by (btf type id, btf source) tuples or even by a |
So we have On the other hand, when using BTF, types can be resolved in |
BPF is gaining support for struct fentry arguments. These are currently rejected in the verifier or, if you try to use kprobe, you see the argument split across multiple argX values.
The code from bpftrace 0.15 looks reasonable enough:
(This code blows up at the assertion here in debug builds.)
Interestingly, this 16 byte copy is kinda correct. However, semantically, it produces a value that cannot be used. Namely, the type of
$tmp
is an anonymous struct (typedef sockptr_t
) with unnamed members (a union), so it cannot be passed tobuf
,str
,printf
, orprint
directly.->
navigation also doesn't work because it's not a pointer to a struct.I'm opening this issue to discuss what the language semantics for these values should be.
I am of the opinion that $tmp in the above program should magically become pointer-to-struct, so everything works transparently but maybe that's too much magic.
I'm also interested to hear if we think this is worth solving for kprobe programs as well. (It can be, it's just more complexity).
The text was updated successfully, but these errors were encountered: