Skip to content

Commit e6fd01f

Browse files
committed
[lldb/crashlog] Fix module binary resolution (llvm#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 <ismail@bennani.ma> (cherry picked from commit f4a7e1f)
1 parent 3076936 commit e6fd01f

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
@@ -414,9 +414,20 @@ def locate_module_and_debug_symbols(self):
414414
with print_lock:
415415
print('falling back to binary inside "%s"' % dsym)
416416
self.symfile = dsym
417-
for filename in os.listdir(dwarf_dir):
418-
self.path = os.path.join(dwarf_dir, filename)
419-
if self.find_matching_slice():
417+
# Look for the executable next to the dSYM bundle.
418+
parent_dir = os.path.dirname(dsym)
419+
executables = []
420+
for root, _, files in os.walk(parent_dir):
421+
for file in files:
422+
abs_path = os.path.join(root, file)
423+
if os.path.isfile(abs_path) and os.access(
424+
abs_path, os.X_OK
425+
):
426+
executables.append(abs_path)
427+
for binary in executables:
428+
basename = os.path.basename(binary)
429+
if basename == self.identifier:
430+
self.path = binary
420431
found_matching_slice = True
421432
break
422433
if found_matching_slice:

0 commit comments

Comments
 (0)