-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Rust splits crates into Code Generation Units, which end up in DW_TAG_compile_unit.
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("clang LLVM (rustc version 1.86.0 (05f9846f8 2025-03-31))")
DW_AT_language (DW_LANG_Rust)
DW_AT_name ("drivers/android/binder/rust_binder.rs/@/rust_binder.7515a52ef019218e-cgu.0")
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ("/android")
DW_AT_low_pc (0x0000000000000000)
DW_AT_ranges (0x0005f850
[0x0000000000000010, 0x00000000000235d7)
[0x00000000000235f0, 0x000000000006dbe3)
[0x000000000006dc00, 0x000000000006dc43)
[0x0000000000000010, 0x000000000000063d)
[0x0000000000000650, 0x000000000000066a))
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 our pkg/report code that first extracts the compilation units
Lines 86 to 88 in 6ca47dd
| for _, unit := range rg.Units { | |
| files[unit.Name] = &file{ | |
| module: unit.Module.Name, |
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 via mod NAME;.
We could theoretically traverse the DWARF info and collect the files mentioned in DW_AT_call_file and DW_AT_decl_file, but I wonder if there's a more elegant solution.