[Lldb-commits] [lldb] r349367 - Make crashlog.py work or binaries with spaces in their names

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


Author: adrian
Date: Mon Dec 17 09:26:04 2018
New Revision: 349367

URL: http://llvm.org/viewvc/llvm-project?rev=349367&view=rev
Log:
Make crashlog.py work or binaries with spaces in their names

This is a little dangerous since the crashlog files aren't 100%
unambiguous, but the risk is mitigated by using a non-greedy +?
pattern.

rdar://problem/38478511

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

Added:
    lldb/trunk/lit/Python/
    lldb/trunk/lit/Python/crashlog.test
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=349367&r1=349366&r2=349367&view=diff
==============================================================================
--- lldb/trunk/examples/python/crashlog.py (original)
+++ lldb/trunk/examples/python/crashlog.py Mon Dec 17 09:26:04 2018
@@ -94,11 +94,9 @@ class CrashLog(symbolication.Symbolicato
     thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
     app_backtrace_regex = re.compile(
         '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-    frame_regex = re.compile('^([0-9]+)\s+([^ ]+)\s+(0x[0-9a-fA-F]+) +(.*)')
+    frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
     image_regex_uuid = re.compile(
-        '(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)')
-    image_regex_no_uuid = re.compile(
-        '(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^/]+)/(.*)')
+        '(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
     empty_line_regex = re.compile('^$')
 
     class Thread:
@@ -477,25 +475,16 @@ class CrashLog(symbolication.Symbolicato
             elif parse_mode == PARSE_MODE_IMAGES:
                 image_match = self.image_regex_uuid.search(line)
                 if image_match:
-                    image = CrashLog.DarwinImage(int(image_match.group(1), 0),
-                                                 int(image_match.group(2), 0),
-                                                 image_match.group(3).strip(),
-                                                 image_match.group(4).strip(),
-                                                 uuid.UUID(image_match.group(5)),
-                                                 image_match.group(6))
+                    (img_lo, img_hi, img_name, img_version,
+                     _, img_uuid, img_path) = image_match.groups()
+                    image = CrashLog.DarwinImage(int(img_lo, 0), int(img_hi, 0),
+                                                 img_name.strip(),
+                                                 img_version.strip()
+                                                 if img_version else "",
+                                                 uuid.UUID(img_uuid), img_path)
                     self.images.append(image)
                 else:
-                    image_match = self.image_regex_no_uuid.search(line)
-                    if image_match:
-                        image = CrashLog.DarwinImage(int(image_match.group(1), 0),
-                                                     int(image_match.group(2), 0),
-                                                     image_match.group(3).strip(),
-                                                     image_match.group(4).strip(),
-                                                     None,
-                                                     image_match.group(5))
-                        self.images.append(image)
-                    else:
-                        print "error: image regex failed for: %s" % line
+                    print "error: image regex failed for: %s" % line
 
             elif parse_mode == PARSE_MODE_THREGS:
                 stripped_line = line.strip()

Added: lldb/trunk/lit/Python/crashlog.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Python/crashlog.test?rev=349367&view=auto
==============================================================================
--- lldb/trunk/lit/Python/crashlog.test (added)
+++ lldb/trunk/lit/Python/crashlog.test Mon Dec 17 09:26:04 2018
@@ -0,0 +1,99 @@
+#                                                                 -*- python -*-
+# RUN: cd %S/../../examples/python && %lldb -S %s | FileCheck %s
+# REQUIRES : system-darwin
+# CHECK-LABEL: {{S}}KIP BEYOND CHECKS
+script
+import crashlog
+cl = crashlog.CrashLog
+images = [
+"0x10b60b000 - 0x10f707fff com.apple.LLDB.framework (1.1000.11.38.2 - 1000.11.38.2) <96E36F5C-1A83-39A1-8713-5FDD9701C3F1> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB",
+# CHECK: 0x10b60b000
+# CHECK: 0x10f707fff
+# CHECK: com.apple.LLDB.framework
+# CHECK: 96E36F5C-1A83-39A1-8713-5FDD9701C3F1
+# CHECK: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB
+
+"0x104591000 - 0x1055cfff7 +llvm-dwarfdump (0) <B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3> /Users/USER 1/Documents/*/llvm-dwarfdump",
+# CHECK: 0x104591000
+# CHECK: 0x1055cfff7
+# CHECK: llvm-dwarfdump
+# CHECK: (0)
+# CHECK: B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3
+# CHECK: /Users/USER 1/Documents/*/llvm-dwarfdump
+
+"0x7fff63f20000 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) <D4AB366F-48A9-3C7D-91BD-41198F69DD57> /usr/lib/libc++.1.dylib",
+# CHECK: 0x7fff63f20000
+# CHECK: 0x7fff63f77ff7
+# CHECK: libc++.1.dylib
+# CHECK: (400.9.4)
+# CHECK: D4AB366F-48A9-3C7D-91BD-41198F69DD57
+# CHECK: /usr/lib/libc++.1.dylib
+
+"0x1111111 - 0x22222 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
+# CHECK: 0x1111111
+# CHECK: 0x22222
+# CHECK: MyApp Pro arm64
+# CHECK: None
+# CHECK: 01234
+# CHECK: /tmp/MyApp Pro.app/MyApp Pro
+
+"0x1111111 - 0x22222 +MyApp Pro (0) <01234> /tmp/MyApp Pro.app/MyApp Pro",
+# CHECK: 0x1111111
+# CHECK: 0x22222
+# CHECK: MyApp Pro
+# CHECK: (0)
+# CHECK: 01234
+# CHECK: /tmp/MyApp Pro.app/MyApp Pro
+    
+"0x7fff63f20000 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+# CHECK: 0x7fff63f20000
+# CHECK: 0x7fff63f77ff7
+# CHECK: libc++.1.dylib
+# CHECK: (400.9.4)
+# CHECK: None
+# CHECK: /usr/lib/libc++.1.dylib
+]
+# CHECK-LABEL: FRAMES
+frames = [
+"0 libsystem_kernel.dylib        	0x00007fff684b78a6 read + 10",
+# CHECK: 0
+# CHECK: libsystem_kernel.dylib
+# CHECK: 0x00007fff684b78a6
+# CHECK: read + 10
+"1   com.apple.LLDB.framework      	0x000000010f7954af lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 105",
+# CHECK: 1
+# CHECK: com.apple.LLDB.framework
+# CHECK: 0x000000010f7954af
+# CHECK: lldb_private{{.*}} + 105
+"2   MyApp Pro arm64    	0x000000019b0db3a8 foo + 72",
+# CHECK: 2
+# CHECK: MyApp Pro arm64
+# CHECK: 0x000000019b0db3a8
+# CHECK: foo + 72
+"3   He 0x1    	0x000000019b0db3a8 foo + 72"
+# CHECK: 3
+# CHECK: He 0x1
+# CHECK: 0x000000019b0db3a8
+# CHECK: foo + 72
+]
+
+
+# Avoid matching the text inside the input.
+print("SKIP BEYOND CHECKS")
+for image in images:
+    print('"%s"'%image)
+    print("--------------")
+    match = cl.image_regex_uuid.search(image)
+    for group in match.groups():
+        print(group)
+
+print("FRAMES")
+for frame in frames:
+    print('"%s"'%frame)
+    print("--------------")
+    match = cl.frame_regex.search(frame)
+    for group in match.groups():
+        print(group)
+
+exit()
+quit




More information about the lldb-commits mailing list