@@ -547,28 +547,39 @@ mod tests {
547547 /// object file by applying ELF relocations during section loading.
548548 #[ test]
549549 fn function_and_line_parsing_relocatable ( ) {
550- let bin_name = Path :: new ( & env ! ( "CARGO_MANIFEST_DIR" ) )
551- . join ( "data" )
552- . join ( "test-stable-addrs.o" ) ;
550+ fn test ( obj_file : & str ) {
551+ let bin_name = Path :: new ( & env ! ( "CARGO_MANIFEST_DIR" ) )
552+ . join ( "data" )
553+ . join ( obj_file) ;
553554
554- let parser = ElfParser :: open ( bin_name. as_path ( ) ) . unwrap ( ) ;
555- let relocs = parser. section_relocations ( ) . unwrap ( ) ;
556- let mut load_section = |section| reader:: load_section ( & parser, section, relocs) ;
557- let dwarf = Dwarf :: < R > :: load ( & mut load_section) . unwrap ( ) ;
558- let units = Units :: parse ( dwarf, None ) . unwrap ( ) ;
559-
560- // Verify we can find a known function.
561- let mut funcs = units. find_name ( "factorial" ) ;
562- let func = funcs. next ( ) . unwrap ( ) . unwrap ( ) ;
563- assert_eq ! (
564- func. name. as_ref( ) . unwrap( ) . inner( ) . to_string( ) . unwrap( ) ,
565- "factorial"
566- ) ;
567-
568- // Verify that the function has an address range (requires correct
569- // relocation of DW_AT_low_pc/DW_AT_high_pc references).
570- let range = func. range . as_ref ( ) . unwrap ( ) ;
571- assert_ne ! ( range. begin, range. end) ;
555+ let parser = ElfParser :: open ( bin_name. as_path ( ) ) . unwrap ( ) ;
556+ let relocs = parser. section_relocations ( ) . unwrap ( ) ;
557+ let mut load_section = |section| reader:: load_section ( & parser, section, relocs) ;
558+ let dwarf = Dwarf :: < R > :: load ( & mut load_section) . unwrap ( ) ;
559+ let units = Units :: parse ( dwarf, None ) . unwrap ( ) ;
560+
561+ // Verify we can find a known function.
562+ let mut funcs = units. find_name ( "factorial" ) ;
563+ let func = funcs. next ( ) . unwrap ( ) . unwrap ( ) ;
564+ assert_eq ! (
565+ func. name. as_ref( ) . unwrap( ) . inner( ) . to_string( ) . unwrap( ) ,
566+ "factorial"
567+ ) ;
568+
569+ // Verify that the function has an address range (requires correct
570+ // relocation of DW_AT_low_pc/DW_AT_high_pc references).
571+ let range = func. range . as_ref ( ) . unwrap ( ) ;
572+ assert_ne ! ( range. begin, range. end) ;
573+
574+ let addr = range. begin ;
575+ let loc = units. find_location ( addr) . unwrap ( ) . unwrap ( ) ;
576+ assert_ne ! ( loc. dir, Path :: new( "" ) ) ;
577+ assert_eq ! ( loc. file, OsStr :: new( "test-stable-addrs.c" ) ) ;
578+ assert ! ( loc. line. is_some( ) ) ;
579+ }
580+
581+ test ( "test-stable-addrs.o" ) ;
582+ test ( "test-stable-addrs-32.o" ) ;
572583 }
573584
574585 /// Check that we fail to find any data for an address not
0 commit comments