Skip to content

Commit b017cbf

Browse files
committed
[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 (cherry picked from commit 0f29319)
1 parent 698e047 commit b017cbf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lldb/examples/python/crashlog.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ def dump(self):
353353
for image in self.images:
354354
image.dump(' ')
355355

356+
def set_main_image(self, identifier):
357+
for i, image in enumerate(self.images):
358+
if image.identifier == identifier:
359+
self.images.insert(0, self.images.pop(i))
360+
break
361+
356362
def find_image_with_identifier(self, identifier):
357363
for image in self.images:
358364
if image.identifier == identifier:
@@ -437,6 +443,7 @@ def parse(self):
437443
try:
438444
self.parse_process_info(self.data)
439445
self.parse_images(self.data['usedImages'])
446+
self.parse_main_image(self.data)
440447
self.parse_threads(self.data['threads'])
441448
self.parse_errors(self.data)
442449
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
@@ -487,6 +494,11 @@ def parse_images(self, json_images):
487494
self.crashlog.images.append(darwin_image)
488495
idx += 1
489496

497+
def parse_main_image(self, json_data):
498+
if 'procName' in json_data:
499+
proc_name = json_data['procName']
500+
self.crashlog.set_main_image(proc_name)
501+
490502
def parse_frames(self, thread, json_frames):
491503
idx = 0
492504
for json_frame in json_frames:

0 commit comments

Comments
 (0)