[COMMIT seastar master] Merge 'seastar-addr2line: support more flexible syslog-style backtraces' from Benny Halevy

2 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Sep 9, 2022, 9:30:28 AMSep 9
to seastar-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Pavel Emelyanov <xe...@scylladb.com>
Branch: master

Merge 'seastar-addr2line: support more flexible syslog-style backtraces' from Benny Halevy

Some may contain space characters around the '+' operator in, e.g.:
```
#1 0x00007fd2dab4f950 abort (libc.so.6 + 0x26950)
```

Fixes #1206

Signed-off-by: Benny Halevy <bha...@scylladb.com>

Closes #1207

* https://github.com/scylladb/seastar:
seastar-addr2line: strip input lines
seastar-addr2line: support more flexible syslog-style backtraces

---
diff --git a/scripts/addr2line.py b/scripts/addr2line.py
--- a/scripts/addr2line.py
+++ b/scripts/addr2line.py
@@ -94,12 +94,14 @@ def __init__(self):
addr = "0x[0-9a-f]+"
path = "\S+"
token = f"(?:{path}\+)?{addr}"
- full_addr_match = f"(?:(?P<path>{path})\+)?(?P<addr>{addr})"
+ full_addr_match = f"(?:(?P<path>{path})\s*\+\s*)?(?P<addr>{addr})"
+ ignore_addr_match = f"(?:(?P<path>{path})\s*\+\s*)?(?:{addr})"
self.oneline_re = re.compile(f"^((?:.*(?:(?:at|backtrace):?|:))?(?:\s+))?({token}(?:\s+{token})*)(?:\).*|\s*)$", flags=re.IGNORECASE)
self.address_re = re.compile(full_addr_match, flags=re.IGNORECASE)
+ self.syslog_re = re.compile(f"^(?:#\d+\s+)(?P<addr>{addr})(?:.*\s+)\({ignore_addr_match}\)\s*$", flags=re.IGNORECASE)
self.asan_re = re.compile(f"^(?:.*\s+)\({full_addr_match}\)\s*$", flags=re.IGNORECASE)
self.asan_ignore_re = re.compile(f"^=.*$", flags=re.IGNORECASE)
- self.syslog_re = re.compile(f"^(?:.*\s+){full_addr_match}\s*$", flags=re.IGNORECASE)
+ self.generic_re = re.compile(f"^(?:.*\s+){full_addr_match}\s*$", flags=re.IGNORECASE)
self.separator_re = re.compile('^\W*-+\W*$')

def __call__(self, line):
@@ -121,6 +123,14 @@ def get_prefix(s):
ret['addresses'] = addresses
return ret

+ m = re.match(self.syslog_re, line)
+ if m:
+ #print(f">>> '{line}': syslog {m.groups()}")
+ ret = {'type': self.Type.ADDRESS}
+ ret['prefix'] = None
+ ret['addresses'] = [{'path': m.group('path'), 'addr': m.group('addr')}]
+ return ret
+
m = re.match(self.asan_ignore_re, line)
if m:
#print(f">>> '{line}': asan ignore")
@@ -134,9 +144,9 @@ def get_prefix(s):
ret['addresses'] = [{'path': m.group('path'), 'addr': m.group('addr')}]
return ret

- m = re.match(self.syslog_re, line)
+ m = re.match(self.generic_re, line)
if m:
- #print(f">>> '{line}': syslog {m.groups()}")
+ #print(f">>> '{line}': generic {m.groups()}")
ret = {'type': self.Type.ADDRESS}
ret['prefix'] = None
ret['addresses'] = [{'path': m.group('path'), 'addr': m.group('addr')}]
diff --git a/scripts/seastar-addr2line b/scripts/seastar-addr2line
--- a/scripts/seastar-addr2line
+++ b/scripts/seastar-addr2line
@@ -213,11 +213,18 @@ if args.test:
('[2022-04-19T23:09:28.311Z] 0x461bbb8',
{'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': None, 'addr': '0x461bbb8'}]}),
('[2022-04-19T23:09:28.311Z] /lib64/libpthread.so.0+0x92a4',
- {'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': '/lib64/libpthread.so.0', 'addr': '0x92a4'}]})
+ {'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': '/lib64/libpthread.so.0', 'addr': '0x92a4'}]}),
+
+ ('#0 0x19c01681 (/path/to/scylla+0xdeadbeef)',
+ {'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': '/path/to/scylla', 'addr': '0x19c01681'}]}),
+ ('#1 0x00007fd2dab4f950 abort (libc.so.6 + 0x26950)',
+ {'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': 'libc.so.6', 'addr': '0x00007fd2dab4f950'}]}),
+ ('#2 0x00000000015c4cd3 n/a (/path/to/scylla + 0x15c4cd3)',
+ {'type': BacktraceResolver.BacktraceParser.Type.ADDRESS, 'prefix': None, 'addresses': [{'path': '/path/to/scylla', 'addr': '0x00000000015c4cd3'}]}),
]
parser = BacktraceResolver.BacktraceParser()
for line, expected in data:
- res = parser(line)
+ res = parser(line.strip())
assert res == expected, f"{line}:\nExpected {expected}\nBut got {res}"
exit(0)

@@ -240,4 +247,4 @@ with BacktraceResolver(executable=args.executable, before_lines=args.before, con
verbose=args.verbose, cmd_path=args.addr2line) as resolve:
p = re.compile(r'\W+')
for line in lines:
- resolve(line)
+ resolve(line.strip())
Reply all
Reply to author
Forward
0 new messages