blob: c7972abec9d140f1bc6030e1574a0d91d83c8fbf [file] [log] [blame]
Greg Clayton2f9ca7b2011-09-26 18:39:23 +00001#!/usr/bin/python
2
3#----------------------------------------------------------------------
4# Be sure to add the python path that points to the LLDB shared library.
5# On MacOSX csh, tcsh:
6# setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python
7# On MacOSX sh, bash:
8# export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python
9#----------------------------------------------------------------------
10
11import lldb
12import optparse
13import os
14import re
15import sys
16import time
17
18PARSE_MODE_NORMAL = 0
19PARSE_MODE_THREAD = 1
20PARSE_MODE_IMAGES = 2
21PARSE_MODE_THREGS = 3
22PARSE_MODE_SYSTEM = 4
23
24class CrashLog:
25 """Class that does parses darwin crash logs"""
26 thread_state_regex = re.compile('^Thread ([0-9]+) crashed with')
27 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
Greg Claytona6e42922011-09-26 19:17:49 +000028 frame_regex = re.compile('^([0-9]+).*\t(0x[0-9a-fA-F]+) +(.*)')
29 image_regex_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)');
30 image_regex_no_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([^/]+)/(.*)');
Greg Clayton2f9ca7b2011-09-26 18:39:23 +000031 empty_line_regex = re.compile('^$')
32
33 class Thread:
34 """Class that represents a thread in a darwin crash log"""
35 def __init__(self, index):
36 self.index = index
37 self.frames = list()
38 self.registers = dict()
39 self.reason = None
40 self.queue = None
41
42 def dump(self, prefix):
43 print "%sThread[%u] %s" % (prefix, self.index, self.reason)
44 if self.frames:
45 print "%s Frames:" % (prefix)
46 for frame in self.frames:
47 frame.dump(prefix + ' ')
48 if self.registers:
49 print "%s Registers:" % (prefix)
50 for reg in self.registers.keys():
51 print "%s %-5s = %#16.16x" % (prefix, reg, self.registers[reg])
52
53 def did_crash(self):
54 return self.reason != None
55
56 def __str__(self):
57 s = "Thread[%u]" % self.index
58 if self.reason:
59 s += ' %s' % self.reason
60 return s
61
62 class Frame:
63 """Class that represents a stack frame in a thread in a darwin crash log"""
64 def __init__(self, index, pc, details):
65 self.index = index
66 self.pc = pc
67 self.sym_ctx = None
68 self.details = details
69
70 def __str__(self):
71 return "[%2u] %#16.16x %s" % (self.index, self.pc, self.details)
72
73 def dump(self, prefix):
74 print "%s%s" % (prefix, self)
75
76 class Image:
77 """Class that represents a binary images in a darwin crash log"""
Greg Claytona6e42922011-09-26 19:17:49 +000078 def __init__(self, text_addr_lo, text_addr_hi, ident, version, uuid, path):
Greg Clayton2f9ca7b2011-09-26 18:39:23 +000079 self.text_addr_lo = text_addr_lo
80 self.text_addr_hi = text_addr_hi
81 self.ident = ident
82 self.version = version
Greg Clayton2f9ca7b2011-09-26 18:39:23 +000083 self.uuid = uuid
84 self.path = path
85
86 def dump(self, prefix):
87 print "%s%s" % (prefix, self)
88
89 def __str__(self):
90 return "%#16.16x %s %s" % (self.text_addr_lo, self.uuid, self.path)
91
92
93 def __init__(self, path):
94 """CrashLog constructor that take a path to a darwin crash log file"""
95 self.path = path;
96 self.info_lines = list()
97 self.system_profile = list()
98 self.threads = list()
99 self.images = list()
100 self.crashed_thread_idx = -1
101 self.version = -1
102 f = open(self.path)
103 self.file_lines = f.read().splitlines()
104 parse_mode = PARSE_MODE_NORMAL
105 thread = None
106 for line in self.file_lines:
107 # print line
108 line_len = len(line)
109 if line_len == 0:
110 if thread:
111 if parse_mode == PARSE_MODE_THREAD:
112 if thread.index == self.crashed_thread_idx:
113 thread.reason = ''
114 if self.thread_exception:
115 thread.reason += self.thread_exception
116 if self.thread_exception_data:
117 thread.reason += " (%s)" % self.thread_exception_data
118 self.threads.append(thread)
119 thread = None
120 else:
121 # only append an extra empty line if the previous line
122 # in the info_lines wasn't empty
123 if len(self.info_lines) > 0 and len(self.info_lines[-1]):
124 self.info_lines.append(line)
125 parse_mode = PARSE_MODE_NORMAL
126 # print 'PARSE_MODE_NORMAL'
127 elif parse_mode == PARSE_MODE_NORMAL:
128 if line.startswith ('Process:'):
129 (self.process_name, pid_with_brackets) = line[8:].strip().split()
130 self.process_id = pid_with_brackets.strip('[]')
131 elif line.startswith ('Path:'):
132 self.process_path = line[5:].strip()
133 elif line.startswith ('Identifier:'):
134 self.process_identifier = line[11:].strip()
135 elif line.startswith ('Version:'):
136 (self.process_version, compatability_version) = line[8:].strip().split()
137 self.process_compatability_version = compatability_version.strip('()')
138 elif line.startswith ('Parent Process:'):
139 (self.parent_process_name, pid_with_brackets) = line[15:].strip().split()
140 self.parent_process_id = pid_with_brackets.strip('[]')
141 elif line.startswith ('Exception Type:'):
142 self.thread_exception = line[15:].strip()
143 continue
144 elif line.startswith ('Exception Codes:'):
145 self.thread_exception_data = line[16:].strip()
146 continue
147 elif line.startswith ('Crashed Thread:'):
148 self.crashed_thread_idx = int(line[15:].strip().split()[0])
149 continue
150 elif line.startswith ('Report Version:'):
151 self.version = int(line[15:].strip())
152 continue
153 elif line.startswith ('System Profile:'):
154 parse_mode = PARSE_MODE_SYSTEM
155 continue
156 elif (line.startswith ('Interval Since Last Report:') or
157 line.startswith ('Crashes Since Last Report:') or
158 line.startswith ('Per-App Interval Since Last Report:') or
159 line.startswith ('Per-App Crashes Since Last Report:') or
160 line.startswith ('Sleep/Wake UUID:') or
161 line.startswith ('Anonymous UUID:')):
162 # ignore these
163 continue
164 elif line.startswith ('Thread'):
165 thread_state_match = self.thread_state_regex.search (line)
166 if thread_state_match:
167 thread_state_match = self.thread_regex.search (line)
168 thread_idx = int(thread_state_match.group(1))
169 parse_mode = PARSE_MODE_THREGS
170 thread = self.threads[thread_idx]
171 else:
172 thread_match = self.thread_regex.search (line)
173 if thread_match:
174 # print 'PARSE_MODE_THREAD'
175 parse_mode = PARSE_MODE_THREAD
176 thread_idx = int(thread_match.group(1))
177 thread = CrashLog.Thread(thread_idx)
178 continue
179 elif line.startswith ('Binary Images:'):
180 parse_mode = PARSE_MODE_IMAGES
181 continue
182 self.info_lines.append(line.strip())
183 elif parse_mode == PARSE_MODE_THREAD:
184 frame_match = self.frame_regex.search(line)
185 if frame_match:
186 thread.frames.append (CrashLog.Frame(int(frame_match.group(1)), int(frame_match.group(2), 0), frame_match.group(3)))
187 else:
188 print "error: frame regex failed"
189 elif parse_mode == PARSE_MODE_IMAGES:
Greg Claytona6e42922011-09-26 19:17:49 +0000190 image_match = self.image_regex_uuid.search (line)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000191 if image_match:
192 image = CrashLog.Image (int(image_match.group(1),0),
193 int(image_match.group(2),0),
Greg Claytona6e42922011-09-26 19:17:49 +0000194 image_match.group(3).strip(),
195 image_match.group(4).strip(),
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000196 image_match.group(5),
Greg Claytona6e42922011-09-26 19:17:49 +0000197 image_match.group(6))
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000198 self.images.append (image)
199 else:
Greg Claytona6e42922011-09-26 19:17:49 +0000200 image_match = self.image_regex_no_uuid.search (line)
201 if image_match:
202 image = CrashLog.Image (int(image_match.group(1),0),
203 int(image_match.group(2),0),
204 image_match.group(3).strip(),
205 image_match.group(4).strip(),
206 None,
207 image_match.group(5))
208 self.images.append (image)
209 else:
210 print "error: image regex failed for: %s" % line
211
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000212 elif parse_mode == PARSE_MODE_THREGS:
213 stripped_line = line.strip()
214 reg_values = stripped_line.split(' ')
215 for reg_value in reg_values:
216 (reg, value) = reg_value.split(': ')
217 thread.registers[reg.strip()] = int(value, 0)
218 elif parse_mode == PARSE_MODE_SYSTEM:
219 self.system_profile.append(line)
220 f.close()
221
222 def dump(self):
223 print "Crash Log File: %s" % (self.path)
224 print "\nThreads:"
225 for thread in self.threads:
226 thread.dump(' ')
227 print "\nImages:"
228 for image in self.images:
229 image.dump(' ')
230
231def disassemble_instructions (target, instructions, pc, insts_before_pc, insts_after_pc):
232 lines = list()
233 pc_index = -1
234 comment_column = 50
235 for inst_idx, inst in enumerate(instructions):
236 inst_pc = inst.GetAddress().GetLoadAddress(target);
237 if pc == inst_pc:
238 pc_index = inst_idx
Greg Claytonfb0655e2011-09-27 00:58:45 +0000239 mnemonic = inst.GetMnemonic (target)
240 operands = inst.GetOperands (target)
241 comment = inst.GetComment (target)
242 #data = inst.GetData (target)
243 lines.append ("%#16.16x: %8s %s" % (inst_pc, mnemonic, operands))
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000244 if comment:
245 line_len = len(lines[-1])
246 if line_len < comment_column:
247 lines[-1] += ' ' * (comment_column - line_len)
248 lines[-1] += "; %s" % comment
249
250 if pc_index >= 0:
251 if pc_index >= insts_before_pc:
252 start_idx = pc_index - insts_before_pc
253 else:
254 start_idx = 0
255 end_idx = pc_index + insts_after_pc
256 if end_idx > inst_idx:
257 end_idx = inst_idx
258 for i in range(start_idx, end_idx+1):
259 if i == pc_index:
260 print ' -> ', lines[i]
261 else:
262 print ' ', lines[i]
263
264def print_module_section_data (section):
265 print section
266 section_data = section.GetSectionData()
267 if section_data:
268 ostream = lldb.SBStream()
269 section_data.GetDescription (ostream, section.GetFileAddress())
270 print ostream.GetData()
271
272def print_module_section (section, depth):
273 print section
274
275 if depth > 0:
276 num_sub_sections = section.GetNumSubSections()
277 for sect_idx in range(num_sub_sections):
278 print_module_section (section.GetSubSectionAtIndex(sect_idx), depth - 1)
279
280def print_module_sections (module, depth):
281 num_sections = module.GetNumSections()
282
283 for sect_idx in range(num_sections):
284 section = module.GetSectionAtIndex(sect_idx)
285 print_module_section (section, depth)
286
287def print_module_symbols (module):
288 n = module.GetNumSymbols()
289
290 for i in range(n):
291 print module.GetSymbolAtIndex(i)
292
293def usage():
294 print "Usage: lldb-symbolicate.py [-n name] executable-image"
295 sys.exit(0)
296
297
298if __name__ == '__main__':
299 parser = optparse.OptionParser(description='A script that parses skinny and universal mach-o files.')
300 parser.add_option('--arch', type='string', metavar='arch', dest='triple', help='specify one architecture or target triple')
301 parser.add_option('--platform', type='string', metavar='platform', dest='platform', help='specify one platform by name')
302 parser.add_option('--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
303 parser.add_option('--interactive', action='store_true', dest='interactive', help='enable interactive mode', default=False)
304 parser.add_option('--no-images', action='store_false', dest='show_images', help='don\'t show images in stack frames', default=True)
305 parser.add_option('--no-dependents', action='store_false', dest='dependents', help='skip loading dependent modules', default=True)
306 parser.add_option('--sections', action='store_true', dest='dump_sections', help='show module sections', default=False)
307 parser.add_option('--symbols', action='store_true', dest='dump_symbols', help='show module symbols', default=False)
308 parser.add_option('--image-list', action='store_true', dest='dump_image_list', help='show image list', default=False)
309 parser.add_option('--debug-delay', type='int', dest='debug_delay', metavar='NSEC', help='pause for NSEC seconds for debugger', default=0)
310 parser.add_option('--section-depth', type='int', dest='section_depth', help='set the section depth to use when showing sections', default=0)
311 parser.add_option('--section-data', type='string', action='append', dest='sect_data_names', help='specify sections by name to display data for')
312 parser.add_option('--address', type='int', action='append', dest='addresses', help='specify addresses to lookup')
313 parser.add_option('--crash-log', type='string', action='append', dest='crash_log_files', help='specify crash log files to symbolicate')
314 parser.add_option('--crashed-only', action='store_true', dest='crashed_only', help='only show the crashed thread', default=False)
315 loaded_addresses = False
316 (options, args) = parser.parse_args()
317 if options.verbose:
318 print 'options', options
319
320 if options.debug_delay > 0:
321 print "Waiting %u seconds for debugger to attach..." % options.debug_delay
322 time.sleep(options.debug_delay)
323
324 # Create a new debugger instance
325 debugger = lldb.SBDebugger.Create()
326
327 # When we step or continue, don't return from the function until the process
328 # stops. We do this by setting the async mode to false.
329 debugger.SetAsync (False)
330 error = lldb.SBError()
331
332 if options.crash_log_files:
333 options.dependents = False
334 for crash_log_file in options.crash_log_files:
335 triple = "x86_64"
336 crash_log = CrashLog(crash_log_file)
337 #crash_log.dump()
338 target = debugger.CreateTarget (crash_log.process_path, options.triple, options.platform, options.dependents, error);
339 exe_module = target.GetModuleAtIndex(0)
Greg Claytona6e42922011-09-26 19:17:49 +0000340 image_paths = list()
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000341 for image in crash_log.images:
342 if image.path == crash_log.process_path:
343 module = exe_module
344 else:
345 module = target.AddModule (image.path, options.triple, image.uuid)
Greg Claytona6e42922011-09-26 19:17:49 +0000346 if image.path in image_paths:
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000347 print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo)
348 else:
Greg Claytona6e42922011-09-26 19:17:49 +0000349 image_paths.append(image.path)
350
351 if not module and image.uuid != module.GetUUIDString():
352 if image.uuid:
353 print "warning: couldn't locate %s %s" % (image.uuid, image.path)
354 else:
355 print "warning: couldn't locate %s" % (image.path)
356 else:
357 target.SetSectionLoadAddress (module.FindSection ("__TEXT"), image.text_addr_lo)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000358 for line in crash_log.info_lines:
359 print line
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000360 # Reconstruct inlined frames for all threads for anything that has debug info
361 for thread in crash_log.threads:
362 if options.crashed_only and thread.did_crash() == False:
363 continue
364 # start a new frame list that we will fixup for each thread
365 new_thread_frames = list()
366 # Iterate through all concrete frames for a thread and resolve
367 # any parent frames of inlined functions
368 for frame_idx, frame in enumerate(thread.frames):
369 # Resolve the frame's pc into a section + offset address 'pc_addr'
370 pc_addr = target.ResolveLoadAddress (frame.pc)
371 # Check to see if we were able to resolve the address
372 if pc_addr:
373 # We were able to resolve the frame's PC into a section offset
374 # address.
375
376 # Resolve the frame's PC value into a symbol context. A symbol
377 # context can resolve a module, compile unit, function, block,
378 # line table entry and/or symbol. If the frame has a block, then
379 # we can look for inlined frames, which are represented by blocks
380 # that have inlined information in them
381 frame.sym_ctx = target.ResolveSymbolContextForAddress (pc_addr, lldb.eSymbolContextEverything);
382
383 # dump if the verbose option was specified
384 if options.verbose:
385 print "frame.pc = %#16.16x (file_addr = %#16.16x)" % (frame.pc, pc_addr.GetFileAddress())
386 print "frame.pc_addr = ", pc_addr
387 print "frame.sym_ctx = "
388 print frame.sym_ctx
389 print
390
391 # Append the frame we already had from the crash log to the new
392 # frames list
393 new_thread_frames.append(frame)
394
395 new_frame = CrashLog.Frame (frame.index, -1, None)
396
397 # Try and use the current frame's symbol context to calculate a
398 # parent frame for an inlined function. If the curent frame is
399 # inlined, it will return a valid symbol context for the parent
400 # frame of the current inlined function
401 parent_pc_addr = lldb.SBAddress()
Greg Clayton1ed54f52011-10-01 00:45:15 +0000402 new_frame.sym_ctx = frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000403
404 # See if we were able to reconstruct anything?
405 while new_frame.sym_ctx:
406 # We have a parent frame of an inlined frame, create a new frame
407 # Convert the section + offset 'parent_pc_addr' to a load address
408 new_frame.pc = parent_pc_addr.GetLoadAddress(target)
409 # push the new frame onto the new frame stack
410 new_thread_frames.append (new_frame)
411 # dump if the verbose option was specified
412 if options.verbose:
413 print "new_frame.pc = %#16.16x (%s)" % (new_frame.pc, parent_pc_addr)
414 print "new_frame.sym_ctx = "
415 print new_frame.sym_ctx
416 print
417 # Create another new frame in case we have multiple inlined frames
418 prev_new_frame = new_frame
419 new_frame = CrashLog.Frame (frame.index, -1, None)
420 # Swap the addresses so we can try another inlined lookup
421 pc_addr = parent_pc_addr;
Greg Clayton1ed54f52011-10-01 00:45:15 +0000422 new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000423 # Replace our thread frames with our new list that includes parent
424 # frames for inlined functions
425 thread.frames = new_thread_frames
426 # Now iterate through all threads and display our richer stack backtraces
427 for thread in crash_log.threads:
428 this_thread_crashed = thread.did_crash()
429 if options.crashed_only and this_thread_crashed == False:
430 continue
431 print "%s" % thread
432 prev_frame_index = -1
433 for frame_idx, frame in enumerate(thread.frames):
Greg Claytona6e42922011-09-26 19:17:49 +0000434 details = ' %s' % frame.details
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000435 module = frame.sym_ctx.GetModule()
436 instructions = None
437 if module:
438 module_basename = module.GetFileSpec().GetFilename();
439 function_start_load_addr = -1
440 function_name = None
441 function = frame.sym_ctx.GetFunction()
442 block = frame.sym_ctx.GetBlock()
443 line_entry = frame.sym_ctx.GetLineEntry()
444 symbol = frame.sym_ctx.GetSymbol()
445 inlined_block = block.GetContainingInlinedBlock();
446 if inlined_block:
447 function_name = inlined_block.GetInlinedName();
448 block_range_idx = inlined_block.GetRangeIndexForBlockAddress (target.ResolveLoadAddress (frame.pc))
449 if block_range_idx < lldb.UINT32_MAX:
450 block_range_start_addr = inlined_block.GetRangeStartAddress (block_range_idx)
451 function_start_load_addr = block_range_start_addr.GetLoadAddress (target)
452 else:
453 function_start_load_addr = frame.pc
454 if this_thread_crashed and frame_idx == 0:
455 instructions = function.GetInstructions(target)
456 elif function:
457 function_name = function.GetName()
458 function_start_load_addr = function.GetStartAddress().GetLoadAddress (target)
459 if this_thread_crashed and frame_idx == 0:
460 instructions = function.GetInstructions(target)
461 elif symbol:
462 function_name = symbol.GetName()
463 function_start_load_addr = symbol.GetStartAddress().GetLoadAddress (target)
464 if this_thread_crashed and frame_idx == 0:
465 instructions = symbol.GetInstructions(target)
466
467 if function_name:
468 # Print the function or symbol name and annotate if it was inlined
469 inline_suffix = ''
470 if inlined_block:
471 inline_suffix = '[inlined] '
472 else:
473 inline_suffix = ' '
474 if options.show_images:
475 details = "%s%s`%s" % (inline_suffix, module_basename, function_name)
476 else:
477 details = "%s" % (function_name)
478 # Dump the offset from the current function or symbol if it is non zero
479 function_offset = frame.pc - function_start_load_addr
480 if function_offset > 0:
481 details += " + %u" % (function_offset)
482 elif function_offset < 0:
483 defaults += " %i (invalid negative offset, file a bug) " % function_offset
484 # Print out any line information if any is available
485 if line_entry.GetFileSpec():
486 details += ' at %s' % line_entry.GetFileSpec().GetFilename()
487 details += ':%u' % line_entry.GetLine ()
488 column = line_entry.GetColumn()
489 if column > 0:
490 details += ':%u' % column
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000491
492
493 # Only print out the concrete frame index if it changes.
494 # if prev_frame_index != frame.index:
495 # print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
496 # else:
497 # print " %#16.16x %s" % (frame.pc, details)
498 print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
499 prev_frame_index = frame.index
500 if instructions:
501 print
502 disassemble_instructions (target, instructions, frame.pc, 4, 4)
503 print
504
505 print
506
507 if options.dump_image_list:
508 print "Binary Images:"
509 for image in crash_log.images:
510 print image
511 else:
512 for exe_file in args:
513
514 # Create a target from a file and arch
515 print "Creating a target for '%s'" % exe_file
516
517 target = debugger.CreateTarget (exe_file, options.triple, options.platform, options.dependents, error);
518
519 if target:
520 exe_module = None;
521 module_count = target.GetNumModules();
522 for module_idx in range(module_count):
523 module = target.GetModuleAtIndex (module_idx)
524 if module_idx == 0:
525 exe_module = module
526 print "module[%u] = %s" % (module_idx, module)
527
528 if options.dump_symbols:
529 print_module_symbols (module)
530 if options.dump_sections:
531 print_module_sections (module, options.section_depth)
532 if options.sect_data_names:
533 for sect_name in options.sect_data_names:
534 section = module.FindSection (sect_name)
535 if section:
536 print_module_section_data (section)
537 else:
538 print "No section was found in '%s' named '%s'" % (module, sect_name)
539 if options.addresses:
540 for address in options.addresses:
541 if loaded_addresses:
542 so_address = target.ResolveLoadAddress (address)
543 if so_address:
544 print so_address
545 so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything);
546 print so_address_sc
547 else:
548 print "error: 0x%8.8x failed to resolve as a load address" % (address)
549 else:
550 so_address = exe_module.ResolveFileAddress (address)
551
552 if so_address:
553 print so_address
554 so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything);
555 print so_address_sc
556 else:
557 print "error: 0x%8.8x failed to resolve as a file address in %s" % (address, exe_module)
558
559 # text_base_addr = 0x10000
560 # load_addr = 0x10bb0
561 # text_segment = exe_module.FindSection ("__TEXT")
562 # if text_segment:
563 # target.SetSectionLoadAddress (text_segment, text_base_addr)
564 #
565 # load_so_addr = target.ResolveLoadAddress (load_addr)
566 #
567 # if load_so_addr:
568 # sc = target.ResolveSymbolContextForAddress (so_addr, lldb.eSymbolContextEverything);
569 # print sc
570 # else:
571 # print "error: 0x%8.8x failed to resolve as a load address" % (load_addr)
572 else:
573 print "error: ", error
574
575
576 lldb.SBDebugger.Terminate()
577