diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2022-02-14 21:21:07 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2022-02-14 21:24:02 -0800 |
commit | 0f29319e56459eb26a3bf7fb86e45e63f43a168e (patch) | |
tree | 80672f5189d9461dc85ab6966232fbef4e476be1 /lldb/examples/python/crashlog.py | |
parent | cd16836ce20bc7f278eac0e367060fb205a78b81 (diff) | |
download | llvm-0f29319e56459eb26a3bf7fb86e45e63f43a168e.zip llvm-0f29319e56459eb26a3bf7fb86e45e63f43a168e.tar.gz llvm-0f29319e56459eb26a3bf7fb86e45e63f43a168e.tar.bz2 |
[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
Diffstat (limited to 'lldb/examples/python/crashlog.py')
-rwxr-xr-x | lldb/examples/python/crashlog.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 63be066..bc57a27 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -351,6 +351,12 @@ class CrashLog(symbolication.Symbolicator): 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 @@ class JSONCrashLogParser: 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 @@ class JSONCrashLogParser: 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: |