blob: 8b315d4e771a2832d6f4950861fd20b649b1f0ab [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):
Johnny Chene7e4ac42011-10-06 22:48:56 +0000281 for sect in module.section_iter():
282 print_module_section (sect, depth)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000283
284def print_module_symbols (module):
Johnny Chene7e4ac42011-10-06 22:48:56 +0000285 for sym in module:
286 print sym
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000287
288def usage():
289 print "Usage: lldb-symbolicate.py [-n name] executable-image"
290 sys.exit(0)
291
292
293if __name__ == '__main__':
294 parser = optparse.OptionParser(description='A script that parses skinny and universal mach-o files.')
295 parser.add_option('--arch', type='string', metavar='arch', dest='triple', help='specify one architecture or target triple')
296 parser.add_option('--platform', type='string', metavar='platform', dest='platform', help='specify one platform by name')
297 parser.add_option('--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
298 parser.add_option('--interactive', action='store_true', dest='interactive', help='enable interactive mode', default=False)
299 parser.add_option('--no-images', action='store_false', dest='show_images', help='don\'t show images in stack frames', default=True)
300 parser.add_option('--no-dependents', action='store_false', dest='dependents', help='skip loading dependent modules', default=True)
301 parser.add_option('--sections', action='store_true', dest='dump_sections', help='show module sections', default=False)
302 parser.add_option('--symbols', action='store_true', dest='dump_symbols', help='show module symbols', default=False)
303 parser.add_option('--image-list', action='store_true', dest='dump_image_list', help='show image list', default=False)
304 parser.add_option('--debug-delay', type='int', dest='debug_delay', metavar='NSEC', help='pause for NSEC seconds for debugger', default=0)
305 parser.add_option('--section-depth', type='int', dest='section_depth', help='set the section depth to use when showing sections', default=0)
306 parser.add_option('--section-data', type='string', action='append', dest='sect_data_names', help='specify sections by name to display data for')
307 parser.add_option('--address', type='int', action='append', dest='addresses', help='specify addresses to lookup')
308 parser.add_option('--crash-log', type='string', action='append', dest='crash_log_files', help='specify crash log files to symbolicate')
309 parser.add_option('--crashed-only', action='store_true', dest='crashed_only', help='only show the crashed thread', default=False)
310 loaded_addresses = False
311 (options, args) = parser.parse_args()
312 if options.verbose:
313 print 'options', options
314
315 if options.debug_delay > 0:
316 print "Waiting %u seconds for debugger to attach..." % options.debug_delay
317 time.sleep(options.debug_delay)
318
319 # Create a new debugger instance
320 debugger = lldb.SBDebugger.Create()
321
322 # When we step or continue, don't return from the function until the process
323 # stops. We do this by setting the async mode to false.
324 debugger.SetAsync (False)
325 error = lldb.SBError()
326
327 if options.crash_log_files:
328 options.dependents = False
329 for crash_log_file in options.crash_log_files:
330 triple = "x86_64"
331 crash_log = CrashLog(crash_log_file)
332 #crash_log.dump()
333 target = debugger.CreateTarget (crash_log.process_path, options.triple, options.platform, options.dependents, error);
334 exe_module = target.GetModuleAtIndex(0)
Greg Claytona6e42922011-09-26 19:17:49 +0000335 image_paths = list()
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000336 for image in crash_log.images:
337 if image.path == crash_log.process_path:
338 module = exe_module
339 else:
340 module = target.AddModule (image.path, options.triple, image.uuid)
Greg Claytona6e42922011-09-26 19:17:49 +0000341 if image.path in image_paths:
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000342 print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo)
343 else:
Greg Claytona6e42922011-09-26 19:17:49 +0000344 image_paths.append(image.path)
345
346 if not module and image.uuid != module.GetUUIDString():
347 if image.uuid:
348 print "warning: couldn't locate %s %s" % (image.uuid, image.path)
349 else:
350 print "warning: couldn't locate %s" % (image.path)
351 else:
352 target.SetSectionLoadAddress (module.FindSection ("__TEXT"), image.text_addr_lo)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000353 for line in crash_log.info_lines:
354 print line
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000355 # Reconstruct inlined frames for all threads for anything that has debug info
356 for thread in crash_log.threads:
357 if options.crashed_only and thread.did_crash() == False:
358 continue
359 # start a new frame list that we will fixup for each thread
360 new_thread_frames = list()
361 # Iterate through all concrete frames for a thread and resolve
362 # any parent frames of inlined functions
363 for frame_idx, frame in enumerate(thread.frames):
364 # Resolve the frame's pc into a section + offset address 'pc_addr'
365 pc_addr = target.ResolveLoadAddress (frame.pc)
366 # Check to see if we were able to resolve the address
367 if pc_addr:
368 # We were able to resolve the frame's PC into a section offset
369 # address.
370
371 # Resolve the frame's PC value into a symbol context. A symbol
372 # context can resolve a module, compile unit, function, block,
373 # line table entry and/or symbol. If the frame has a block, then
374 # we can look for inlined frames, which are represented by blocks
375 # that have inlined information in them
376 frame.sym_ctx = target.ResolveSymbolContextForAddress (pc_addr, lldb.eSymbolContextEverything);
377
378 # dump if the verbose option was specified
379 if options.verbose:
380 print "frame.pc = %#16.16x (file_addr = %#16.16x)" % (frame.pc, pc_addr.GetFileAddress())
381 print "frame.pc_addr = ", pc_addr
382 print "frame.sym_ctx = "
383 print frame.sym_ctx
384 print
385
386 # Append the frame we already had from the crash log to the new
387 # frames list
388 new_thread_frames.append(frame)
389
390 new_frame = CrashLog.Frame (frame.index, -1, None)
391
392 # Try and use the current frame's symbol context to calculate a
393 # parent frame for an inlined function. If the curent frame is
394 # inlined, it will return a valid symbol context for the parent
395 # frame of the current inlined function
396 parent_pc_addr = lldb.SBAddress()
Greg Clayton1ed54f52011-10-01 00:45:15 +0000397 new_frame.sym_ctx = frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000398
399 # See if we were able to reconstruct anything?
400 while new_frame.sym_ctx:
401 # We have a parent frame of an inlined frame, create a new frame
402 # Convert the section + offset 'parent_pc_addr' to a load address
403 new_frame.pc = parent_pc_addr.GetLoadAddress(target)
404 # push the new frame onto the new frame stack
405 new_thread_frames.append (new_frame)
406 # dump if the verbose option was specified
407 if options.verbose:
408 print "new_frame.pc = %#16.16x (%s)" % (new_frame.pc, parent_pc_addr)
409 print "new_frame.sym_ctx = "
410 print new_frame.sym_ctx
411 print
412 # Create another new frame in case we have multiple inlined frames
413 prev_new_frame = new_frame
414 new_frame = CrashLog.Frame (frame.index, -1, None)
415 # Swap the addresses so we can try another inlined lookup
416 pc_addr = parent_pc_addr;
Greg Clayton1ed54f52011-10-01 00:45:15 +0000417 new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000418 # Replace our thread frames with our new list that includes parent
419 # frames for inlined functions
420 thread.frames = new_thread_frames
421 # Now iterate through all threads and display our richer stack backtraces
422 for thread in crash_log.threads:
423 this_thread_crashed = thread.did_crash()
424 if options.crashed_only and this_thread_crashed == False:
425 continue
426 print "%s" % thread
427 prev_frame_index = -1
428 for frame_idx, frame in enumerate(thread.frames):
Greg Claytona6e42922011-09-26 19:17:49 +0000429 details = ' %s' % frame.details
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000430 module = frame.sym_ctx.GetModule()
431 instructions = None
432 if module:
433 module_basename = module.GetFileSpec().GetFilename();
434 function_start_load_addr = -1
435 function_name = None
436 function = frame.sym_ctx.GetFunction()
437 block = frame.sym_ctx.GetBlock()
438 line_entry = frame.sym_ctx.GetLineEntry()
439 symbol = frame.sym_ctx.GetSymbol()
440 inlined_block = block.GetContainingInlinedBlock();
441 if inlined_block:
442 function_name = inlined_block.GetInlinedName();
443 block_range_idx = inlined_block.GetRangeIndexForBlockAddress (target.ResolveLoadAddress (frame.pc))
444 if block_range_idx < lldb.UINT32_MAX:
445 block_range_start_addr = inlined_block.GetRangeStartAddress (block_range_idx)
446 function_start_load_addr = block_range_start_addr.GetLoadAddress (target)
447 else:
448 function_start_load_addr = frame.pc
449 if this_thread_crashed and frame_idx == 0:
450 instructions = function.GetInstructions(target)
451 elif function:
452 function_name = function.GetName()
453 function_start_load_addr = function.GetStartAddress().GetLoadAddress (target)
454 if this_thread_crashed and frame_idx == 0:
455 instructions = function.GetInstructions(target)
456 elif symbol:
457 function_name = symbol.GetName()
458 function_start_load_addr = symbol.GetStartAddress().GetLoadAddress (target)
459 if this_thread_crashed and frame_idx == 0:
460 instructions = symbol.GetInstructions(target)
461
462 if function_name:
463 # Print the function or symbol name and annotate if it was inlined
464 inline_suffix = ''
465 if inlined_block:
466 inline_suffix = '[inlined] '
467 else:
468 inline_suffix = ' '
469 if options.show_images:
470 details = "%s%s`%s" % (inline_suffix, module_basename, function_name)
471 else:
472 details = "%s" % (function_name)
473 # Dump the offset from the current function or symbol if it is non zero
474 function_offset = frame.pc - function_start_load_addr
475 if function_offset > 0:
476 details += " + %u" % (function_offset)
477 elif function_offset < 0:
478 defaults += " %i (invalid negative offset, file a bug) " % function_offset
479 # Print out any line information if any is available
480 if line_entry.GetFileSpec():
481 details += ' at %s' % line_entry.GetFileSpec().GetFilename()
482 details += ':%u' % line_entry.GetLine ()
483 column = line_entry.GetColumn()
484 if column > 0:
485 details += ':%u' % column
Greg Clayton2f9ca7b2011-09-26 18:39:23 +0000486
487
488 # Only print out the concrete frame index if it changes.
489 # if prev_frame_index != frame.index:
490 # print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
491 # else:
492 # print " %#16.16x %s" % (frame.pc, details)
493 print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
494 prev_frame_index = frame.index
495 if instructions:
496 print
497 disassemble_instructions (target, instructions, frame.pc, 4, 4)
498 print
499
500 print
501
502 if options.dump_image_list:
503 print "Binary Images:"
504 for image in crash_log.images:
505 print image
506 else:
507 for exe_file in args:
508
509 # Create a target from a file and arch
510 print "Creating a target for '%s'" % exe_file
511
512 target = debugger.CreateTarget (exe_file, options.triple, options.platform, options.dependents, error);
513
514 if target:
515 exe_module = None;
516 module_count = target.GetNumModules();
517 for module_idx in range(module_count):
518 module = target.GetModuleAtIndex (module_idx)
519 if module_idx == 0:
520 exe_module = module
521 print "module[%u] = %s" % (module_idx, module)
522
523 if options.dump_symbols:
524 print_module_symbols (module)
525 if options.dump_sections:
526 print_module_sections (module, options.section_depth)
527 if options.sect_data_names:
528 for sect_name in options.sect_data_names:
529 section = module.FindSection (sect_name)
530 if section:
531 print_module_section_data (section)
532 else:
533 print "No section was found in '%s' named '%s'" % (module, sect_name)
534 if options.addresses:
535 for address in options.addresses:
536 if loaded_addresses:
537 so_address = target.ResolveLoadAddress (address)
538 if so_address:
539 print so_address
540 so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything);
541 print so_address_sc
542 else:
543 print "error: 0x%8.8x failed to resolve as a load address" % (address)
544 else:
545 so_address = exe_module.ResolveFileAddress (address)
546
547 if so_address:
548 print so_address
549 so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything);
550 print so_address_sc
551 else:
552 print "error: 0x%8.8x failed to resolve as a file address in %s" % (address, exe_module)
553
554 # text_base_addr = 0x10000
555 # load_addr = 0x10bb0
556 # text_segment = exe_module.FindSection ("__TEXT")
557 # if text_segment:
558 # target.SetSectionLoadAddress (text_segment, text_base_addr)
559 #
560 # load_so_addr = target.ResolveLoadAddress (load_addr)
561 #
562 # if load_so_addr:
563 # sc = target.ResolveSymbolContextForAddress (so_addr, lldb.eSymbolContextEverything);
564 # print sc
565 # else:
566 # print "error: 0x%8.8x failed to resolve as a load address" % (load_addr)
567 else:
568 print "error: ", error
569
570
571 lldb.SBDebugger.Terminate()
572