summaryrefslogtreecommitdiffstats
path: root/lldb/examples/python
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-11-07 10:50:37 -0800
committerAdrian Prantl <aprantl@apple.com>2019-11-07 10:52:06 -0800
commitff9d732887385e6f3e516769419dd64b406d81d8 (patch)
tree2f1e174486a6a0a5b82137c733516eb961187b58 /lldb/examples/python
parent90ecfa2f5f7feea6e3676d59fe6126e08c52d00e (diff)
downloadbcm5719-llvm-ff9d732887385e6f3e516769419dd64b406d81d8.tar.gz
bcm5719-llvm-ff9d732887385e6f3e516769419dd64b406d81d8.zip
crashlog.py: Improve regular expressions
This is yet another change to the regular expressions in crashlog.py that fix a few edge cases, and attempt to improve the readability quite a bit in the process. My last change to support spaces in filenames introduced a bug that caused the version/archspec field to be parsed as part of the image name. For example, in "0x1111111 - 0x22222 +MyApp Pro arm64 <01234>", the name of the image was recognized as "MyApp Pro arm64" instead of "MyApp Pro" with a "version" of arm64. The bugfix makes the space following an optional field mandatory *inside* the optional group. rdar://problem/56883435 Differential Revision: https://reviews.llvm.org/D69871
Diffstat (limited to 'lldb/examples/python')
-rwxr-xr-xlldb/examples/python/crashlog.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 9a8ec8c1a43..b7b62acc60e 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -101,10 +101,22 @@ class CrashLog(symbolication.Symbolicator):
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]{7}[0-9a-fA-F]+) +(.*)')
- null_frame_regex = re.compile('^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
- image_regex_uuid = re.compile(
- '(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
+ version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+ frame_regex = re.compile(r'^([0-9]+)' r'\s' # id
+ r'+(.+?)' r'\s+' # img_name
+ r'(' +version+ r')?' # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+ )
+ null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+ image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)' # img_lo
+ r'\s+' '-' r'\s+' # -
+ r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+ r'[+]?(.+?)' r'\s+' # img_name
+ r'(' +version+ ')?' # img_version
+ r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+ r'(/.*)' # img_path
+ )
empty_line_regex = re.compile('^$')
class Thread:
@@ -489,18 +501,20 @@ class CrashLog(symbolication.Symbolicator):
continue
frame_match = self.frame_regex.search(line)
if frame_match:
- ident = frame_match.group(2)
+ (frame_id, frame_img_name, _, frame_img_version, _,
+ frame_addr, frame_ofs) = frame_match.groups()
+ ident = frame_img_name
thread.add_ident(ident)
if ident not in self.idents:
self.idents.append(ident)
- thread.frames.append(CrashLog.Frame(int(frame_match.group(1)), int(
- frame_match.group(3), 0), frame_match.group(4)))
+ thread.frames.append(CrashLog.Frame(int(frame_id), int(
+ frame_addr, 0), frame_ofs))
else:
print('error: frame regex failed for line: "%s"' % line)
elif parse_mode == PARSE_MODE_IMAGES:
image_match = self.image_regex_uuid.search(line)
if image_match:
- (img_lo, img_hi, img_name, img_version,
+ (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(),
OpenPOWER on IntegriCloud