Skip to content

Commit 0f29319

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
1 parent cd16836 commit 0f29319

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
@@ -351,6 +351,12 @@ def dump(self):
351351
for image in self.images:
352352
image.dump(' ')
353353

354+
def set_main_image(self, identifier):
355+
for i, image in enumerate(self.images):
356+
if image.identifier == identifier:
357+
self.images.insert(0, self.images.pop(i))
358+
break
359+
354360
def find_image_with_identifier(self, identifier):
355361
for image in self.images:
356362
if image.identifier == identifier:
@@ -435,6 +441,7 @@ def parse(self):
435441
try:
436442
self.parse_process_info(self.data)
437443
self.parse_images(self.data['usedImages'])
444+
self.parse_main_image(self.data)
438445
self.parse_threads(self.data['threads'])
439446
self.parse_errors(self.data)
440447
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
@@ -485,6 +492,11 @@ def parse_images(self, json_images):
485492
self.crashlog.images.append(darwin_image)
486493
idx += 1
487494

495+
def parse_main_image(self, json_data):
496+
if 'procName' in json_data:
497+
proc_name = json_data['procName']
498+
self.crashlog.set_main_image(proc_name)
499+
488500
def parse_frames(self, thread, json_frames):
489501
idx = 0
490502
for json_frame in json_frames:

0 commit comments

Comments
 (0)