-
Notifications
You must be signed in to change notification settings - Fork 685
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 metadata to instructions returned by program info #1118
Add metadata to instructions returned by program info #1118
Conversation
a7efb4a
to
917fec1
Compare
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 is a really nice idea, when we wrote the current code to pull out instructions metadata wasn't a thing yet. This reminds me that we could also use metadata to tag map load isns we get from the kernel, I should create an issue.
Some high level thoughts: seems like what you really want to do is calling Assign()
. All of the other stuff with ExtInfoBuilder
is just a side-show. What do you think about the following?
- Export
funcInfo
andlineInfo
- Export constructors for
[]FuncInfo
,[]LineInfo
. Those should take a byte order, reader and a Spec probably. These are somewhere betweenparseFuncInfos
andparseFuncInfoRecords
: they take infos without the header and return a slice instead of a map. - Add a function
AssignInstructionMetadata(Instructions, []FuncInfo, []LineInfo)
and call that fromExtInfos.Assign
. The core relocation part we can keep inExtInfos.Assign
for now.
In general I want to avoid public APIs which assume native endian as much as possible. The same goes for the record size.
Yea, that is fair, sounds like a good way to approach this. I will make it so |
917fec1
to
303496f
Compare
428e523
to
2bc0dc6
Compare
Added exported types which contain slices of metadata objects so they can be used by other packages. In particular to in a followup commit. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
Added two constructors which allow for parsing of BTF FuncInfos and LineInfos from their wire format. This will be used in a followup commit to parse BTF metadata from program info. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
The `ProgInfo.LineInfo` and `ProgInfo.FuncInfo` fields were uint64. This commit changes their type from uint64 to Pointer so pointers can be assigned to these fields in a follow up commit. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
2bc0dc6
to
ea5a274
Compare
info_test.go
Outdated
|
||
spec, err := LoadCollectionSpec("testdata/raw_tracepoint-el.elf") | ||
if err != nil { | ||
panic(err) |
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: these should be t.Fatal
Edit: i'll fix these up.
The instructions returned by program info gotten from the kernel did not contain any metadata such as line info or function info. This makes it harder to read the instructions when comparing the xlated instruction in the kernel with the spec. This commit uses the line info and function info that is available via the program info and adds it to the returned instructions. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
ea5a274
to
4204efe
Compare
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.
Thanks!
The instructions returned by program info gotten from the kernel did
not contain any metadata such as line info or function info. This
makes it harder to read the instructions when comparing the xlated
instruction in the kernel with the spec.
This PR uses the line info and function info that is available via
the program info and adds it to the returned instructions.