@@ -6,11 +6,11 @@ use clap::parser::ValuesRef;
6
6
use clap:: { value_parser, Arg , ArgAction , Command } ;
7
7
use wholesym:: LookupAddress ;
8
8
9
- fn parse_uint_from_hex_string ( string : & str ) -> u32 {
9
+ fn parse_uint_from_hex_string ( string : & str ) -> u64 {
10
10
if string. len ( ) > 2 && string. starts_with ( "0x" ) {
11
- u32 :: from_str_radix ( & string[ 2 ..] , 16 ) . expect ( "Failed to parse address" )
11
+ u64 :: from_str_radix ( & string[ 2 ..] , 16 ) . expect ( "Failed to parse address" )
12
12
} else {
13
- u32 :: from_str_radix ( string, 16 ) . expect ( "Failed to parse address" )
13
+ u64 :: from_str_radix ( string, 16 ) . expect ( "Failed to parse address" )
14
14
}
15
15
}
16
16
@@ -20,9 +20,9 @@ enum Addrs<'a> {
20
20
}
21
21
22
22
impl < ' a > Iterator for Addrs < ' a > {
23
- type Item = u32 ;
23
+ type Item = u64 ;
24
24
25
- fn next ( & mut self ) -> Option < u32 > {
25
+ fn next ( & mut self ) -> Option < u64 > {
26
26
let text = match * self {
27
27
Addrs :: Args ( ref mut vals) => vals. next ( ) . map ( Cow :: from) ,
28
28
Addrs :: Stdin ( ref mut lines) => lines. next ( ) . map ( Result :: unwrap) . map ( Cow :: from) ,
@@ -64,9 +64,9 @@ fn print_loc(
64
64
65
65
#[ tokio:: main]
66
66
async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
67
- let matches = Command :: new ( "pdb -addr2line" )
67
+ let matches = Command :: new ( "wholesym -addr2line" )
68
68
. version ( "0.1" )
69
- . about ( "A fast addr2line port for PDBs " )
69
+ . about ( "A fast addr2line equivalent which supports lots of platforms. " )
70
70
. args ( & [
71
71
Arg :: new ( "exe" )
72
72
. short ( 'e' )
@@ -77,10 +77,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
77
77
"Specify the name of the executable for which addresses should be translated." ,
78
78
)
79
79
. required ( true ) ,
80
- Arg :: new ( "sup" )
81
- . long ( "sup" )
82
- . value_name ( "filename" )
83
- . help ( "Path to supplementary object file." ) ,
84
80
Arg :: new ( "functions" )
85
81
. action ( ArgAction :: SetTrue )
86
82
. short ( 'f' )
@@ -122,9 +118,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
122
118
. long ( "demangle" )
123
119
. help (
124
120
"Demangle function names. \
125
- Specifying a specific demangling style (like GNU addr2line) \
126
- is not supported. (TODO)",
121
+ We are currently demangling all function names even if this flag is not set.",
127
122
) ,
123
+ Arg :: new ( "relative" )
124
+ . action ( ArgAction :: SetTrue )
125
+ . long ( "relative" )
126
+ . conflicts_with ( "file-offsets" )
127
+ . help ( "Interpret the passed addresses as being relative to the image base address" ) ,
128
+ Arg :: new ( "file-offsets" )
129
+ . action ( ArgAction :: SetTrue )
130
+ . long ( "file-offsets" )
131
+ . conflicts_with ( "relative" )
132
+ . help ( "Interpret the passed addresses as being raw file offsets" ) ,
128
133
Arg :: new ( "llvm" )
129
134
. action ( ArgAction :: SetTrue )
130
135
. long ( "llvm" )
@@ -141,6 +146,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
141
146
let print_addrs = matches. get_flag ( "addresses" ) ;
142
147
let basenames = matches. get_flag ( "basenames" ) ;
143
148
let _demangle = matches. get_flag ( "demangle" ) ;
149
+ let relative = matches. get_flag ( "relative" ) ;
150
+ let file_offsets = matches. get_flag ( "file-offsets" ) ;
144
151
let llvm = matches. get_flag ( "llvm" ) ;
145
152
let path = matches. get_one :: < PathBuf > ( "exe" ) . unwrap ( ) ;
146
153
@@ -174,7 +181,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
174
181
}
175
182
176
183
let mut printed_anything = false ;
177
- if let Some ( address_info) = symbol_map. lookup ( LookupAddress :: Relative ( probe) ) . await {
184
+ let address = if relative {
185
+ LookupAddress :: Relative ( probe as u32 )
186
+ } else if file_offsets {
187
+ LookupAddress :: FileOffset ( probe)
188
+ } else {
189
+ LookupAddress :: Svma ( probe)
190
+ } ;
191
+ if let Some ( address_info) = symbol_map. lookup ( address) . await {
178
192
if let Some ( frames) = address_info. frames {
179
193
if do_functions || do_inlines {
180
194
for ( i, frame) in frames. iter ( ) . enumerate ( ) {
0 commit comments