-
Notifications
You must be signed in to change notification settings - Fork 704
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
Add RelativeOffset
field to UprobeOptions
struct
#682
Conversation
link/uprobe.go
Outdated
@@ -49,9 +49,13 @@ type Executable struct { | |||
// UprobeOptions defines additional parameters that will be used | |||
// when loading Uprobes. | |||
type UprobeOptions struct { | |||
// Symbol offset. Must be provided in case of external symbols (shared libs). | |||
// Symbol offset (absolute). Must be provided in case of external symbols (shared libs). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be the offset from the start (so maybe absolute
is not the best term). Maybe leave this comment as is and specify in the comment below that RelativeOffset
is an additional offset relative to the calculated or provided offset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmat11 reverted with mertyildiran@ddbe83e
link/uprobe.go
Outdated
@@ -254,11 +262,12 @@ func (ex *Executable) uprobe(symbol string, prog *ebpf.Program, opts *UprobeOpti | |||
|
|||
offset := opts.Offset | |||
if offset == 0 { | |||
offset = opts.RelativeOffset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what about doing offset: offset+opts.RelativeOffset
in probeArgs
on line 287? this way the "relative offset" is added both for a specified one and for an internally calculated one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmat11 done with mertyildiran@8a7955a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, can you add a test that covers the feature?
@lmb I have added a test case with mertyildiran@89cb6f2 But IMHO, exporting the Line 160 in 0f69484
|
Also change the behaviour to always add RelativeOffset, regardless of where we got the absolute offset from.
Looks good to me, I've pushed 401e03f with small changes:
Regarding the API: If you are OK with these changes I'm happy to merge the PR. |
Alternative to #683
This PR, for a bpftrace program like below:
enables probing without the need of recalculating the offset of
main.probeMe
(which is already calculated and stored insideoffsets
field), adding0x2a
and settingOffset
field to the resulting value:The PR also improves some of the comments because it's hard to understand at first glance that with the block below, the
Offset
field nullifies the offset that's calculated from the given symbol and theOffset
is actually an absolute offset instead of a relative one:ebpf/link/uprobe.go
Lines 255 to 262 in 951bb28