Support riscv64 in stack tool, remove mips64

Test: atest python-stack_core_test
Test: Manual validation against a crash stack on aosp_riscv64.
Change-Id: Ifc3646486fda9120c30c987f9623e134d3491a9a
This commit is contained in:
Prashanth Swaminathan
2023-03-08 13:16:35 -08:00
parent e0447d38ef
commit 01fd4185b1
2 changed files with 32 additions and 34 deletions

View File

@@ -110,33 +110,6 @@ backtrace:
#06 pc 00013198 /system/lib/libc.so (__start_thread+36) #06 pc 00013198 /system/lib/libc.so (__start_thread+36)
""" """
mips64 = """
Build fingerprint: 'Android/aosp_mips64/generic_mips64:5.1.51/AOSP/agampe05040015:userdebug/test-keys'
Revision: '1'
ABI: 'mips64'
pid: 342, tid: 342, name: crasher64 >>> crasher64 <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
zr 0000000000000000 at 0000000000000001 v0 0000000000000000 v1 000000ffec1c6528
a0 0000000000000156 a1 0000000000000156 a2 0000000000000006 a3 0000000000000000
a4 000000000000ffff a5 fffffffffffffffc a6 0000000000000000 a7 0000000000000001
t0 0000000000000001 t1 0000000000000000 t2 0000000000000001 t3 0000000000000001
s0 0000000000000002 s1 000000ffec1c6538 s2 000000ffec1c6478 s3 0000000000000006
s4 0000000000100000 s5 000000fff1d44f98 s6 000000fff186c488 s7 0000000000000000
t8 ffffffffffff0000 t9 000000ffec01c2a0 k0 0000000000000000 k1 0000000000000000
gp 000000ffec0a6680 sp 000000ffff8c7150 s8 0000000000100206 ra 000000ffec016684
hi 0000000000000000 lo 0000000000000000 bva 000000ffffffe010 epc 000000ffec01c2a8
backtrace:
#00 pc 00000000000832a8 /system/lib64/libc.so (tgkill+8)
#01 pc 000000000007d684 /system/lib64/libc.so (pthread_kill+116)
#02 pc 000000000002dd78 /system/lib64/libc.so (raise+56)
#03 pc 000000000002684c /system/lib64/libc.so (abort+92)
#04 pc 000000000000199c /system/xbin/crasher64
#05 pc 000000000002595c /system/lib64/libc.so (__libc_init+140)
#06 pc 0000000000000fd4 /system/xbin/crasher64
#07 pc 0000000000000f80 /system/xbin/crasher64
"""
x86 = """ x86 = """
Build fingerprint: 'Android/aosp_x86_64/generic_x86_64:4.4.3.43.43.43/AOSP/enh06302258:eng/test-keys' Build fingerprint: 'Android/aosp_x86_64/generic_x86_64:4.4.3.43.43.43/AOSP/enh06302258:eng/test-keys'
Revision: '0' Revision: '0'
@@ -184,6 +157,31 @@ backtrace:
#08 pc 00000000000138f5 /system/lib64/libc.so (__bionic_clone+53) #08 pc 00000000000138f5 /system/lib64/libc.so (__bionic_clone+53)
""" """
riscv64 = """
Build fingerprint: 'generic/aosp_riscv64/vsoc_riscv64:4.4.3.43.43.43/AOSP/eng.prasha.20230307.172954:eng/test-keys'
Revision: '0'
ABI: 'riscv64'
pid: 794, tid: 794, name: crasher64 >>> crasher64 <<<
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
gp ffffffff81dabe60 tp 00ffffff1aae0050 t0 000000000002ba76 t1 00ffffff140d598c
t2 00000000d82989b1 t3 00ffffff1407e570 t4 00ffffff1ac2d000 t5 0000000000000018
t6 0000000000000018 s0 000000000000031a s1 000000000000031a s2 ffffffffffffffff
s3 00ffffffca72dd20 s4 0000000000000000 s5 00fffff499ead378 s6 00fffff469ea7b90
s7 00aaaaaba6d2b2c8 s8 00fffff5fa3a1588 s9 0000000000000000 s10 0000000000000000
s11 0000000000000000 a0 0000000000000000 a1 000000000000031a a2 0000000000000006
a3 00ffffffca72da00 a4 0000000000000000 a5 000000007fffffff a6 000000007fffffff
a7 00000000000000f0
pc 00ffffff1407e582 ra 00ffffff140811d2 sp 00ffffffca72d9d0
backtrace:
#00 pc 0000000000049582 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+18)
#01 pc 000000000004c1ce /apex/com.android.runtime/lib64/bionic/libc.so (abort+98)
#02 pc 0000000000004012 /system/bin/crasher64 (maybe_abort+40)
#03 pc 000000000000457c /system/bin/crasher64 (do_action+966)
#04 pc 0000000000005528 /system/bin/crasher64 (main+78)
#05 pc 0000000000047cd4 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+80)
"""
libmemunreachable = """ libmemunreachable = """
Unreachable memory Unreachable memory
48 bytes in 2 unreachable allocations 48 bytes in 2 unreachable allocations

View File

@@ -66,9 +66,9 @@ class TraceConverter:
"arm": "r0|r1|r2|r3|r4|r5|r6|r7|r8|r9|sl|fp|ip|sp|lr|pc|cpsr", "arm": "r0|r1|r2|r3|r4|r5|r6|r7|r8|r9|sl|fp|ip|sp|lr|pc|cpsr",
"arm64": "x0|x1|x2|x3|x4|x5|x6|x7|x8|x9|x10|x11|x12|x13|x14|x15|x16|x17|x18|x19|x20|x21|x22|x23|x24|x25|x26|x27|x28|x29|x30|sp|pc|pstate", "arm64": "x0|x1|x2|x3|x4|x5|x6|x7|x8|x9|x10|x11|x12|x13|x14|x15|x16|x17|x18|x19|x20|x21|x22|x23|x24|x25|x26|x27|x28|x29|x30|sp|pc|pstate",
"mips": "zr|at|v0|v1|a0|a1|a2|a3|t0|t1|t2|t3|t4|t5|t6|t7|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|ra|hi|lo|bva|epc", "mips": "zr|at|v0|v1|a0|a1|a2|a3|t0|t1|t2|t3|t4|t5|t6|t7|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|ra|hi|lo|bva|epc",
"mips64": "zr|at|v0|v1|a0|a1|a2|a3|a4|a5|a6|a7|t0|t1|t2|t3|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|ra|hi|lo|bva|epc",
"x86": "eax|ebx|ecx|edx|esi|edi|x?cs|x?ds|x?es|x?fs|x?ss|eip|ebp|esp|flags", "x86": "eax|ebx|ecx|edx|esi|edi|x?cs|x?ds|x?es|x?fs|x?ss|eip|ebp|esp|flags",
"x86_64": "rax|rbx|rcx|rdx|rsi|rdi|r8|r9|r10|r11|r12|r13|r14|r15|cs|ss|rip|rbp|rsp|eflags", "x86_64": "rax|rbx|rcx|rdx|rsi|rdi|r8|r9|r10|r11|r12|r13|r14|r15|cs|ss|rip|rbp|rsp|eflags",
"riscv64": "ra|sp|gp|tp|t0|t1|t2|s0|s1|a0|a1|a2|a3|a4|a5|a6|a7|s2|s3|s4|s5|s6|s7|s8|s9|s10|s11|t3|t4|t5|t6|pc",
} }
# We use the "file" command line tool to extract BuildId from ELF files. # We use the "file" command line tool to extract BuildId from ELF files.
@@ -78,14 +78,14 @@ class TraceConverter:
flags=re.DOTALL) flags=re.DOTALL)
def UpdateAbiRegexes(self): def UpdateAbiRegexes(self):
if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64": if symbol.ARCH == "arm64" or symbol.ARCH == "x86_64" or symbol.ARCH == "riscv64":
self.width = "{16}" self.width = "{16}"
self.spacing = " " self.spacing = " "
else: else:
self.width = "{8}" self.width = "{8}"
self.spacing = "" self.spacing = ""
self.register_line = re.compile("(([ ]*\\b(" + self.register_names[symbol.ARCH] + ")\\b +[0-9a-f]" + self.width + "){2,5})") self.register_line = re.compile("(([ ]*\\b(" + self.register_names[symbol.ARCH] + ")\\b +[0-9a-f]" + self.width + "){1,5}$)")
# Note that both trace and value line matching allow for variable amounts of # Note that both trace and value line matching allow for variable amounts of
# whitespace (e.g. \t). This is because the we want to allow for the stack # whitespace (e.g. \t). This is because the we want to allow for the stack
@@ -541,7 +541,7 @@ class TraceConverter:
if nest_count > 0: if nest_count > 0:
nest_count = nest_count - 1 nest_count = nest_count - 1
arrow = "v------>" arrow = "v------>"
if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64": if symbol.ARCH == "arm64" or symbol.ARCH == "x86_64" or symbol.ARCH == "riscv64":
arrow = "v-------------->" arrow = "v-------------->"
self.trace_lines.append((arrow, source_symbol, source_location)) self.trace_lines.append((arrow, source_symbol, source_location))
else: else:
@@ -602,15 +602,15 @@ class RegisterPatternTests(unittest.TestCase):
def test_mips_registers(self): def test_mips_registers(self):
self.assert_register_matches("mips", example_crashes.mips, '\\b(zr|a0|t0|t4|s0|s4|t8|gp|hi)\\b') self.assert_register_matches("mips", example_crashes.mips, '\\b(zr|a0|t0|t4|s0|s4|t8|gp|hi)\\b')
def test_mips64_registers(self):
self.assert_register_matches("mips64", example_crashes.mips64, '\\b(zr|a0|a4|t0|s0|s4|t8|gp|hi)\\b')
def test_x86_registers(self): def test_x86_registers(self):
self.assert_register_matches("x86", example_crashes.x86, '\\b(eax|esi|xcs|eip)\\b') self.assert_register_matches("x86", example_crashes.x86, '\\b(eax|esi|xcs|eip)\\b')
def test_x86_64_registers(self): def test_x86_64_registers(self):
self.assert_register_matches("x86_64", example_crashes.x86_64, '\\b(rax|rsi|r8|r12|cs|rip)\\b') self.assert_register_matches("x86_64", example_crashes.x86_64, '\\b(rax|rsi|r8|r12|cs|rip)\\b')
def test_riscv64_registers(self):
self.assert_register_matches("riscv64", example_crashes.riscv64, '\\b(gp|t2|t6|s3|s7|s11|a3|a7|sp)\\b')
class LibmemunreachablePatternTests(unittest.TestCase): class LibmemunreachablePatternTests(unittest.TestCase):
def test_libmemunreachable(self): def test_libmemunreachable(self):
tc = TraceConverter() tc = TraceConverter()