Skip to content

Commit f4a7e1f

Browse files
authored
[lldb/crashlog] Fix module binary resolution (#91631)
This patch fixes a bug in when resolving and loading modules from the binary image list. When loading a module, we would first use the UUID from the binary image list with `dsymForUUID` to fetch the dSYM bundle from our remote build records and copy the executable locally. If we failed to find a matching dSYM bundle for that UUID on the build record, let's say if that module was built locally, we use Spotlight (`mdfind`) to find the dSYM bundle once again using the UUID. Prior to this patch, we would set the image path to be the same as the symbol file. This resulted in trying to load the dSYM as a module in lldb, which isn't allowed. This patch address that by looking for a binary matching the image identifier, next to the dSYM bundle and try to load that instead. rdar://127433616 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent ddad7c3 commit f4a7e1f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lldb/examples/python/crashlog.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,20 @@ def locate_module_and_debug_symbols(self):
418418
with print_lock:
419419
print('falling back to binary inside "%s"' % dsym)
420420
self.symfile = dsym
421-
for filename in os.listdir(dwarf_dir):
422-
self.path = os.path.join(dwarf_dir, filename)
423-
if self.find_matching_slice():
421+
# Look for the executable next to the dSYM bundle.
422+
parent_dir = os.path.dirname(dsym)
423+
executables = []
424+
for root, _, files in os.walk(parent_dir):
425+
for file in files:
426+
abs_path = os.path.join(root, file)
427+
if os.path.isfile(abs_path) and os.access(
428+
abs_path, os.X_OK
429+
):
430+
executables.append(abs_path)
431+
for binary in executables:
432+
basename = os.path.basename(binary)
433+
if basename == self.identifier:
434+
self.path = binary
424435
found_matching_slice = True
425436
break
426437
if found_matching_slice:

0 commit comments

Comments
 (0)