44#![ allow( clippy:: needless_lifetimes) ]
55
66use fallible_iterator:: FallibleIterator ;
7- use gimli:: { Section , UnitHeader , UnitOffset , UnitSectionOffset , UnitType , UnwindSection } ;
7+ use gimli:: { Section , UnitHeader , UnitOffset , UnitType , UnwindSection } ;
88use object:: { Object , ObjectSection } ;
99use regex:: bytes:: Regex ;
1010use std:: borrow:: Cow ;
@@ -1033,13 +1033,12 @@ where
10331033 }
10341034 } ;
10351035 let process_unit = |header : UnitHeader < R > , buf : & mut Vec < u8 > | -> Result < ( ) > {
1036- let output_unit = dump_unit ( buf, header, dwarf, dwo_parent_units, flags) ?;
1037- if !output_unit
1038- || !flags
1039- . match_units
1040- . as_ref ( )
1041- . map ( |r| r. is_match ( buf) )
1042- . unwrap_or ( true )
1036+ dump_unit ( buf, header, dwarf, dwo_parent_units, flags) ?;
1037+ if !flags
1038+ . match_units
1039+ . as_ref ( )
1040+ . map ( |r| r. is_match ( buf) )
1041+ . unwrap_or ( true )
10431042 {
10441043 buf. clear ( ) ;
10451044 }
@@ -1071,32 +1070,28 @@ fn dump_unit<R: Reader, W: Write>(
10711070 dwarf : & gimli:: Dwarf < R > ,
10721071 dwo_parent_units : Option < & HashMap < gimli:: DwoId , gimli:: Unit < R > > > ,
10731072 flags : & Flags ,
1074- ) -> Result < bool > {
1075- write ! ( w, "\n UNIT<" ) ?;
1076- let offset = match header. offset ( ) {
1077- UnitSectionOffset :: DebugInfoOffset ( o) => {
1078- write ! ( w, ".debug_info+0x{:08x}" , o. 0 ) ?;
1079- if let Some ( offset) = flags. info_offset {
1080- if offset == o {
1081- // If the offset points to the very start of the unit, we
1082- // can process everything from here on normally.
1083- None
1084- } else if let Some ( o) = offset. to_unit_offset ( & header) {
1085- Some ( o)
1086- } else {
1087- // Skip this unit and erase what we already wrote.
1088- return Ok ( false ) ;
1089- }
1090- } else {
1073+ ) -> Result < ( ) > {
1074+ let offset = if let Some ( o) = header. offset ( ) . to_debug_info_offset ( & header) {
1075+ if let Some ( offset) = flags. info_offset {
1076+ if offset == o {
1077+ // If the offset points to the very start of the unit, we
1078+ // can process everything from here on normally.
10911079 None
1080+ } else if let Some ( o) = offset. to_unit_offset ( & header) {
1081+ Some ( o)
1082+ } else {
1083+ // Skip this unit.
1084+ return Ok ( ( ) ) ;
10921085 }
1093- }
1094- UnitSectionOffset :: DebugTypesOffset ( o) => {
1095- write ! ( w, ".debug_types+0x{:08x}" , o. 0 ) ?;
1086+ } else {
10961087 None
10971088 }
1089+ } else {
1090+ None
10981091 } ;
1099- writeln ! ( w, ">: length = 0x{:x}, format = {:?}, version = {}, address_size = {}, abbrev_offset = 0x{:x}" ,
1092+ writeln ! ( w, "\n UNIT<{}+0x{:08x}>: length = 0x{:x}, format = {:?}, version = {}, address_size = {}, abbrev_offset = 0x{:x}" ,
1093+ header. section( ) . name( ) ,
1094+ header. offset( ) . 0 ,
11001095 header. unit_length( ) ,
11011096 header. format( ) ,
11021097 header. version( ) ,
@@ -1129,7 +1124,7 @@ fn dump_unit<R: Reader, W: Write>(
11291124 Ok ( unit) => unit,
11301125 Err ( err) => {
11311126 writeln_error ( w, dwarf, err. into ( ) , "Failed to parse unit root entry" ) ?;
1132- return Ok ( true ) ;
1127+ return Ok ( ( ) ) ;
11331128 }
11341129 } ;
11351130
@@ -1146,7 +1141,7 @@ fn dump_unit<R: Reader, W: Write>(
11461141 if let Err ( err) = entries_result {
11471142 writeln_error ( w, dwarf, err, "Failed to dump entries" ) ?;
11481143 }
1149- Ok ( true )
1144+ Ok ( ( ) )
11501145}
11511146
11521147fn spaces ( buf : & mut String , len : usize ) -> & str {
@@ -1167,11 +1162,7 @@ fn write_offset<R: Reader, W: Write>(
11671162) -> Result < ( ) > {
11681163 write ! ( w, "<0x{:08x}" , offset. 0 ) ?;
11691164 if flags. goff {
1170- let goff = match offset. to_unit_section_offset ( unit) {
1171- UnitSectionOffset :: DebugInfoOffset ( o) => o. 0 ,
1172- UnitSectionOffset :: DebugTypesOffset ( o) => o. 0 ,
1173- } ;
1174- write ! ( w, " GOFF=0x{:08x}" , goff) ?;
1165+ write ! ( w, " GOFF=0x{:08x}" , offset. to_unit_section_offset( unit) . 0 ) ?;
11751166 }
11761167 write ! ( w, ">" ) ?;
11771168 Ok ( ( ) )
@@ -1377,16 +1368,13 @@ fn dump_attr_value<R: Reader, W: Write>(
13771368 writeln ! ( w, "{:#x}" , address) ?;
13781369 }
13791370 gimli:: AttributeValue :: UnitRef ( offset) => {
1380- write ! ( w, "0x{:08x}" , offset. 0 ) ?;
1381- match offset. to_unit_section_offset ( & unit) {
1382- UnitSectionOffset :: DebugInfoOffset ( goff) => {
1383- write ! ( w, "<.debug_info+0x{:08x}>" , goff. 0 ) ?;
1384- }
1385- UnitSectionOffset :: DebugTypesOffset ( goff) => {
1386- write ! ( w, "<.debug_types+0x{:08x}>" , goff. 0 ) ?;
1387- }
1388- }
1389- writeln ! ( w) ?;
1371+ writeln ! (
1372+ w,
1373+ "0x{:08x}<{}+0x{:08x}>" ,
1374+ offset. 0 ,
1375+ unit. section( ) . name( ) ,
1376+ offset. to_unit_section_offset( & unit) . 0 ,
1377+ ) ?;
13901378 }
13911379 gimli:: AttributeValue :: DebugInfoRef ( offset) => {
13921380 writeln ! ( w, "<.debug_info+0x{:08x}>" , offset. 0 ) ?;
@@ -1975,7 +1963,7 @@ fn dump_line<R: Reader, W: Write>(w: &mut W, dwarf: &gimli::Dwarf<R>) -> Result<
19751963 writeln ! (
19761964 w,
19771965 "\n .debug_line: line number info for unit at .debug_info offset 0x{:08x}" ,
1978- header. offset( ) . as_debug_info_offset ( ) . unwrap ( ) . 0
1966+ header. offset( ) . 0
19791967 ) ?;
19801968 let unit = match dwarf. unit ( header) {
19811969 Ok ( unit) => unit,
0 commit comments