@@ -154,10 +154,7 @@ impl<E: gimli::Endianity> DwpStringTable<E> {
154
154
let ( index, is_new) = self . strings . insert_full ( bytes. clone ( ) ) ;
155
155
let index = DwpStringId ( index) ;
156
156
if !is_new {
157
- return Ok ( * self
158
- . offsets
159
- . get ( & index)
160
- . expect ( "insert exists but no offset" ) ) ;
157
+ return Ok ( * self . offsets . get ( & index) . expect ( "insert exists but no offset" ) ) ;
161
158
}
162
159
163
160
// Keep track of the offset for this string, it might be referenced by the next compilation
@@ -280,11 +277,7 @@ fn load_file_section<'input, 'arena: 'input>(
280
277
arena_relocations : & ' arena Arena < RelocationMap > ,
281
278
) -> Result < DwpReader < ' arena > > {
282
279
let mut relocations = RelocationMap :: default ( ) ;
283
- let name = if is_dwo {
284
- id. dwo_name ( )
285
- } else {
286
- Some ( id. name ( ) )
287
- } ;
280
+ let name = if is_dwo { id. dwo_name ( ) } else { Some ( id. name ( ) ) } ;
288
281
289
282
let data = match name. and_then ( |name| obj. section_by_name ( & name) ) {
290
283
Some ( ref section) => {
@@ -301,11 +294,7 @@ fn load_file_section<'input, 'arena: 'input>(
301
294
let reader = gimli:: EndianSlice :: new ( data_ref, runtime_endian_of_object ( obj) ) ;
302
295
let section = reader;
303
296
let relocations = ( * arena_relocations. alloc ( relocations) ) . borrow ( ) ;
304
- Ok ( Relocate {
305
- relocations,
306
- section,
307
- reader,
308
- } )
297
+ Ok ( Relocate { relocations, section, reader } )
309
298
}
310
299
311
300
/// Returns the `DwoId` of a DIE.
@@ -358,10 +347,7 @@ fn dwo_id_and_path_of_unit<R: gimli::Reader>(
358
347
return Err ( anyhow ! ( DwpError :: DwoIdWithoutDwoName ) ) ;
359
348
} ;
360
349
361
- dwarf
362
- . attr_string ( & unit, dwo_name) ?
363
- . to_string ( ) ?
364
- . into_owned ( )
350
+ dwarf. attr_string ( & unit, dwo_name) ?. to_string ( ) ?. into_owned ( )
365
351
} ;
366
352
367
353
// Prepend the compilation directory if it exists.
@@ -466,10 +452,7 @@ fn append_str_offsets<'input, 'output, 'arena: 'input, Endian: gimli::Endianity>
466
452
467
453
let mut data = EndianVec :: new ( runtime_endian_of_object ( dwo_obj) ) ;
468
454
469
- let root_header = dwo_dwarf
470
- . units ( )
471
- . next ( ) ?
472
- . context ( DwpError :: DwarfObjectWithNoUnits ) ?;
455
+ let root_header = dwo_dwarf. units ( ) . next ( ) ?. context ( DwpError :: DwarfObjectWithNoUnits ) ?;
473
456
let encoding = root_header. encoding ( ) ;
474
457
let base = DebugStrOffsetsBase :: default_for_encoding_and_file ( encoding, DwarfFileType :: Dwo ) ;
475
458
@@ -478,52 +461,29 @@ fn append_str_offsets<'input, 'output, 'arena: 'input, Endian: gimli::Endianity>
478
461
Format :: Dwarf64 => 8 ,
479
462
} ;
480
463
481
- debug ! (
482
- ?section_size,
483
- str_offset_size_num_elements = section_size / entry_size
484
- ) ;
464
+ debug ! ( ?section_size, str_offset_size_num_elements = section_size / entry_size) ;
485
465
for i in 0 ..( section_size / entry_size) {
486
466
let dwo_index = DebugStrOffsetsIndex ( i as usize ) ;
487
467
let dwo_offset =
488
- dwo_dwarf
489
- . debug_str_offsets
490
- . get_str_offset ( encoding. format , base, dwo_index) ?;
468
+ dwo_dwarf. debug_str_offsets . get_str_offset ( encoding. format , base, dwo_index) ?;
491
469
let dwo_str = dwo_dwarf. debug_str . get_str ( dwo_offset) ?;
492
470
let dwo_str = dwo_str. to_string ( ) ?;
493
471
494
472
let dwp_offset = string_table. get_or_insert ( dwo_str. as_ref ( ) ) ?;
495
- debug ! (
496
- ?i,
497
- ?dwo_str,
498
- "dwo_offset={:#x} dwp_offset={:#x}" ,
499
- dwo_offset. 0 ,
500
- dwp_offset. 0
501
- ) ;
473
+ debug ! ( ?i, ?dwo_str, "dwo_offset={:#x} dwp_offset={:#x}" , dwo_offset. 0 , dwp_offset. 0 ) ;
502
474
503
475
match encoding. format {
504
476
Format :: Dwarf32 => {
505
- data. write_u32 (
506
- dwp_offset
507
- . 0
508
- . try_into ( )
509
- . context ( DwpError :: DwpStrOffsetOutOfRange ) ?,
510
- ) ?;
477
+ data. write_u32 ( dwp_offset. 0 . try_into ( ) . context ( DwpError :: DwpStrOffsetOutOfRange ) ?) ?;
511
478
}
512
479
Format :: Dwarf64 => {
513
- data. write_u64 (
514
- dwp_offset
515
- . 0
516
- . try_into ( )
517
- . context ( DwpError :: DwpStrOffsetOutOfRange ) ?,
518
- ) ?;
480
+ data. write_u64 ( dwp_offset. 0 . try_into ( ) . context ( DwpError :: DwpStrOffsetOutOfRange ) ?) ?;
519
481
}
520
482
}
521
483
}
522
484
523
485
let offset =
524
- output
525
- . obj
526
- . append_section_data ( output. debug_str_offsets , & data. into_vec ( ) , section. align ( ) ) ;
486
+ output. obj . append_section_data ( output. debug_str_offsets , & data. into_vec ( ) , section. align ( ) ) ;
527
487
Ok ( Some ( Contribution {
528
488
offset : ContributionOffset ( offset) ,
529
489
size : section_size. try_into ( ) . expect ( "too large for u32" ) ,
@@ -557,23 +517,16 @@ where
557
517
. data_range ( dwo_offset. try_into ( ) . unwrap ( ) , dwo_length) ?
558
518
. ok_or ( DwpError :: CompilationUnitWithNoData ) ?;
559
519
let dwp_offset =
560
- output
561
- . obj
562
- . append_section_data ( output. debug_info , dwo_data, debug_info. align ( ) ) ;
520
+ output. obj . append_section_data ( output. debug_info , dwo_data, debug_info. align ( ) ) ;
563
521
564
522
create_cu_entry (
565
523
dwo_id,
566
- Contribution {
567
- offset : ContributionOffset ( dwp_offset) ,
568
- size : dwo_length,
569
- } ,
524
+ Contribution { offset : ContributionOffset ( dwp_offset) , size : dwo_length } ,
570
525
) ;
571
526
572
527
Ok ( ( ) )
573
528
}
574
- ( Some ( ..) , _) => Err ( anyhow ! (
575
- DwpError :: DwarfObjectCompilationUnitWithDwoIdNotSplitUnit
576
- ) ) ,
529
+ ( Some ( ..) , _) => Err ( anyhow ! ( DwpError :: DwarfObjectCompilationUnitWithDwoIdNotSplitUnit ) ) ,
577
530
_ => Ok ( ( ) ) ,
578
531
}
579
532
}
@@ -596,9 +549,7 @@ fn append_section<'input, 'output>(
596
549
597
550
Ok ( Some ( Contribution { offset : ContributionOffset ( offset) , size } ) )
598
551
}
599
- None if required => Err ( anyhow ! ( DwpError :: DwarfObjectMissingSection (
600
- name. to_string( )
601
- ) ) ) ,
552
+ None if required => Err ( anyhow ! ( DwpError :: DwarfObjectMissingSection ( name. to_string( ) ) ) ) ,
602
553
None => Ok ( None ) ,
603
554
}
604
555
}
@@ -607,14 +558,7 @@ fn append_section<'input, 'output>(
607
558
/// object into output object.
608
559
#[ tracing:: instrument(
609
560
level = "trace" ,
610
- skip(
611
- parent_debug_addr,
612
- string_table,
613
- output,
614
- arena_data,
615
- arena_mmap,
616
- arena_relocations
617
- )
561
+ skip( parent_debug_addr, string_table, output, arena_data, arena_mmap, arena_relocations)
618
562
) ]
619
563
fn process_dwarf_object < ' input , ' output , ' arena : ' input , Endian : gimli:: Endianity > (
620
564
parent_debug_addr : DebugAddr < DwpReader < ' arena > > ,
@@ -709,10 +653,7 @@ fn next_pow2(mut val: u32) -> u32 {
709
653
/// Returns a hash table computed for `elements`. Used in the `.debug_{cu,tu}_index` sections.
710
654
#[ tracing:: instrument( level = "trace" , skip_all) ]
711
655
fn bucket < B : Bucketable + fmt:: Debug > ( elements : & [ B ] ) -> Vec < u32 > {
712
- let unit_count: u32 = elements
713
- . len ( )
714
- . try_into ( )
715
- . expect ( "unit count too big for u32" ) ;
656
+ let unit_count: u32 = elements. len ( ) . try_into ( ) . expect ( "unit count too big for u32" ) ;
716
657
let num_buckets = next_pow2 ( 3 * unit_count / 2 ) ;
717
658
let mask: u64 = num_buckets as u64 - 1 ;
718
659
@@ -753,9 +694,7 @@ fn write_indices<'output, E: gimli::Endianity>(
753
694
debug ! ( ?has_loc, ?has_line, ?has_str_off, ?has_rng) ;
754
695
755
696
let num_columns = cu_index_entries. first ( ) . unwrap ( ) . number_of_columns ( ) ;
756
- assert ! ( cu_index_entries
757
- . iter( )
758
- . all( |e| e. number_of_columns( ) == num_columns) ) ;
697
+ assert ! ( cu_index_entries. iter( ) . all( |e| e. number_of_columns( ) == num_columns) ) ;
759
698
debug ! ( ?num_columns) ;
760
699
761
700
// DWARF 5
@@ -841,22 +780,18 @@ fn write_indices<'output, E: gimli::Endianity>(
841
780
}
842
781
843
782
// FIXME: use the correct alignment here
844
- let _ = output
845
- . obj
846
- . append_section_data ( output. debug_cu_index , & cu_index_data. into_vec ( ) , 1 ) ;
783
+ let _ = output. obj . append_section_data ( output. debug_cu_index , & cu_index_data. into_vec ( ) , 1 ) ;
847
784
Ok ( ( ) )
848
785
}
849
786
850
787
fn main ( ) -> Result < ( ) > {
851
- let subscriber = Registry :: default ( )
852
- . with ( EnvFilter :: from_env ( "RUST_DWP_LOG" ) )
853
- . with (
854
- HierarchicalLayer :: default ( )
855
- . with_writer ( io:: stderr)
856
- . with_indent_lines ( true )
857
- . with_targets ( true )
858
- . with_indent_amount ( 2 ) ,
859
- ) ;
788
+ let subscriber = Registry :: default ( ) . with ( EnvFilter :: from_env ( "RUST_DWP_LOG" ) ) . with (
789
+ HierarchicalLayer :: default ( )
790
+ . with_writer ( io:: stderr)
791
+ . with_indent_lines ( true )
792
+ . with_targets ( true )
793
+ . with_indent_amount ( 2 ) ,
794
+ ) ;
860
795
tracing:: subscriber:: set_global_default ( subscriber) . unwrap ( ) ;
861
796
862
797
let opt = Opt :: from_args ( ) ;
0 commit comments