Skip to content

Commit e764347

Browse files
committed
[lldb] Update crashlog.py to accept multiple results from mdfind
mdfind can return multiple results, some of which are not even dSYM bundles, but Xcode archives (.xcrachive). Currently, we end up concatenating the paths, which is obviously bogus. This patch not only fixes that, but now also skips paths that don't have a Contents/Resources/DWARF subdirectory. rdar://81270312 Differential revision: https://reviews.llvm.org/D109263 (cherry picked from commit 4da5a44)
1 parent 52df6ad commit e764347

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lldb/examples/python/crashlog.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,24 @@ def locate_module_and_debug_symbols(self):
293293
return False
294294
if not self.resolved_path and not os.path.exists(self.path):
295295
try:
296-
dsym = subprocess.check_output(
296+
mdfind_results = subprocess.check_output(
297297
["/usr/bin/mdfind",
298-
"com_apple_xcode_dsym_uuids == %s"%uuid_str]).decode("utf-8")[:-1]
299-
if dsym and os.path.exists(dsym):
300-
print(('falling back to binary inside "%s"'%dsym))
301-
self.symfile = dsym
298+
"com_apple_xcode_dsym_uuids == %s" % uuid_str]).decode("utf-8").splitlines()
299+
found_matching_slice = False
300+
for dsym in mdfind_results:
302301
dwarf_dir = os.path.join(dsym, 'Contents/Resources/DWARF')
302+
if not os.path.exists(dwarf_dir):
303+
# Not a dSYM bundle, probably an Xcode archive.
304+
continue
305+
print('falling back to binary inside "%s"' % dsym)
306+
self.symfile = dsym
303307
for filename in os.listdir(dwarf_dir):
304-
self.path = os.path.join(dwarf_dir, filename)
305-
if not self.find_matching_slice():
306-
return False
307-
break
308+
self.path = os.path.join(dwarf_dir, filename)
309+
if self.find_matching_slice():
310+
found_matching_slice = True
311+
break
312+
if found_matching_slice:
313+
break
308314
except:
309315
pass
310316
if (self.resolved_path and os.path.exists(self.resolved_path)) or (

0 commit comments

Comments
 (0)