@@ -592,28 +592,52 @@ where
592592 load_file_section ( id, file, endian, flags. dwo , & arena_data, & arena_relocations)
593593 } ;
594594 let mut dwarf = gimli:: Dwarf :: load ( & mut load_section) ?;
595- let mut load_dwo_parent_section = None ;
595+ let mut dwo_parent_units = HashMap :: new ( ) ;
596596 if flags. dwo {
597597 dwarf. file_type = gimli:: DwarfFileType :: Dwo ;
598598
599599 if let Some ( dwo_parent_file) = flags. dwo_parent . as_ref ( ) {
600- let arena_data = & arena_data;
601- let arena_relocations = & arena_relocations;
602- load_dwo_parent_section = Some ( move |id : gimli:: SectionId | -> Result < _ > {
600+ let mut load_dwo_parent_section = |id : gimli:: SectionId | -> Result < _ > {
603601 load_file_section (
604602 id,
605603 dwo_parent_file,
606604 endian,
607605 false ,
608- arena_data,
609- arena_relocations,
606+ & arena_data,
607+ & arena_relocations,
610608 )
611- } ) ;
612- dwarf. debug_addr = gimli:: Section :: load ( load_dwo_parent_section. as_mut ( ) . unwrap ( ) ) ?;
613- dwarf. ranges = gimli:: RangeLists :: new (
614- gimli:: Section :: load ( load_dwo_parent_section. as_mut ( ) . unwrap ( ) ) ?,
615- gimli:: Section :: load ( load_dwo_parent_section. as_mut ( ) . unwrap ( ) ) ?,
616- ) ;
609+ } ;
610+ let dwo_parent = gimli:: Dwarf :: load ( & mut load_dwo_parent_section) ?;
611+ dwarf. debug_addr = dwo_parent. debug_addr . clone ( ) ;
612+ dwarf. ranges = dwo_parent. ranges . clone ( ) ;
613+ dwo_parent_units = match dwo_parent
614+ . units ( )
615+ . map ( |unit_header| dwo_parent. unit ( unit_header) )
616+ . filter_map ( |unit| {
617+ let dwo_id = match unit. header . type_ ( ) {
618+ gimli:: UnitType :: Skeleton ( dwo_id) => dwo_id,
619+ gimli:: UnitType :: Compilation => {
620+ let mut entries = unit. entries ( ) ;
621+ let ( _, this) = entries. next_dfs ( ) ?. unwrap ( ) ;
622+ match this. attr_value ( gimli:: constants:: DW_AT_GNU_dwo_id ) ? {
623+ Some ( gimli:: AttributeValue :: DwoId ( dwo_id) ) => dwo_id,
624+ Some ( _) => unreachable ! ( ) ,
625+ None => return Ok ( None ) ,
626+ }
627+ }
628+ _ => return Ok ( None ) ,
629+ } ;
630+
631+ Ok ( Some ( ( dwo_id, unit) ) )
632+ } )
633+ . collect ( )
634+ {
635+ Ok ( units) => units,
636+ Err ( err) => {
637+ eprintln ! ( "Failed to process --dwo-parent units: {}" , err) ;
638+ return Ok ( ( ) ) ;
639+ }
640+ }
617641 }
618642 }
619643
@@ -672,40 +696,7 @@ where
672696 ) ?;
673697 }
674698 if flags. info {
675- let dwo_parent_headers = if let Some ( loader) = load_dwo_parent_section. as_mut ( ) {
676- let dwarf = gimli:: Dwarf :: load ( loader) ?;
677- match dwarf
678- . units ( )
679- . map ( |unit_header| dwarf. unit ( unit_header) )
680- . filter_map ( |unit| {
681- let dwo_id = match unit. header . type_ ( ) {
682- gimli:: UnitType :: Skeleton ( dwo_id) => dwo_id,
683- gimli:: UnitType :: Compilation => {
684- let mut entries = unit. entries ( ) ;
685- let ( _, this) = entries. next_dfs ( ) ?. unwrap ( ) ;
686- match this. attr_value ( gimli:: constants:: DW_AT_GNU_dwo_id ) ? {
687- Some ( gimli:: AttributeValue :: DwoId ( dwo_id) ) => dwo_id,
688- Some ( _) => unreachable ! ( ) ,
689- None => return Ok ( None ) ,
690- }
691- }
692- _ => return Ok ( None ) ,
693- } ;
694-
695- Ok ( Some ( ( dwo_id, unit) ) )
696- } )
697- . collect ( )
698- {
699- Ok ( units) => units,
700- Err ( err) => {
701- eprintln ! ( "Failed to process --dwo-parent units: {}" , err) ;
702- return Ok ( ( ) ) ;
703- }
704- }
705- } else {
706- HashMap :: new ( )
707- } ;
708- dump_info ( & dwarf, dwo_parent_headers, flags) ?;
699+ dump_info ( & dwarf, dwo_parent_units, flags) ?;
709700 dump_types ( & mut BufWriter :: new ( out. lock ( ) ) , & dwarf, flags) ?;
710701 writeln ! ( & mut out. lock( ) ) ?;
711702 }
@@ -1010,7 +1001,7 @@ fn dump_cfi_instructions<R: Reader, W: Write>(
10101001
10111002fn dump_info < R : Reader > (
10121003 dwarf : & gimli:: Dwarf < R > ,
1013- dwo_parent_headers : HashMap < gimli:: DwoId , gimli:: Unit < R > > ,
1004+ dwo_parent_units : HashMap < gimli:: DwoId , gimli:: Unit < R > > ,
10141005 flags : & Flags ,
10151006) -> Result < ( ) >
10161007where
@@ -1096,7 +1087,7 @@ where
10961087 }
10971088 _ => None ,
10981089 } {
1099- if let Some ( parent_unit) = dwo_parent_headers . get ( & dwo_id) {
1090+ if let Some ( parent_unit) = dwo_parent_units . get ( & dwo_id) {
11001091 unit. copy_relocated_attributes ( parent_unit) ;
11011092 }
11021093 }
0 commit comments