blob: 9498dfbebdf4b22de958d76b8f8cbb5598f80753 [file] [log] [blame]
Greg Clayton01f7c962012-01-20 03:15:45 +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 commands # commands.getoutput ('/bin/ls /tmp')
13import optparse
14import os
15import plistlib
16import pprint
17import re
18import sys
19import time
20
21PARSE_MODE_NORMAL = 0
22PARSE_MODE_THREAD = 1
23PARSE_MODE_IMAGES = 2
24PARSE_MODE_THREGS = 3
25PARSE_MODE_SYSTEM = 4
26
27class CrashLog:
28 """Class that does parses darwin crash logs"""
29 thread_state_regex = re.compile('^Thread ([0-9]+) crashed with')
30 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
Greg Clayton8077a532012-01-20 03:32:35 +000031 frame_regex = re.compile('^([0-9]+) +([^ ]+) *\t(0x[0-9a-fA-F]+) +(.*)')
32 image_regex_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)');
33 image_regex_no_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^/]+)/(.*)');
Greg Clayton01f7c962012-01-20 03:15:45 +000034 empty_line_regex = re.compile('^$')
35
36 class Thread:
37 """Class that represents a thread in a darwin crash log"""
38 def __init__(self, index):
39 self.index = index
40 self.frames = list()
41 self.registers = dict()
42 self.reason = None
43 self.queue = None
44
45 def dump(self, prefix):
46 print "%sThread[%u] %s" % (prefix, self.index, self.reason)
47 if self.frames:
48 print "%s Frames:" % (prefix)
49 for frame in self.frames:
50 frame.dump(prefix + ' ')
51 if self.registers:
52 print "%s Registers:" % (prefix)
53 for reg in self.registers.keys():
54 print "%s %-5s = %#16.16x" % (prefix, reg, self.registers[reg])
55
56 def did_crash(self):
57 return self.reason != None
58
59 def __str__(self):
60 s = "Thread[%u]" % self.index
61 if self.reason:
62 s += ' %s' % self.reason
63 return s
64
65
66 class Frame:
67 """Class that represents a stack frame in a thread in a darwin crash log"""
68 def __init__(self, index, pc, details):
69 self.index = index
70 self.pc = pc
71 self.sym_ctx = None
72 self.details = details
73
74 def __str__(self):
75 return "[%2u] %#16.16x %s" % (self.index, self.pc, self.details)
76
77 def dump(self, prefix):
78 print "%s%s" % (prefix, self)
79
80
81 class Image:
82 """Class that represents a binary images in a darwin crash log"""
Greg Clayton8077a532012-01-20 03:32:35 +000083 dsymForUUIDBinary = os.path.expanduser('~rc/bin/dsymForUUID')
84
Greg Clayton01f7c962012-01-20 03:15:45 +000085 def __init__(self, text_addr_lo, text_addr_hi, ident, version, uuid, path):
86 self.text_addr_lo = text_addr_lo
87 self.text_addr_hi = text_addr_hi
88 self.ident = ident
89 self.version = version
90 self.uuid = uuid
91 self.path = path
92 self.target = None
93 self.module = None
94 self.plist = None
95
96 def dump(self, prefix):
97 print "%s%s" % (prefix, self)
98
99 def __str__(self):
100 return "%#16.16x %s %s" % (self.text_addr_lo, self.uuid, self.path)
101
102 def basename(self):
103 if self.path:
104 return os.path.basename(self.path)
105 return None
106
107 def fetch_symboled_executable_and_dsym(self):
Greg Clayton8077a532012-01-20 03:32:35 +0000108 if os.path.exists(self.dsymForUUIDBinary):
109 dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, self.uuid)
110 print 'Fetching %s %s...' % (self.uuid, self.path),
111 s = commands.getoutput(dsym_for_uuid_command)
112 if s:
113 plist_root = plistlib.readPlistFromString (s)
114 if plist_root:
115 # pp = pprint.PrettyPrinter(indent=4)
116 # pp.pprint(plist_root)
117 self.plist = plist_root[self.uuid]
118 if self.plist:
119 if 'DBGError' in self.plist:
120 err = self.plist['DBGError']
121 if isinstance(err, unicode):
122 err = err.encode('utf-8')
123 print 'error: %s' % err
124 elif 'DBGSymbolRichExecutable' in self.plist:
125 self.path = os.path.expanduser (self.plist['DBGSymbolRichExecutable'])
126 #print 'success: symboled exe is "%s"' % self.path
127 print 'ok'
128 return 1
129 print 'error: failed to get plist dictionary entry for UUID %s: %s' % (uuid, plist_root)
130 else:
131 print 'error: failed to extract plist from "%s"' % (s)
Greg Clayton01f7c962012-01-20 03:15:45 +0000132 else:
Greg Clayton8077a532012-01-20 03:32:35 +0000133 print 'error: %s failed...' % (dsym_for_uuid_command)
134 return 0
Greg Clayton01f7c962012-01-20 03:15:45 +0000135 else:
Greg Clayton8077a532012-01-20 03:32:35 +0000136 return 1 # no dsym locating script, just use the paths in the crash log
Greg Clayton01f7c962012-01-20 03:15:45 +0000137
138 def load_module(self):
139 if self.module:
140 text_section = self.module.FindSection ("__TEXT")
141 if text_section:
142 error = self.target.SetSectionLoadAddress (text_section, self.text_addr_lo)
143 if error.Success():
Greg Clayton8077a532012-01-20 03:32:35 +0000144 #print 'Success: loaded %s.__TEXT = 0x%x' % (self.basename(), self.text_addr_lo)
Greg Clayton01f7c962012-01-20 03:15:45 +0000145 return None
146 else:
147 return 'error: %s' % error.GetCString()
148 else:
149 return 'error: unable to find "__TEXT" section in "%s"' % self.path
150 else:
151 return 'error: invalid module'
152
153 def create_target(self, debugger):
154 if self.fetch_symboled_executable_and_dsym ():
155 path_spec = lldb.SBFileSpec (self.path)
156 arch = self.plist['DBGArchitecture']
157 #print 'debugger.CreateTarget (path="%s", arch="%s") uuid=%s' % (self.path, arch, self.uuid)
158 #result.PutCString ('plist[%s] = %s' % (uuid, self.plist))
159 error = lldb.SBError()
160 self.target = debugger.CreateTarget (self.path, arch, None, False, error);
161 if self.target:
162 self.module = self.target.FindModule (path_spec)
163 if self.module:
164 err = self.load_module()
165 if err:
166 print err
167 else:
168 return None
169 else:
170 return 'error: unable to get module for (%s) "%s"' % (arch, self.path)
171 else:
172 return 'error: unable to create target for (%s) "%s"' % (arch, self.path)
173
174 def add_target_module(self, target):
175 if target:
176 self.target = target
177 if self.fetch_symboled_executable_and_dsym ():
178 path_spec = lldb.SBFileSpec (self.path)
179 arch = self.plist['DBGArchitecture']
180 #result.PutCString ('plist[%s] = %s' % (uuid, self.plist))
181 #print 'target.AddModule (path="%s", arch="%s", uuid=%s)' % (self.path, arch, self.uuid)
182 self.module = target.AddModule (self.path, arch, self.uuid)
183 if self.module:
184 err = self.load_module()
185 if err:
186 print err;
187 else:
188 return None
189 else:
190 return 'error: unable to get module for (%s) "%s"' % (arch, self.path)
191 else:
192 return 'error: invalid target'
193
194 def __init__(self, path):
195 """CrashLog constructor that take a path to a darwin crash log file"""
196 self.path = path;
197 self.info_lines = list()
198 self.system_profile = list()
199 self.threads = list()
200 self.images = list()
201 self.idents = list() # A list of the required identifiers for doing all stack backtraces
202 self.crashed_thread_idx = -1
203 self.version = -1
204 # With possible initial component of ~ or ~user replaced by that user's home directory.
205 f = open(os.path.expanduser(self.path))
206 self.file_lines = f.read().splitlines()
207 parse_mode = PARSE_MODE_NORMAL
208 thread = None
209 for line in self.file_lines:
210 # print line
211 line_len = len(line)
212 if line_len == 0:
213 if thread:
214 if parse_mode == PARSE_MODE_THREAD:
215 if thread.index == self.crashed_thread_idx:
216 thread.reason = ''
217 if self.thread_exception:
218 thread.reason += self.thread_exception
219 if self.thread_exception_data:
220 thread.reason += " (%s)" % self.thread_exception_data
221 self.threads.append(thread)
222 thread = None
223 else:
224 # only append an extra empty line if the previous line
225 # in the info_lines wasn't empty
226 if len(self.info_lines) > 0 and len(self.info_lines[-1]):
227 self.info_lines.append(line)
228 parse_mode = PARSE_MODE_NORMAL
229 # print 'PARSE_MODE_NORMAL'
230 elif parse_mode == PARSE_MODE_NORMAL:
231 if line.startswith ('Process:'):
232 (self.process_name, pid_with_brackets) = line[8:].strip().split()
233 self.process_id = pid_with_brackets.strip('[]')
234 elif line.startswith ('Path:'):
235 self.process_path = line[5:].strip()
236 elif line.startswith ('Identifier:'):
237 self.process_identifier = line[11:].strip()
238 elif line.startswith ('Version:'):
239 (self.process_version, compatability_version) = line[8:].strip().split()
240 self.process_compatability_version = compatability_version.strip('()')
241 elif line.startswith ('Parent Process:'):
242 (self.parent_process_name, pid_with_brackets) = line[15:].strip().split()
243 self.parent_process_id = pid_with_brackets.strip('[]')
244 elif line.startswith ('Exception Type:'):
245 self.thread_exception = line[15:].strip()
246 continue
247 elif line.startswith ('Exception Codes:'):
248 self.thread_exception_data = line[16:].strip()
249 continue
250 elif line.startswith ('Crashed Thread:'):
251 self.crashed_thread_idx = int(line[15:].strip().split()[0])
252 continue
253 elif line.startswith ('Report Version:'):
254 self.version = int(line[15:].strip())
255 continue
256 elif line.startswith ('System Profile:'):
257 parse_mode = PARSE_MODE_SYSTEM
258 continue
259 elif (line.startswith ('Interval Since Last Report:') or
260 line.startswith ('Crashes Since Last Report:') or
261 line.startswith ('Per-App Interval Since Last Report:') or
262 line.startswith ('Per-App Crashes Since Last Report:') or
263 line.startswith ('Sleep/Wake UUID:') or
264 line.startswith ('Anonymous UUID:')):
265 # ignore these
266 continue
267 elif line.startswith ('Thread'):
268 thread_state_match = self.thread_state_regex.search (line)
269 if thread_state_match:
270 thread_state_match = self.thread_regex.search (line)
271 thread_idx = int(thread_state_match.group(1))
272 parse_mode = PARSE_MODE_THREGS
273 thread = self.threads[thread_idx]
274 else:
275 thread_match = self.thread_regex.search (line)
276 if thread_match:
277 # print 'PARSE_MODE_THREAD'
278 parse_mode = PARSE_MODE_THREAD
279 thread_idx = int(thread_match.group(1))
280 thread = CrashLog.Thread(thread_idx)
281 continue
282 elif line.startswith ('Binary Images:'):
283 parse_mode = PARSE_MODE_IMAGES
284 continue
285 self.info_lines.append(line.strip())
286 elif parse_mode == PARSE_MODE_THREAD:
287 frame_match = self.frame_regex.search(line)
288 if frame_match:
289 ident = frame_match.group(2)
290 if not ident in self.idents:
291 self.idents.append(ident)
292 thread.frames.append (CrashLog.Frame(int(frame_match.group(1)), int(frame_match.group(3), 0), frame_match.group(4)))
293 else:
Greg Clayton8077a532012-01-20 03:32:35 +0000294 print 'error: frame regex failed for line: "%s"' % line
Greg Clayton01f7c962012-01-20 03:15:45 +0000295 elif parse_mode == PARSE_MODE_IMAGES:
296 image_match = self.image_regex_uuid.search (line)
297 if image_match:
298 image = CrashLog.Image (int(image_match.group(1),0),
299 int(image_match.group(2),0),
300 image_match.group(3).strip(),
301 image_match.group(4).strip(),
302 image_match.group(5),
303 image_match.group(6))
304 self.images.append (image)
305 else:
306 image_match = self.image_regex_no_uuid.search (line)
307 if image_match:
308 image = CrashLog.Image (int(image_match.group(1),0),
309 int(image_match.group(2),0),
310 image_match.group(3).strip(),
311 image_match.group(4).strip(),
312 None,
313 image_match.group(5))
314 self.images.append (image)
315 else:
316 print "error: image regex failed for: %s" % line
317
318 elif parse_mode == PARSE_MODE_THREGS:
319 stripped_line = line.strip()
320 reg_values = stripped_line.split(' ')
321 for reg_value in reg_values:
322 (reg, value) = reg_value.split(': ')
323 thread.registers[reg.strip()] = int(value, 0)
324 elif parse_mode == PARSE_MODE_SYSTEM:
325 self.system_profile.append(line)
326 f.close()
327
328 def dump(self):
329 print "Crash Log File: %s" % (self.path)
330 print "\nThreads:"
331 for thread in self.threads:
332 thread.dump(' ')
333 print "\nImages:"
334 for image in self.images:
335 image.dump(' ')
336
337 def find_image_with_identifier(self, ident):
338 for image in self.images:
339 if image.ident == ident:
340 return image
341 return None
342
343def disassemble_instructions (target, instructions, pc, insts_before_pc, insts_after_pc):
344 lines = list()
345 pc_index = -1
346 comment_column = 50
347 for inst_idx, inst in enumerate(instructions):
348 inst_pc = inst.GetAddress().GetLoadAddress(target);
349 if pc == inst_pc:
350 pc_index = inst_idx
351 mnemonic = inst.GetMnemonic (target)
352 operands = inst.GetOperands (target)
353 comment = inst.GetComment (target)
354 #data = inst.GetData (target)
355 lines.append ("%#16.16x: %8s %s" % (inst_pc, mnemonic, operands))
356 if comment:
357 line_len = len(lines[-1])
358 if line_len < comment_column:
359 lines[-1] += ' ' * (comment_column - line_len)
360 lines[-1] += "; %s" % comment
361
362 if pc_index >= 0:
363 if pc_index >= insts_before_pc:
364 start_idx = pc_index - insts_before_pc
365 else:
366 start_idx = 0
367 end_idx = pc_index + insts_after_pc
368 if end_idx > inst_idx:
369 end_idx = inst_idx
370 for i in range(start_idx, end_idx+1):
371 if i == pc_index:
372 print ' -> ', lines[i]
373 else:
374 print ' ', lines[i]
375
376def print_module_section_data (section):
377 print section
378 section_data = section.GetSectionData()
379 if section_data:
380 ostream = lldb.SBStream()
381 section_data.GetDescription (ostream, section.GetFileAddress())
382 print ostream.GetData()
383
384def print_module_section (section, depth):
385 print section
386
387 if depth > 0:
388 num_sub_sections = section.GetNumSubSections()
389 for sect_idx in range(num_sub_sections):
390 print_module_section (section.GetSubSectionAtIndex(sect_idx), depth - 1)
391
392def print_module_sections (module, depth):
393 for sect in module.section_iter():
394 print_module_section (sect, depth)
395
396def print_module_symbols (module):
397 for sym in module:
398 print sym
399
400def usage():
401 print "Usage: lldb-symbolicate.py [-n name] executable-image"
402 sys.exit(0)
403
404def Symbolicate(debugger, command, result, dict):
405 SymbolicateCrashLog (command.split())
406
407def SymbolicateCrashLog(command_args):
408
409 parser = optparse.OptionParser(description='A script that parses skinny and universal mach-o files.')
410 parser.add_option('--arch', type='string', metavar='arch', dest='triple', help='specify one architecture or target triple')
411 parser.add_option('--platform', type='string', metavar='platform', dest='platform', help='specify one platform by name')
412 parser.add_option('--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
413 parser.add_option('--interactive', action='store_true', dest='interactive', help='enable interactive mode', default=False)
414 parser.add_option('--no-images', action='store_false', dest='show_images', help='don\'t show images in stack frames', default=True)
415 parser.add_option('--no-dependents', action='store_false', dest='dependents', help='skip loading dependent modules', default=True)
416 parser.add_option('--sections', action='store_true', dest='dump_sections', help='show module sections', default=False)
417 parser.add_option('--symbols', action='store_true', dest='dump_symbols', help='show module symbols', default=False)
418 parser.add_option('--image-list', action='store_true', dest='dump_image_list', help='show image list', default=False)
419 parser.add_option('--debug-delay', type='int', dest='debug_delay', metavar='NSEC', help='pause for NSEC seconds for debugger', default=0)
420 parser.add_option('--section-depth', type='int', dest='section_depth', help='set the section depth to use when showing sections', default=0)
421 parser.add_option('--section-data', type='string', action='append', dest='sect_data_names', help='specify sections by name to display data for')
422 parser.add_option('--address', type='int', action='append', dest='addresses', help='specify addresses to lookup')
423 parser.add_option('--crash-log', type='string', action='append', dest='crash_log_files', help='specify crash log files to symbolicate')
424 parser.add_option('--crashed-only', action='store_true', dest='crashed_only', help='only show the crashed thread', default=False)
425 loaded_addresses = False
426 (options, args) = parser.parse_args(command_args)
427 if options.verbose:
428 print 'options', options
429
430 if options.debug_delay > 0:
431 print "Waiting %u seconds for debugger to attach..." % options.debug_delay
432 time.sleep(options.debug_delay)
433
434 # Create a new debugger instance
435 debugger = lldb.SBDebugger.Create()
436
437 error = lldb.SBError()
438
439
440 if options.crash_log_files:
441 options.dependents = False
442 for crash_log_file in options.crash_log_files:
443 crash_log = CrashLog(crash_log_file)
Greg Clayton8077a532012-01-20 03:32:35 +0000444 if options.verbose:
445 crash_log.dump()
Greg Clayton01f7c962012-01-20 03:15:45 +0000446 if crash_log.images:
447 err = crash_log.images[0].create_target (debugger)
448 if err:
449 print err
450 else:
451 target = crash_log.images[0].target
452 exe_module = target.GetModuleAtIndex(0)
453 image_paths = list()
454 # for i in range (1, len(crash_log.images)):
455 # image = crash_log.images[i]
456 for ident in crash_log.idents:
457 image = crash_log.find_image_with_identifier (ident)
458 if image:
459 if image.path in image_paths:
460 print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo)
461 else:
462 err = image.add_target_module (target)
463 if err:
464 print err
465 else:
466 image_paths.append(image.path)
467 else:
468 print 'error: can\'t find image for identifier "%s"' % ident
469
470 for line in crash_log.info_lines:
471 print line
472
473 # Reconstruct inlined frames for all threads for anything that has debug info
474 for thread in crash_log.threads:
475 if options.crashed_only and thread.did_crash() == False:
476 continue
477 # start a new frame list that we will fixup for each thread
478 new_thread_frames = list()
479 # Iterate through all concrete frames for a thread and resolve
480 # any parent frames of inlined functions
481 for frame_idx, frame in enumerate(thread.frames):
482 # Resolve the frame's pc into a section + offset address 'pc_addr'
483 pc_addr = target.ResolveLoadAddress (frame.pc)
484 # Check to see if we were able to resolve the address
485 if pc_addr:
486 # We were able to resolve the frame's PC into a section offset
487 # address.
488
489 # Resolve the frame's PC value into a symbol context. A symbol
490 # context can resolve a module, compile unit, function, block,
491 # line table entry and/or symbol. If the frame has a block, then
492 # we can look for inlined frames, which are represented by blocks
493 # that have inlined information in them
494 frame.sym_ctx = target.ResolveSymbolContextForAddress (pc_addr, lldb.eSymbolContextEverything);
495
496 # dump if the verbose option was specified
497 if options.verbose:
498 print "frame.pc = %#16.16x (file_addr = %#16.16x)" % (frame.pc, pc_addr.GetFileAddress())
499 print "frame.pc_addr = ", pc_addr
500 print "frame.sym_ctx = "
501 print frame.sym_ctx
502 print
503
504 # Append the frame we already had from the crash log to the new
505 # frames list
506 new_thread_frames.append(frame)
507
508 new_frame = CrashLog.Frame (frame.index, -1, None)
509
510 # Try and use the current frame's symbol context to calculate a
511 # parent frame for an inlined function. If the curent frame is
512 # inlined, it will return a valid symbol context for the parent
513 # frame of the current inlined function
514 parent_pc_addr = lldb.SBAddress()
515 new_frame.sym_ctx = frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
516
517 # See if we were able to reconstruct anything?
518 while new_frame.sym_ctx:
519 # We have a parent frame of an inlined frame, create a new frame
520 # Convert the section + offset 'parent_pc_addr' to a load address
521 new_frame.pc = parent_pc_addr.GetLoadAddress(target)
522 # push the new frame onto the new frame stack
523 new_thread_frames.append (new_frame)
524 # dump if the verbose option was specified
525 if options.verbose:
526 print "new_frame.pc = %#16.16x (%s)" % (new_frame.pc, parent_pc_addr)
527 print "new_frame.sym_ctx = "
528 print new_frame.sym_ctx
529 print
530 # Create another new frame in case we have multiple inlined frames
531 prev_new_frame = new_frame
532 new_frame = CrashLog.Frame (frame.index, -1, None)
533 # Swap the addresses so we can try another inlined lookup
534 pc_addr = parent_pc_addr;
535 new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr)
536 # Replace our thread frames with our new list that includes parent
537 # frames for inlined functions
538 thread.frames = new_thread_frames
539 # Now iterate through all threads and display our richer stack backtraces
540 for thread in crash_log.threads:
541 this_thread_crashed = thread.did_crash()
542 if options.crashed_only and this_thread_crashed == False:
543 continue
544 print "%s" % thread
545 prev_frame_index = -1
546 for frame_idx, frame in enumerate(thread.frames):
547 details = ' %s' % frame.details
548 module = frame.sym_ctx.GetModule()
549 instructions = None
550 if module:
551 module_basename = module.GetFileSpec().GetFilename();
552 function_start_load_addr = -1
553 function_name = None
554 function = frame.sym_ctx.GetFunction()
555 block = frame.sym_ctx.GetBlock()
556 line_entry = frame.sym_ctx.GetLineEntry()
557 symbol = frame.sym_ctx.GetSymbol()
558 inlined_block = block.GetContainingInlinedBlock();
559 if inlined_block:
560 function_name = inlined_block.GetInlinedName();
561 block_range_idx = inlined_block.GetRangeIndexForBlockAddress (target.ResolveLoadAddress (frame.pc))
562 if block_range_idx < lldb.UINT32_MAX:
563 block_range_start_addr = inlined_block.GetRangeStartAddress (block_range_idx)
564 function_start_load_addr = block_range_start_addr.GetLoadAddress (target)
565 else:
566 function_start_load_addr = frame.pc
567 if this_thread_crashed and frame_idx == 0:
568 instructions = function.GetInstructions(target)
569 elif function:
570 function_name = function.GetName()
571 function_start_load_addr = function.GetStartAddress().GetLoadAddress (target)
572 if this_thread_crashed and frame_idx == 0:
573 instructions = function.GetInstructions(target)
574 elif symbol:
575 function_name = symbol.GetName()
576 function_start_load_addr = symbol.GetStartAddress().GetLoadAddress (target)
577 if this_thread_crashed and frame_idx == 0:
578 instructions = symbol.GetInstructions(target)
579
580 if function_name:
581 # Print the function or symbol name and annotate if it was inlined
582 inline_suffix = ''
583 if inlined_block:
584 inline_suffix = '[inlined] '
585 else:
586 inline_suffix = ' '
587 if options.show_images:
588 details = "%s%s`%s" % (inline_suffix, module_basename, function_name)
589 else:
590 details = "%s" % (function_name)
591 # Dump the offset from the current function or symbol if it is non zero
592 function_offset = frame.pc - function_start_load_addr
593 if function_offset > 0:
594 details += " + %u" % (function_offset)
595 elif function_offset < 0:
596 defaults += " %i (invalid negative offset, file a bug) " % function_offset
597 # Print out any line information if any is available
598 if line_entry.GetFileSpec():
599 details += ' at %s' % line_entry.GetFileSpec().GetFilename()
600 details += ':%u' % line_entry.GetLine ()
601 column = line_entry.GetColumn()
602 if column > 0:
603 details += ':%u' % column
604
605
606 # Only print out the concrete frame index if it changes.
607 # if prev_frame_index != frame.index:
608 # print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
609 # else:
610 # print " %#16.16x %s" % (frame.pc, details)
611 print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details)
612 prev_frame_index = frame.index
613 if instructions:
614 print
615 disassemble_instructions (target, instructions, frame.pc, 4, 4)
616 print
617
618 print
619
620 if options.dump_image_list:
621 print "Binary Images:"
622 for image in crash_log.images:
623 print image
624
625
626if __name__ == '__main__':
627 SymbolicateCrashLog (args)
628