Skip to content

Commit f700c8b

Browse files
committedDec 17, 2018
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 llvm-svn: 349367
1 parent fb5aa93 commit f700c8b

File tree

2 files changed

+109
-21
lines changed

2 files changed

+109
-21
lines changed
 

‎lldb/examples/python/crashlog.py

+10-21
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ class CrashLog(symbolication.Symbolicator):
9494
thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
9595
app_backtrace_regex = re.compile(
9696
'^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
97-
frame_regex = re.compile('^([0-9]+)\s+([^ ]+)\s+(0x[0-9a-fA-F]+) +(.*)')
97+
frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
9898
image_regex_uuid = re.compile(
99-
'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)')
100-
image_regex_no_uuid = re.compile(
101-
'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^/]+)/(.*)')
99+
'(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
102100
empty_line_regex = re.compile('^$')
103101

104102
class Thread:
@@ -477,25 +475,16 @@ def __init__(self, path):
477475
elif parse_mode == PARSE_MODE_IMAGES:
478476
image_match = self.image_regex_uuid.search(line)
479477
if image_match:
480-
image = CrashLog.DarwinImage(int(image_match.group(1), 0),
481-
int(image_match.group(2), 0),
482-
image_match.group(3).strip(),
483-
image_match.group(4).strip(),
484-
uuid.UUID(image_match.group(5)),
485-
image_match.group(6))
478+
(img_lo, img_hi, img_name, img_version,
479+
_, img_uuid, img_path) = image_match.groups()
480+
image = CrashLog.DarwinImage(int(img_lo, 0), int(img_hi, 0),
481+
img_name.strip(),
482+
img_version.strip()
483+
if img_version else "",
484+
uuid.UUID(img_uuid), img_path)
486485
self.images.append(image)
487486
else:
488-
image_match = self.image_regex_no_uuid.search(line)
489-
if image_match:
490-
image = CrashLog.DarwinImage(int(image_match.group(1), 0),
491-
int(image_match.group(2), 0),
492-
image_match.group(3).strip(),
493-
image_match.group(4).strip(),
494-
None,
495-
image_match.group(5))
496-
self.images.append(image)
497-
else:
498-
print "error: image regex failed for: %s" % line
487+
print "error: image regex failed for: %s" % line
499488

500489
elif parse_mode == PARSE_MODE_THREGS:
501490
stripped_line = line.strip()

‎lldb/lit/Python/crashlog.test

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# -*- python -*-
2+
# RUN: cd %S/../../examples/python && %lldb -S %s | FileCheck %s
3+
# REQUIRES : system-darwin
4+
# CHECK-LABEL: {{S}}KIP BEYOND CHECKS
5+
script
6+
import crashlog
7+
cl = crashlog.CrashLog
8+
images = [
9+
"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",
10+
# CHECK: 0x10b60b000
11+
# CHECK: 0x10f707fff
12+
# CHECK: com.apple.LLDB.framework
13+
# CHECK: 96E36F5C-1A83-39A1-8713-5FDD9701C3F1
14+
# CHECK: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB
15+
16+
"0x104591000 - 0x1055cfff7 +llvm-dwarfdump (0) <B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3> /Users/USER 1/Documents/*/llvm-dwarfdump",
17+
# CHECK: 0x104591000
18+
# CHECK: 0x1055cfff7
19+
# CHECK: llvm-dwarfdump
20+
# CHECK: (0)
21+
# CHECK: B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3
22+
# CHECK: /Users/USER 1/Documents/*/llvm-dwarfdump
23+
24+
"0x7fff63f20000 - 0x7fff63f77ff7 libc++.1.dylib (400.9.4) <D4AB366F-48A9-3C7D-91BD-41198F69DD57> /usr/lib/libc++.1.dylib",
25+
# CHECK: 0x7fff63f20000
26+
# CHECK: 0x7fff63f77ff7
27+
# CHECK: libc++.1.dylib
28+
# CHECK: (400.9.4)
29+
# CHECK: D4AB366F-48A9-3C7D-91BD-41198F69DD57
30+
# CHECK: /usr/lib/libc++.1.dylib
31+
32+
"0x1111111 - 0x22222 +MyApp Pro arm64 <01234> /tmp/MyApp Pro.app/MyApp Pro",
33+
# CHECK: 0x1111111
34+
# CHECK: 0x22222
35+
# CHECK: MyApp Pro arm64
36+
# CHECK: None
37+
# CHECK: 01234
38+
# CHECK: /tmp/MyApp Pro.app/MyApp Pro
39+
40+
"0x1111111 - 0x22222 +MyApp Pro (0) <01234> /tmp/MyApp Pro.app/MyApp Pro",
41+
# CHECK: 0x1111111
42+
# CHECK: 0x22222
43+
# CHECK: MyApp Pro
44+
# CHECK: (0)
45+
# CHECK: 01234
46+
# CHECK: /tmp/MyApp Pro.app/MyApp Pro
47+
48+
"0x7fff63f20000 - 0x7fff63f77ff7 libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
49+
# CHECK: 0x7fff63f20000
50+
# CHECK: 0x7fff63f77ff7
51+
# CHECK: libc++.1.dylib
52+
# CHECK: (400.9.4)
53+
# CHECK: None
54+
# CHECK: /usr/lib/libc++.1.dylib
55+
]
56+
# CHECK-LABEL: FRAMES
57+
frames = [
58+
"0 libsystem_kernel.dylib 0x00007fff684b78a6 read + 10",
59+
# CHECK: 0
60+
# CHECK: libsystem_kernel.dylib
61+
# CHECK: 0x00007fff684b78a6
62+
# CHECK: read + 10
63+
"1 com.apple.LLDB.framework 0x000000010f7954af lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 105",
64+
# CHECK: 1
65+
# CHECK: com.apple.LLDB.framework
66+
# CHECK: 0x000000010f7954af
67+
# CHECK: lldb_private{{.*}} + 105
68+
"2 MyApp Pro arm64 0x000000019b0db3a8 foo + 72",
69+
# CHECK: 2
70+
# CHECK: MyApp Pro arm64
71+
# CHECK: 0x000000019b0db3a8
72+
# CHECK: foo + 72
73+
"3 He 0x1 0x000000019b0db3a8 foo + 72"
74+
# CHECK: 3
75+
# CHECK: He 0x1
76+
# CHECK: 0x000000019b0db3a8
77+
# CHECK: foo + 72
78+
]
79+
80+
81+
# Avoid matching the text inside the input.
82+
print("SKIP BEYOND CHECKS")
83+
for image in images:
84+
print('"%s"'%image)
85+
print("--------------")
86+
match = cl.image_regex_uuid.search(image)
87+
for group in match.groups():
88+
print(group)
89+
90+
print("FRAMES")
91+
for frame in frames:
92+
print('"%s"'%frame)
93+
print("--------------")
94+
match = cl.frame_regex.search(frame)
95+
for group in match.groups():
96+
print(group)
97+
98+
exit()
99+
quit

0 commit comments

Comments
 (0)
Please sign in to comment.