-
Notifications
You must be signed in to change notification settings - Fork 1.3k
pkg/cover: parse Rust DWARF #6000
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
Comments
We could also switch to own DWARF parsing: After I switched objdump to manual binary parsing, addr2line is the last slow part. Manual parsing of all DWARF looks super fast in my experiments, so we could drop tons of complexity related to lazy parsing, compile units, etc. |
There's still a question of what to look for in the DWARF info in this case :) I wish there were some explicit records as to what |
We won't need CGUs nor compile units, we just map all callback PCs to file:line info. Basically scan whole DWARF and extract all PC -> file:line info. |
After an offline discussion with @dvyukov: It would be best to teach syzkaller/pkg/cover/backend/dwarf.go Lines 370 to 380 in 350f4ff
The question is still how to extract these file names and how to split the address range. Getting the address ranges of a whole compilation unit is straigtforward - it's just in its direct
To split it per file, it looks like we'd have to go deeper into the DWARF tree and process all entries like this
Those subprograms that are not inlined, may have
... and the subprogram itself may of course also have |
If we are to follow the
This piece of code does indeed extract the PCs associated with the compilation unit as well as their source files, and these PCs are within the ranges returned by The small problem is that DWARF's compilation units are relative to the build directory (at least for kernel source files), while the
Do we want to call Another concern are PCs that belong to the Rust toolchain.
These same files are mentioned in many compilation units. Do we want to create fake |
Since it's a hack already, I would say call whatever is necessary to make it work.
We won't find/show these source files anyway. So if everything works without that, I don't think it's necessary. |
Rust compilation units are different from C in that a single compilation unit includes multiple source files, but we still need to tell which PC range belong to which source file. Infer that information from the LineEntry structures. Cc google#6000.
Rust compilation units are different from C in that a single compilation unit includes multiple source files, but we still need to tell which PC range belong to which source file. Infer that information from the LineEntry structures. Cc google#6000.
Rust compilation units are different from C in that a single compilation unit includes multiple source files, but we still need to tell which PC range belong to which source file. Infer that information from the LineEntry structures. Cc google#6000.
Rust compilation units are different from C in that a single compilation unit includes multiple source files, but we still need to tell which PC range belong to which source file. Infer that information from the LineEntry structures. Cc #6000.
Let's consider it solved. |
Given the huge amount of inlining, even after this change there are a number of Lines 244 to 246 in b47f9e0
Locally, I've also covered
I don't get why it's not one of the files with 100% fake coverage, though. If I see it appear when I |
Rust splits crates into Code Generation Units, which end up in
DW_TAG_compile_unit
.At the same time, all
.rs
files that belong to a crate are essentially squashed into the same compile unit, which goes against the assumptions of ourpkg/report
code that first extracts the compilation unitssyzkaller/pkg/cover/report.go
Lines 86 to 88 in 6ca47dd
and then maps
addr2line
results to them.If we just strip the
/@/..
part off the unit name, our coverage reports would only highlight the coverage from the single mentioned.rs
file and not from everything that was included viamod NAME;
.We could theoretically traverse the DWARF info and collect the files mentioned in
DW_AT_call_file
andDW_AT_decl_file
, but I wonder if there's a more elegant solution.The text was updated successfully, but these errors were encountered: