[Lldb-commits] [lldb] 0f29319 - [lldb] Determine the main binary in JSON crashlogs

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 14 21:24:07 PST 2022


Author: Jonas Devlieghere
Date: 2022-02-14T21:24:02-08:00
New Revision: 0f29319e56459eb26a3bf7fb86e45e63f43a168e

URL: https://github.com/llvm/llvm-project/commit/0f29319e56459eb26a3bf7fb86e45e63f43a168e
DIFF: https://github.com/llvm/llvm-project/commit/0f29319e56459eb26a3bf7fb86e45e63f43a168e.diff

LOG: [lldb] Determine the main binary in JSON crashlogs

The symbolicator assumes that the first image in the image list is the
main image. That isn't always the case. For JSON crashlogs we can use
the procName to move the main image to the front of the list.

rdar://83907760

Added: 
    

Modified: 
    lldb/examples/python/crashlog.py

Removed: 
    


################################################################################
diff  --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 63be06662562a..bc57a275ce744 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -351,6 +351,12 @@ def dump(self):
         for image in self.images:
             image.dump('  ')
 
+    def set_main_image(self, identifier):
+        for i, image in enumerate(self.images):
+            if image.identifier == identifier:
+                self.images.insert(0, self.images.pop(i))
+                break
+
     def find_image_with_identifier(self, identifier):
         for image in self.images:
             if image.identifier == identifier:
@@ -435,6 +441,7 @@ def parse(self):
         try:
             self.parse_process_info(self.data)
             self.parse_images(self.data['usedImages'])
+            self.parse_main_image(self.data)
             self.parse_threads(self.data['threads'])
             self.parse_errors(self.data)
             thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
@@ -485,6 +492,11 @@ def parse_images(self, json_images):
             self.crashlog.images.append(darwin_image)
             idx += 1
 
+    def parse_main_image(self, json_data):
+        if 'procName' in json_data:
+            proc_name = json_data['procName']
+            self.crashlog.set_main_image(proc_name)
+
     def parse_frames(self, thread, json_frames):
         idx = 0
         for json_frame in json_frames:


        


More information about the lldb-commits mailing list