@@ -89,6 +89,7 @@ def symbolize_address_symbolizer(module, address, is_dwarf):
89
89
# '/abc/def.c:3:5'. If the function or source info is not available, it will
90
90
# be printed as '??', in which case we store None. If the line and column info
91
91
# is not available, they will be printed as 0, which we store as is.
92
+ infos = []
92
93
for i in range (0 , len (out_lines ), 2 ):
93
94
func , loc_str = out_lines [i ], out_lines [i + 1 ]
94
95
m = SOURCE_LOC_RE .match (loc_str )
@@ -97,7 +98,8 @@ def symbolize_address_symbolizer(module, address, is_dwarf):
97
98
func = None
98
99
if source == '??' :
99
100
source = None
100
- LocationInfo (source , line , column , func ).print ()
101
+ infos .append (LocationInfo (source , line , column , func ))
102
+ return infos
101
103
102
104
103
105
def get_sourceMappingURL_section (module ):
@@ -221,7 +223,7 @@ def symbolize_address_sourcemap(module, address, force_file):
221
223
# Print with section offsets to easily compare against dwarf
222
224
for k , v in sm .mappings .items ():
223
225
print (f'{ k - csoff :x} : { v } ' )
224
- sm .lookup (address ). print ( )
226
+ return sm .lookup (address )
225
227
226
228
227
229
def symbolize_address_symbolmap (module , address , symbol_map_file ):
@@ -246,7 +248,7 @@ def symbolize_address_symbolmap(module, address, symbol_map_file):
246
248
print ("Address is before the first function" )
247
249
return
248
250
249
- LocationInfo (func = func_names [func_index ]). print ( )
251
+ return LocationInfo (func = func_names [func_index ])
250
252
251
253
252
254
def main (args ):
@@ -257,20 +259,27 @@ def main(args):
257
259
if args .addrtype == 'code' :
258
260
address += get_codesec_offset (module )
259
261
262
+ def print_loc (loc ):
263
+ if isinstance (loc , list ):
264
+ for l in loc :
265
+ l .print ()
266
+ else :
267
+ loc .print ()
268
+
260
269
if ((has_debug_line_section (module ) and not args .source ) or
261
270
'dwarf' in args .source ):
262
- symbolize_address_symbolizer (module , address , is_dwarf = True )
271
+ print_loc ( symbolize_address_symbolizer (module , address , is_dwarf = True ) )
263
272
elif ((get_sourceMappingURL_section (module ) and not args .source ) or
264
273
'sourcemap' in args .source ):
265
- symbolize_address_sourcemap (module , address , args .file )
274
+ print_loc ( symbolize_address_sourcemap (module , address , args .file ) )
266
275
elif ((has_name_section (module ) and not args .source ) or
267
276
'names' in args .source ):
268
- symbolize_address_symbolizer (module , address , is_dwarf = False )
277
+ print_loc ( symbolize_address_symbolizer (module , address , is_dwarf = False ) )
269
278
elif ((has_linking_section (module ) and not args .source ) or
270
279
'symtab' in args .source ):
271
- symbolize_address_symbolizer (module , address , is_dwarf = False )
280
+ print_loc ( symbolize_address_symbolizer (module , address , is_dwarf = False ) )
272
281
elif (args .source == 'symbolmap' ):
273
- symbolize_address_symbolmap (module , address , args .file )
282
+ print_loc ( symbolize_address_symbolmap (module , address , args .file ) )
274
283
else :
275
284
raise Error ('No .debug_line or sourceMappingURL section found in '
276
285
f'{ module .filename } .'
0 commit comments