Skip to content
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

Handle DW_TAG_partial_unit #514

Closed
calixteman opened this issue Jun 25, 2020 · 8 comments · Fixed by #515
Closed

Handle DW_TAG_partial_unit #514

calixteman opened this issue Jun 25, 2020 · 8 comments · Fixed by #515

Comments

@calixteman
Copy link
Contributor

I'm trying to use dump_syms which depends on symbolic which itself depends on gimli to dump breakpad symbols for iris_dri.so-20.1.1-1.fc32.x86_64.debug.
I get neither DW_TAG_subprogram nor DW_TAG_inlined_subroutine, all the units are either empty or erroneous.
I llvm-dwarf dump the file:
The first 54 CU looks like:

0x00000000: Compile Unit: length = 0x00000013 version = 0x0004 abbr_offset = 0x2842 addr_size = 0x08 (next unit at 0x00000017)

0x0000000b: DW_TAG_partial_unit

0x0000000c:   DW_TAG_imported_unit
                DW_AT_import	(<alt 0x2a6a57>)

0x00000011:   DW_TAG_imported_unit
                DW_AT_import	(<alt 0x2a6a73>)

0x00000016:   NULL

These ones look empty.
And all the next CU start with something like:

0x000000cf: Compile Unit: length = 0x0000001b version = 0x0004 abbr_offset = 0x15987 addr_size = 0x08 (next unit at 0x000000ee)

0x000000da: DW_TAG_partial_unit
              DW_AT_stmt_list	(0x00000000)
              DW_AT_comp_dir	()

0x000000e3:   DW_TAG_imported_unit
                DW_AT_import	(<alt 0xb>)

0x000000e8:   DW_TAG_imported_unit
                DW_AT_import	(<alt 0x2a6b29>)

0x000000ed:   NULL

they look like erroneous.
I greped on TAG_partial_unit on the gimli source and I got almost nothing so maybe it's because gimli doesn't handle partial unit.

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 25, 2020

What is the llvm-dwarfdump output?

@calixteman
Copy link
Contributor Author

The dump for .debug_info is ~700Mb so it's why I sumed it up in my comment 0.

@jrmuizel
Copy link
Contributor

It looks this is a regression.
With 3015ebe

$ cargo run --release --example dwarfdump /tmp/iris_dri.so-20.1.1-1.fc32.x86_64.debug | grep subprogram | wc
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/examples/dwarfdump /tmp/iris_dri.so-20.1.1-1.fc32.x86_64.debug`
   33444  100332 1278020

With master

$ cargo run --release --example dwarfdump /tmp/iris_dri.so-20.1.1-1.fc32.x86_64.debug | grep subprogram | wc
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/examples/dwarfdump /tmp/iris_dri.so-20.1.1-1.fc32.x86_64.debug`
       0       0       0

@jrmuizel
Copy link
Contributor

I'll run a bisection.

@jrmuizel
Copy link
Contributor

It looks like this was caused by 9dabba0

@mstange
Copy link
Contributor

mstange commented Jun 25, 2020

I've uploaded the file (gzipped) here: iris_dri.so-20.1.1-1.fc32.x86_64.debug.gz

@jrmuizel
Copy link
Contributor

More specifically with that change DwarfUnit returns Error because dwarf.attr_string(&unit, val) on comp_dir does.

@jrmuizel
Copy link
Contributor

diff --git a/src/read/dwarf.rs b/src/read/dwarf.rs
index 04fd013..eeb1a74 100644
--- a/src/read/dwarf.rs
+++ b/src/read/dwarf.rs
@@ -601,25 +601,25 @@ impl<R: Reader> Unit<R> {
                         if let AttributeValue::DebugRngListsBase(base) = attr.value() {
                             unit.rnglists_base = base;
                         }
                     }
                     _ => {}
                 }
             }
         }
 
         unit.name = match name {
-            Some(val) => Some(dwarf.attr_string(&unit, val)?),
+            Some(val) => dwarf.attr_string(&unit, val).ok(),
             None => None,
         };
         unit.comp_dir = match comp_dir {
-            Some(val) => Some(dwarf.attr_string(&unit, val)?),
+            Some(val) => dwarf.attr_string(&unit, val).ok(),
             None => None,
         };
         unit.line_program = match line_program_offset {
             Some(offset) => Some(dwarf.debug_line.program(
                 offset,
                 unit.header.address_size(),
                 unit.comp_dir.clone(),
                 unit.name.clone(),
             )?),
             None => None,

fixes it.

jrmuizel added a commit to jrmuizel/gimli that referenced this issue Jun 25, 2020
This matches the behaviour of llvm-dwarfdump:
e.g. dwarf::toString(UnitDie.find(DW_AT_comp_dir)) just returns an
Optional and doesn't fail.

Fixes gimli-rs#514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants