monkey-see-monkey-do: Decode backtraces

To improve debugging, decode backtraces discovered during
runs with monkey-see-monkey-do

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-01-10 22:19:39 +00:00
parent a29ed7c083
commit d63de35033
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74
1 changed files with 15 additions and 1 deletions

View File

@ -24,6 +24,20 @@ MONKEY_PATH = "./nsmonkey"
mp.set_start_method('fork')
def decode_trace(s):
import re
from subprocess import getoutput
addr_re = re.compile(r"./nsmonkey\(\+(0x[0-9a-f]+)\)")
def decode_line(l):
caps = addr_re.findall(l);
if caps:
return getoutput(
"addar2line -e {} {} 2>/dev/null || echo './nsmonkey(+{})'".format(
MONKEY_PATH, caps[0], caps[0]))
else:
return l
return "\n".join(decode_line(l) for l in s.split("\n"))
def child_run_test(verbose, parts):
outcapture = StringIO()
errcapture = StringIO()
@ -38,7 +52,7 @@ def child_run_test(verbose, parts):
sys.stderr = olderr
print("FAIL:")
print("STDOUT:\n{}\n".format(outcapture.getvalue()))
print("STDERR:\n{}\n".format(errcapture.getvalue()))
print("STDERR:\n{}\n".format(decode_trace(errcapture.getvalue())))
print("RERAISE:")
raise
else: