bpftrace: Fix __data_loc reads #122
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cherry-pick bpftrace/bpftrace@665b754
A __data_loc field is an (offset, len) pair; its value is determined by
adding the offset (in bytes) to the address of the tracepoint struct.
Commit bpftrace/bpftrace@06a8972 ("codegen: use preserve_static_offset intrinsic")
replaced the add instruction with getelementptr, but used i32 as the
GEP type without adjusting the offset. This causes the value to be
incorrectly set to ctx + 4*offset.
For example, this currently prints an empty or incomplete filename:
bpftrace -e 't:sched:sched_process_exec { print(str(args.filename)) }'
Fix it by changing the getelementptr type argument to i8.