[Lldb-commits] [lldb] r349366 - Make crashlog.py work when a .dSYM is present, but a binary is missing

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 17 09:25:57 PST 2018


Author: adrian
Date: Mon Dec 17 09:25:57 2018
New Revision: 349366

URL: http://llvm.org/viewvc/llvm-project?rev=349366&view=rev
Log:
Make crashlog.py work when a .dSYM is present, but a binary is missing

Often users have a crash log an d a .dSYM bundle, but not the original
application binary. It turns out that for crash symbolication, we can
safely fall back to using the binary inside the .dSYM bundle.

Differential Revision: https://reviews.llvm.org/D55607

Modified:
    lldb/trunk/examples/python/crashlog.py

Modified: lldb/trunk/examples/python/crashlog.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/crashlog.py?rev=349366&r1=349365&r2=349366&view=diff
==============================================================================
--- lldb/trunk/examples/python/crashlog.py (original)
+++ lldb/trunk/examples/python/crashlog.py Mon Dec 17 09:25:57 2018
@@ -246,6 +246,25 @@ class CrashLog(symbolication.Symbolicato
             self.identifier = identifier
             self.version = version
 
+        def find_matching_slice(self):
+            dwarfdump_cmd_output = commands.getoutput(
+                'dwarfdump --uuid "%s"' % self.path)
+            self_uuid = self.get_uuid()
+            for line in dwarfdump_cmd_output.splitlines():
+                match = self.dwarfdump_uuid_regex.search(line)
+                if match:
+                    dwarf_uuid_str = match.group(1)
+                    dwarf_uuid = uuid.UUID(dwarf_uuid_str)
+                    if self_uuid == dwarf_uuid:
+                        self.resolved_path = self.path
+                        self.arch = match.group(2)
+                        return True
+            if not self.resolved_path:
+                self.unavailable = True
+                print("error\n    error: unable to locate '%s' with UUID %s"
+                      % (self.path, uuid_str))
+                return False
+
         def locate_module_and_debug_symbols(self):
             # Don't load a module twice...
             if self.resolved:
@@ -277,22 +296,25 @@ class CrashLog(symbolication.Symbolicato
                                     plist['DBGSymbolRichExecutable'])
                                 self.resolved_path = self.path
             if not self.resolved_path and os.path.exists(self.path):
-                dwarfdump_cmd_output = commands.getoutput(
-                    'dwarfdump --uuid "%s"' % self.path)
-                self_uuid = self.get_uuid()
-                for line in dwarfdump_cmd_output.splitlines():
-                    match = self.dwarfdump_uuid_regex.search(line)
-                    if match:
-                        dwarf_uuid_str = match.group(1)
-                        dwarf_uuid = uuid.UUID(dwarf_uuid_str)
-                        if self_uuid == dwarf_uuid:
-                            self.resolved_path = self.path
-                            self.arch = match.group(2)
-                            break
-                if not self.resolved_path:
-                    self.unavailable = True
-                    print "error\n    error: unable to locate '%s' with UUID %s" % (self.path, uuid_str)
+                if not self.find_matching_slice():
                     return False
+            if not self.resolved_path and not os.path.exists(self.path):
+                try:
+                    import subprocess
+                    dsym = subprocess.check_output(
+                        ["/usr/bin/mdfind",
+                         "com_apple_xcode_dsym_uuids == %s"%uuid_str])[:-1]
+                    if dsym and os.path.exists(dsym):
+                        print('falling back to binary inside "%s"'%dsym)
+                        self.symfile = dsym
+                        dwarf_dir = os.path.join(dsym, 'Contents/Resources/DWARF')
+                        for filename in os.listdir(dwarf_dir):
+                            self.path = os.path.join(dwarf_dir, filename)
+                            if not self.find_matching_slice():
+                                return False
+                            break
+                except:
+                    pass
             if (self.resolved_path and os.path.exists(self.resolved_path)) or (
                     self.path and os.path.exists(self.path)):
                 print 'ok'




More information about the lldb-commits mailing list