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

Handle enum values in tracepoint format defs #2236

Merged
merged 1 commit into from
Jun 1, 2022

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented May 25, 2022

It may happen that a tracepoint format definition contains enum values instead of constants for array sizes. Not sure if this is a kernel bug or a legit behaviour but it has happened at my system (5.17.4-200.fc35.x86_64 kernel):

# cat /sys/kernel/debug/tracing/events/block/block_rq_issue/format
[...]
	field:char comm[TASK_COMM_LEN];	offset:40;	size:16;	signed:1;
[...]

breaking tools/bitesize.bt (fails with error: use of undeclared identifier 'TASK_COMM_LEN').

This PR fixes the problem by inserting the enum value into bpftrace.btf_set_ to get the definition from BTF.

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

@viktormalik viktormalik force-pushed the tp-format-enums branch 2 times, most recently from ef5c74d to 8bdd2cc Compare May 25, 2022 07:50
@viktormalik viktormalik mentioned this pull request May 25, 2022
4 tasks
@danobi
Copy link
Member

danobi commented May 28, 2022

LGTM, but can we add a unit test for this?

@viktormalik
Copy link
Contributor Author

LGTM, but can we add a unit test for this?

Good idea, I extended an existing unit test for tracepoint parsing.

It may happen that a tracepoint format definition contains enum values
instead of constants for array sizes. If that happens, insert the enum
value into bpftrace.btf_set_ to get the enum definition from BTF.

This bug broke tools/bitesize.bt on 5.17.4-200.fc35.x86_64 kernel.
@viktormalik viktormalik merged commit e0c66b4 into bpftrace:master Jun 1, 2022
@viktormalik viktormalik deleted the tp-format-enums branch June 1, 2022 09:10
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