@@ -11,7 +11,6 @@ use crate::symbolize::ResolveWhat;
1111use crate :: types:: BytesOrWideString ;
1212use crate :: SymbolName ;
1313use addr2line:: gimli;
14- use core:: convert:: TryFrom ;
1514use core:: mem;
1615use core:: u32;
1716use findshlibs:: { self , Segment , SharedLibrary } ;
@@ -83,9 +82,10 @@ fn mmap(path: &Path) -> Option<Mmap> {
8382
8483cfg_if:: cfg_if! {
8584 if #[ cfg( windows) ] {
86- use std:: cmp;
8785 use goblin:: pe:: { self , PE } ;
8886 use goblin:: strtab:: Strtab ;
87+ use std:: cmp;
88+ use std:: convert:: TryFrom ;
8989
9090 struct Object <' a> {
9191 pe: PE <' a>,
@@ -542,14 +542,11 @@ pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) {
542542 None => return ,
543543 } ;
544544 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 ( ) {
549546 cb. call ( Symbol :: Frame {
550547 addr : addr. 0 as * mut c_void ,
551- frame,
552- name,
548+ location : frame. location ,
549+ name : frame . function . map ( |f| f . name . slice ( ) ) ,
553550 } ) ;
554551 }
555552 }
@@ -605,7 +602,7 @@ pub enum Symbol<'a> {
605602 /// `addr2line`'s frame internally has all the nitty gritty details.
606603 Frame {
607604 addr : * mut c_void ,
608- frame : addr2line:: Frame < EndianSlice < ' a , Endian > > ,
605+ location : Option < addr2line:: Location < ' a > > ,
609606 name : Option < & ' a [ u8 ] > ,
610607 } ,
611608 /// Couldn't find debug information, but we found it in the symbol table of
@@ -639,9 +636,8 @@ impl Symbol<'_> {
639636 pub fn filename_raw ( & self ) -> Option < BytesOrWideString > {
640637 match self {
641638 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 ?;
645641 Some ( BytesOrWideString :: Bytes ( file. as_bytes ( ) ) )
646642 }
647643 Symbol :: Symtab { .. } => None ,
@@ -651,9 +647,8 @@ impl Symbol<'_> {
651647 pub fn filename ( & self ) -> Option < & Path > {
652648 match self {
653649 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 ?;
657652 Some ( Path :: new ( file) )
658653 }
659654 Symbol :: Symtab { .. } => None ,
@@ -663,10 +658,7 @@ impl Symbol<'_> {
663658 pub fn lineno ( & self ) -> Option < u32 > {
664659 match self {
665660 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 ,
670662 Symbol :: Symtab { .. } => None ,
671663 }
672664 }
0 commit comments