-
Notifications
You must be signed in to change notification settings - Fork 289
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
aya: add symbol lookup in associated debug files #938
aya: add symbol lookup in associated debug files #938
Conversation
❌ Deploy Preview for aya-rs-docs failed.Built without sensitive environment variables
|
Thanks! This looks great. Could you add a test for the debuglink resolution? |
Actually thinking of it, given our current integration-test setup this is probably harder than it should be. Please take a look but if it's too cumbersome I'm fine just smoke testing this locally for now. |
I was initially planning to add UT, haha. However, I realized I needed to hook the I took a look at the integration test, but for this particular change, I think UT might be a more suitable choice because it doesn't affect the ebpf code part. If I am mistaken, please correct me. If it's okay, I will add some UTs using the |
c3754a2
to
a24aac3
Compare
unit test works! But why do you need to hook std::fs::read? |
Since |
You could introduce a new resolve_symbol_data(...) and call it from resolve_symbol. resolve_symbol would fs::read then call resolve_symbol_data with the content. Then you could unit test resolve_symbol_data and not need fs access? |
a24aac3
to
7e31e1f
Compare
Super cool. I work a lot with stripped binaries for which I have separate debug symbols, so this will be a real help. |
@alessandrod could you review this pr? thanks |
Yep sorry been travelling this week, will take a look soon |
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.
quality PR, thanks so much! Just a nit and please fix the lint issue
aya/src/programs/uprobe.rs
Outdated
|
||
debug_obj_keeper = Some(debug_obj); | ||
debug_obj_keeper.as_ref().map_or( | ||
Err(ResolveSymbolError::Unknown(symbol.to_string())), |
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: why not unwrap here?
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.
oh, I totally agree.
269e5bf
to
dea1b64
Compare
This change enhances the logic for symbol lookup in uprobe or uretprobe. If the symbol is not found in the original binary, the search continues in the debug file associated through the debuglink section. Before searching the symbol table, it compares the build IDs of the two files. The symbol lookup will only be terminated if both build IDs exist and do not match. This modification does not affect the existing symbol lookup logic. Refs: aya-rs#936
dea1b64
to
e6e1bfe
Compare
Hi @alessandrod this PR failed the public api check phase, but I am not sure if it's the root cause, could you help take a look? thanks! |
The equivalent crate has a blanket implementation smh. We don't depend on it directly it's pulled in by the object crate.
I think you can do |
Hey @alessandrod, this pull request changes the Aya Public API and requires your review. |
I think adding the write feature to the object crate pulls in a new transitive dependency - the equivalent crate. That crate has a blanket impl (smh), which impacts some of our types that we use as keys in maps. I just pushed a commit which hopefully makes CI green. |
Can you take a look at the test failure under miri? |
The object::File::parse API requires parameter to be aligned with 8 bytes. Adjusted the Vec in the tests with miri to meet this requirement.
I looked into this failure and found an exception, Invalid ELF header size or alignment, originating from the object crate. I checked the main_bytes generated by create_elf_with_build_id, and the ELF header size is 64, which seems correct. However, further investigation into the object crate showed that it has a strict address alignment requirement, leading to a failure in the object::File::parse API (see this link). My understanding is that in Rust, a Vec's memory comes from the heap and should be aligned to 8 bytes on x64 architectures. However, since I'm new to Rust, I'm not entirely certain about this. Obviously, this alignment is not guaranteed with the miri interpreter (this is my first time hearing about miri, haha). Given the strict limitation in the object crate, I decided to adjust the Vec to ensure 8-byte alignment in the tests as a workaround for miri (I am not sure if it's a good idea = =||). I've added a new commit with these changes. Could you please review it and let me know your thoughts? |
Yep ELF files must be aligned. Thank you again! |
This change enhances the logic for symbol lookup in uprobe or uretprobe. If the symbol is not found in the original binary, the search continues in the debug file associated through the debuglink section. Before searching the symbol table, it compares the build IDs of the two files. The symbol lookup will only be terminated if both build IDs exist and do not match. This modification does not affect the existing symbol lookup logic.
Refs: #936