[Lldb-commits] [lldb] r160316 - /lldb/trunk/examples/python/crashlog.py

Greg Clayton gclayton at apple.com
Mon Jul 16 13:40:20 PDT 2012


Author: gclayton
Date: Mon Jul 16 15:40:20 2012
New Revision: 160316

URL: http://llvm.org/viewvc/llvm-project?rev=160316&view=rev
Log:
Enable the "symbolicate" interactive command to symbolicate all crash logs if no indexes are supplied. This can be handy to use as:

(lldb) script import lldb.macosx.crashlog
(lldb) crashlog -i /tmp/*.crash
% symbolicate --crashed-only

This will symbolicate all of the crash logs only for the crashed thread.

Also print out the crash log index number in the output of the interactive "image" command:

(lldb) script import lldb.macosx.crashlog
(lldb) crashlog -i /tmp/*.crash
% image LLDB.framework
...

This then allows you to symbolicate a crash log by index accurately when you looked for an image of a specific version


Modified:
    lldb/trunk/examples/python/crashlog.py

Modified: lldb/trunk/examples/python/crashlog.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/crashlog.py?rev=160316&r1=160315&r2=160316&view=diff
==============================================================================
--- lldb/trunk/examples/python/crashlog.py (original)
+++ lldb/trunk/examples/python/crashlog.py Mon Jul 16 15:40:20 2012
@@ -405,12 +405,18 @@
         except:
             return
 
-        for idx_str in args:
-            idx = int(idx_str)
-            if idx < len(self.crash_logs):
-                SymbolicateCrashLog (self.crash_logs[idx], options)
-            else:
-                print 'error: crash log index %u is out of range' % (idx)
+        if args:
+            # We have arguments, they must valid be crash log file indexes
+            for idx_str in args:
+                idx = int(idx_str)
+                if idx < len(self.crash_logs):
+                    SymbolicateCrashLog (self.crash_logs[idx], options)
+                else:
+                    print 'error: crash log index %u is out of range' % (idx)
+        else:
+            # No arguments, symbolicate all crash logs using the options provided
+            for idx in range(len(self.crash_logs)):
+                SymbolicateCrashLog (self.crash_logs[idx], options)                
     
     def do_list(self, line=None):
         '''Dump a list of all crash logs that are currently loaded.
@@ -421,12 +427,9 @@
             print '[%u] = %s' % (crash_log_idx, crash_log.path)
 
     def do_image(self, line):
-        '''Dump information about an image in the crash log given an image basename.
-        
-        USAGE: image <basename>'''
+        '''Dump information about one or more binary images in the crash log given an image basename, or all images if no arguments are provided.'''
         usage = "usage: %prog [options] <PATH> [PATH ...]"
-        description='''Dump information about one or more images in all crash logs. The <PATH>
-        can be a full path or a image basename.'''
+        description='''Dump information about one or more images in all crash logs. The <PATH> can be a full path, image basename, or partial path. Searches are done in this order.'''
         command_args = shlex.split(line)
         if not self.image_option_parser:
             self.image_option_parser = optparse.OptionParser(description=description, prog='image',usage=usage)
@@ -439,23 +442,23 @@
         if args:
             for image_path in args:
                 fullpath_search = image_path[0] == '/'
-                for crash_log in self.crash_logs:
+                for (crash_log_idx, crash_log) in enumerate(self.crash_logs):
                     matches_found = 0
                     for (image_idx, image) in enumerate(crash_log.images):
                         if fullpath_search:
                             if image.get_resolved_path() == image_path:
                                 matches_found += 1
-                                print image
+                                print '[%u] ' % (crash_log_idx), image
                         else:
                             image_basename = image.get_resolved_path_basename()
                             if image_basename == image_path:
                                 matches_found += 1
-                                print image
+                                print '[%u] ' % (crash_log_idx), image
                     if matches_found == 0:
                         for (image_idx, image) in enumerate(crash_log.images):
                             resolved_image_path = image.get_resolved_path()
                             if resolved_image_path and string.find(image.get_resolved_path(), image_path) >= 0:
-                                print image
+                                print '[%u] ' % (crash_log_idx), image
         else:
             for crash_log in self.crash_logs:
                 for (image_idx, image) in enumerate(crash_log.images):





More information about the lldb-commits mailing list