Skip to content
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

Support printing entire structs #2557

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented Apr 6, 2023

Until now, field analyser resolved struct fields for structs accessed via a pointer only when the pointer dereference was followed by a field access, i.e. for cases like p->field.

This does the field resolution on every dereference, particularly allowing to print the entire struct using print(*p).

Also improves printing of pointers as they are often members of kernel structs.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Pointers are printed in hex format, e.g. "0xdeadbeef". This is
especially useful when printing structs containing pointer fields.

This changed the output format of some regression tests so they are
updated accordingly.
Until now, field analyser resolved struct fields for structs accessed
via a pointer only when the pointer dereference was followed by a field
access, i.e. for cases like `p->field`.

This does the field resolution on every dereference, particularly
allowing to print the entire struct using `print(*p)`.

Includes a test case for kfunc which failed before this change.
@viktormalik viktormalik merged commit ded5b31 into bpftrace:master Apr 6, 2023
@viktormalik viktormalik deleted the struct-print branch April 11, 2023 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants