@@ -24,24 +24,26 @@ impl Mapping {
2424
2525 // Try to locate an external debug file using the build ID.
2626 if let Some ( path_debug) = object. build_id ( ) . and_then ( locate_build_id) {
27- if let Some ( mapping) = Mapping :: new_debug ( path_debug, None ) {
27+ if let Some ( mapping) = Mapping :: new_debug ( path , path_debug, None ) {
2828 return Some ( Either :: A ( mapping) ) ;
2929 }
3030 }
3131
3232 // Try to locate an external debug file using the GNU debug link section.
3333 if let Some ( ( path_debug, crc) ) = object. gnu_debuglink_path ( path) {
34- if let Some ( mapping) = Mapping :: new_debug ( path_debug, Some ( crc) ) {
34+ if let Some ( mapping) = Mapping :: new_debug ( path , path_debug, Some ( crc) ) {
3535 return Some ( Either :: A ( mapping) ) ;
3636 }
3737 }
3838
39- Context :: new ( stash, object, None ) . map ( Either :: B )
39+ let dwp = Mapping :: load_dwarf_package ( path, stash) ;
40+
41+ Context :: new ( stash, object, None , dwp) . map ( Either :: B )
4042 } )
4143 }
4244
4345 /// Load debuginfo from an external debug file.
44- fn new_debug ( path : PathBuf , crc : Option < u32 > ) -> Option < Mapping > {
46+ fn new_debug ( original_path : & Path , path : PathBuf , crc : Option < u32 > ) -> Option < Mapping > {
4547 let map = super :: mmap ( & path) ?;
4648 Mapping :: mk ( map, |map, stash| {
4749 let object = Object :: parse ( & map) ?;
@@ -51,20 +53,45 @@ impl Mapping {
5153 }
5254
5355 // Try to locate a supplementary object file.
56+ let mut sup = None ;
5457 if let Some ( ( path_sup, build_id_sup) ) = object. gnu_debugaltlink_path ( & path) {
5558 if let Some ( map_sup) = super :: mmap ( & path_sup) {
5659 let map_sup = stash. set_mmap_aux ( map_sup) ;
57- if let Some ( sup ) = Object :: parse ( map_sup) {
58- if sup . build_id ( ) == Some ( build_id_sup) {
59- return Context :: new ( stash , object , Some ( sup ) ) ;
60+ if let Some ( sup_ ) = Object :: parse ( map_sup) {
61+ if sup_ . build_id ( ) == Some ( build_id_sup) {
62+ sup = Some ( sup_ ) ;
6063 }
6164 }
6265 }
6366 }
6467
65- Context :: new ( stash, object, None )
68+ let dwp = Mapping :: load_dwarf_package ( original_path, stash) ;
69+
70+ Context :: new ( stash, object, sup, dwp)
6671 } )
6772 }
73+
74+ /// Try to locate a DWARF package file.
75+ fn load_dwarf_package < ' data > ( path : & Path , stash : & ' data Stash ) -> Option < Object < ' data > > {
76+ let mut path_dwp = path. to_path_buf ( ) ;
77+ let dwp_extension = path
78+ . extension ( )
79+ . map ( |previous_extension| {
80+ let mut previous_extension = previous_extension. to_os_string ( ) ;
81+ previous_extension. push ( ".dwp" ) ;
82+ previous_extension
83+ } )
84+ . unwrap_or_else ( || "dwp" . into ( ) ) ;
85+ path_dwp. set_extension ( dwp_extension) ;
86+ if let Some ( map_dwp) = super :: mmap ( & path_dwp) {
87+ let map_dwp = stash. set_mmap_dwp ( map_dwp) ;
88+ if let Some ( dwp_) = Object :: parse ( map_dwp) {
89+ return Some ( dwp_) ;
90+ }
91+ }
92+
93+ None
94+ }
6895}
6996
7097struct ParsedSym {
0 commit comments