@@ -11,7 +11,6 @@ use crate::symbolize::ResolveWhat;
11
11
use crate :: types:: BytesOrWideString ;
12
12
use crate :: SymbolName ;
13
13
use addr2line:: gimli;
14
- use core:: convert:: TryFrom ;
15
14
use core:: mem;
16
15
use core:: u32;
17
16
use findshlibs:: { self , Segment , SharedLibrary } ;
@@ -83,9 +82,10 @@ fn mmap(path: &Path) -> Option<Mmap> {
83
82
84
83
cfg_if:: cfg_if! {
85
84
if #[ cfg( windows) ] {
86
- use std:: cmp;
87
85
use goblin:: pe:: { self , PE } ;
88
86
use goblin:: strtab:: Strtab ;
87
+ use std:: cmp;
88
+ use std:: convert:: TryFrom ;
89
89
90
90
struct Object <' a> {
91
91
pe: PE <' a>,
@@ -542,14 +542,11 @@ pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) {
542
542
None => return ,
543
543
} ;
544
544
if let Ok ( mut frames) = cx. dwarf . find_frames ( addr. 0 as u64 ) {
545
- while let Ok ( Some ( mut frame) ) = frames. next ( ) {
546
- let function = frame. function . take ( ) ;
547
- let name = function. as_ref ( ) . and_then ( |f| f. raw_name ( ) . ok ( ) ) ;
548
- let name = name. as_ref ( ) . map ( |n| n. as_bytes ( ) ) ;
545
+ while let Ok ( Some ( frame) ) = frames. next ( ) {
549
546
cb. call ( Symbol :: Frame {
550
547
addr : addr. 0 as * mut c_void ,
551
- frame,
552
- name,
548
+ location : frame. location ,
549
+ name : frame . function . map ( |f| f . name . slice ( ) ) ,
553
550
} ) ;
554
551
}
555
552
}
@@ -605,7 +602,7 @@ pub enum Symbol<'a> {
605
602
/// `addr2line`'s frame internally has all the nitty gritty details.
606
603
Frame {
607
604
addr : * mut c_void ,
608
- frame : addr2line:: Frame < EndianSlice < ' a , Endian > > ,
605
+ location : Option < addr2line:: Location < ' a > > ,
609
606
name : Option < & ' a [ u8 ] > ,
610
607
} ,
611
608
/// Couldn't find debug information, but we found it in the symbol table of
@@ -639,9 +636,8 @@ impl Symbol<'_> {
639
636
pub fn filename_raw ( & self ) -> Option < BytesOrWideString > {
640
637
match self {
641
638
Symbol :: Dladdr ( s) => return s. filename_raw ( ) ,
642
- Symbol :: Frame { frame, .. } => {
643
- let location = frame. location . as_ref ( ) ?;
644
- let file = location. file . as_ref ( ) ?;
639
+ Symbol :: Frame { location, .. } => {
640
+ let file = location. as_ref ( ) ?. file ?;
645
641
Some ( BytesOrWideString :: Bytes ( file. as_bytes ( ) ) )
646
642
}
647
643
Symbol :: Symtab { .. } => None ,
@@ -651,9 +647,8 @@ impl Symbol<'_> {
651
647
pub fn filename ( & self ) -> Option < & Path > {
652
648
match self {
653
649
Symbol :: Dladdr ( s) => return s. filename ( ) ,
654
- Symbol :: Frame { frame, .. } => {
655
- let location = frame. location . as_ref ( ) ?;
656
- let file = location. file . as_ref ( ) ?;
650
+ Symbol :: Frame { location, .. } => {
651
+ let file = location. as_ref ( ) ?. file ?;
657
652
Some ( Path :: new ( file) )
658
653
}
659
654
Symbol :: Symtab { .. } => None ,
@@ -663,10 +658,7 @@ impl Symbol<'_> {
663
658
pub fn lineno ( & self ) -> Option < u32 > {
664
659
match self {
665
660
Symbol :: Dladdr ( s) => return s. lineno ( ) ,
666
- Symbol :: Frame { frame, .. } => {
667
- let location = frame. location . as_ref ( ) ?;
668
- location. line . and_then ( |l| u32:: try_from ( l) . ok ( ) )
669
- }
661
+ Symbol :: Frame { location, .. } => location. as_ref ( ) ?. line ,
670
662
Symbol :: Symtab { .. } => None ,
671
663
}
672
664
}
0 commit comments