@@ -3,7 +3,7 @@ use std::error::Error;
3
3
use addr2line:: {
4
4
gimli:: { EndianRcSlice , RunTimeEndian } ,
5
5
object:: { read:: File , Object } ,
6
- Context ,
6
+ Context , LookupResult ,
7
7
} ;
8
8
9
9
// Wrapper around addr2line that allows to look up function names and
@@ -20,6 +20,7 @@ impl<'sym> Symbols<'sym> {
20
20
21
21
Ok ( Self { file, ctx } )
22
22
}
23
+
23
24
/// Returns the name of the function at the given address, if one can be found.
24
25
pub fn get_name ( & self , addr : u64 ) -> Option < String > {
25
26
// The basic steps here are:
@@ -28,15 +29,19 @@ impl<'sym> Symbols<'sym> {
28
29
// 3. if no function name is found, try to look it up in the object file
29
30
// directly
30
31
// 4. return a demangled function name, if one was found
31
- self . ctx
32
- . find_frames ( addr)
32
+ let mut frames = match self . ctx . find_frames ( addr) {
33
+ LookupResult :: Output ( result) => result. unwrap ( ) ,
34
+ LookupResult :: Load { .. } => unimplemented ! ( ) ,
35
+ } ;
36
+
37
+ frames
38
+ . next ( )
33
39
. ok ( )
34
- . and_then ( |mut frames| {
35
- frames. next ( ) . ok ( ) . flatten ( ) . and_then ( |frame| {
36
- frame
37
- . function
38
- . and_then ( |name| name. demangle ( ) . map ( |s| s. into_owned ( ) ) . ok ( ) )
39
- } )
40
+ . flatten ( )
41
+ . and_then ( |frame| {
42
+ frame
43
+ . function
44
+ . and_then ( |name| name. demangle ( ) . map ( |s| s. into_owned ( ) ) . ok ( ) )
40
45
} )
41
46
. or_else ( || {
42
47
self . file
0 commit comments