Updating stack_core.py to recognize new ABI output from debuggerd.
Change-Id: Ib9736a0509edb97be15f5e89dbc3a5188e744416
This commit is contained in:
committed by
Elliott Hughes
parent
9649c415e7
commit
45a46c6138
@@ -23,9 +23,12 @@ import symbol
|
|||||||
def PrintTraceLines(trace_lines):
|
def PrintTraceLines(trace_lines):
|
||||||
"""Print back trace."""
|
"""Print back trace."""
|
||||||
maxlen = max(map(lambda tl: len(tl[1]), trace_lines))
|
maxlen = max(map(lambda tl: len(tl[1]), trace_lines))
|
||||||
|
spacing = ""
|
||||||
|
if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64":
|
||||||
|
spacing = " "
|
||||||
print
|
print
|
||||||
print "Stack Trace:"
|
print "Stack Trace:"
|
||||||
print " RELADDR " + "FUNCTION".ljust(maxlen) + " FILE:LINE"
|
print " RELADDR " + spacing + "FUNCTION".ljust(maxlen) + " FILE:LINE"
|
||||||
for tl in trace_lines:
|
for tl in trace_lines:
|
||||||
(addr, symbol_with_offset, location) = tl
|
(addr, symbol_with_offset, location) = tl
|
||||||
print " %8s %s %s" % (addr, symbol_with_offset.ljust(maxlen), location)
|
print " %8s %s %s" % (addr, symbol_with_offset.ljust(maxlen), location)
|
||||||
@@ -58,19 +61,34 @@ def PrintDivider():
|
|||||||
print
|
print
|
||||||
print "-----------------------------------------------------\n"
|
print "-----------------------------------------------------\n"
|
||||||
|
|
||||||
|
def CleanLine(ln):
|
||||||
|
# AndroidFeedback adds zero width spaces into its crash reports. These
|
||||||
|
# should be removed or the regular expresssions will fail to match.
|
||||||
|
return unicode(ln, errors='ignore')
|
||||||
|
|
||||||
def ConvertTrace(lines):
|
def ConvertTrace(lines):
|
||||||
"""Convert strings containing native crash to a stack."""
|
"""Convert strings containing native crash to a stack."""
|
||||||
|
lines = map(CleanLine, lines)
|
||||||
|
|
||||||
process_info_line = re.compile("(pid: [0-9]+, tid: [0-9]+.*)")
|
process_info_line = re.compile("(pid: [0-9]+, tid: [0-9]+.*)")
|
||||||
|
abi_line = re.compile("(ABI: \'(.*)\')")
|
||||||
signal_line = re.compile("(signal [0-9]+ \(.*\).*)")
|
signal_line = re.compile("(signal [0-9]+ \(.*\).*)")
|
||||||
register_line = re.compile("(([ ]*[0-9a-z]{2} [0-9a-f]{8}){4})")
|
|
||||||
thread_line = re.compile("(.*)(\-\-\- ){15}\-\-\-")
|
thread_line = re.compile("(.*)(\-\-\- ){15}\-\-\-")
|
||||||
dalvik_jni_thread_line = re.compile("(\".*\" prio=[0-9]+ tid=[0-9]+ NATIVE.*)")
|
dalvik_jni_thread_line = re.compile("(\".*\" prio=[0-9]+ tid=[0-9]+ NATIVE.*)")
|
||||||
dalvik_native_thread_line = re.compile("(\".*\" sysTid=[0-9]+ nice=[0-9]+.*)")
|
dalvik_native_thread_line = re.compile("(\".*\" sysTid=[0-9]+ nice=[0-9]+.*)")
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
abi_header = abi_line.search(line)
|
||||||
|
if abi_header:
|
||||||
|
symbol.ARCH = abi_header.group(2)
|
||||||
|
break
|
||||||
|
|
||||||
width = "{8}"
|
width = "{8}"
|
||||||
if symbol.ARCH == "arm64" or symbol.ARCH == "x86_64":
|
if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64":
|
||||||
width = "{16}"
|
width = "{16}"
|
||||||
|
|
||||||
|
register_line = re.compile("(([ ]*[0-9a-z]{2} +[0-9a-f]" + width + "){4})")
|
||||||
|
|
||||||
# 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
|
||||||
# tool to operate on AndroidFeedback provided system logs. AndroidFeedback
|
# tool to operate on AndroidFeedback provided system logs. AndroidFeedback
|
||||||
@@ -107,17 +125,15 @@ def ConvertTrace(lines):
|
|||||||
value_lines = []
|
value_lines = []
|
||||||
last_frame = -1
|
last_frame = -1
|
||||||
|
|
||||||
for ln in lines:
|
for line in lines:
|
||||||
# AndroidFeedback adds zero width spaces into its crash reports. These
|
|
||||||
# should be removed or the regular expresssions will fail to match.
|
|
||||||
line = unicode(ln, errors='ignore')
|
|
||||||
process_header = process_info_line.search(line)
|
process_header = process_info_line.search(line)
|
||||||
signal_header = signal_line.search(line)
|
signal_header = signal_line.search(line)
|
||||||
register_header = register_line.search(line)
|
|
||||||
thread_header = thread_line.search(line)
|
thread_header = thread_line.search(line)
|
||||||
|
register_header = register_line.search(line)
|
||||||
|
abi_header = abi_line.search(line)
|
||||||
dalvik_jni_thread_header = dalvik_jni_thread_line.search(line)
|
dalvik_jni_thread_header = dalvik_jni_thread_line.search(line)
|
||||||
dalvik_native_thread_header = dalvik_native_thread_line.search(line)
|
dalvik_native_thread_header = dalvik_native_thread_line.search(line)
|
||||||
if process_header or signal_header or register_header or thread_header \
|
if process_header or signal_header or thread_header or abi_header or register_header\
|
||||||
or dalvik_jni_thread_header or dalvik_native_thread_header:
|
or dalvik_jni_thread_header or dalvik_native_thread_header:
|
||||||
if trace_lines or value_lines:
|
if trace_lines or value_lines:
|
||||||
PrintOutput(trace_lines, value_lines)
|
PrintOutput(trace_lines, value_lines)
|
||||||
@@ -137,6 +153,8 @@ def ConvertTrace(lines):
|
|||||||
print dalvik_jni_thread_header.group(1)
|
print dalvik_jni_thread_header.group(1)
|
||||||
if dalvik_native_thread_header:
|
if dalvik_native_thread_header:
|
||||||
print dalvik_native_thread_header.group(1)
|
print dalvik_native_thread_header.group(1)
|
||||||
|
if abi_header:
|
||||||
|
print abi_header.group(1)
|
||||||
continue
|
continue
|
||||||
if trace_line.match(line):
|
if trace_line.match(line):
|
||||||
match = trace_line.match(line)
|
match = trace_line.match(line)
|
||||||
|
|||||||
@@ -78,20 +78,21 @@ def FindToolchain():
|
|||||||
if TOOLCHAIN_INFO is not None:
|
if TOOLCHAIN_INFO is not None:
|
||||||
return TOOLCHAIN_INFO
|
return TOOLCHAIN_INFO
|
||||||
|
|
||||||
|
# TODO: TARGET_GCC_VERSION is the version for the primary architecture.
|
||||||
|
gcc_version = os.environ["TARGET_GCC_VERSION"]
|
||||||
|
|
||||||
## Known toolchains, newer ones in the front.
|
## Known toolchains, newer ones in the front.
|
||||||
if ARCH == "arm64":
|
if ARCH == "arm":
|
||||||
gcc_version = os.environ["TARGET_GCC_VERSION"]
|
|
||||||
known_toolchains = [
|
|
||||||
("aarch64-linux-android-" + gcc_version, "aarch64", "aarch64-linux-android")
|
|
||||||
]
|
|
||||||
elif ARCH == "arm":
|
|
||||||
gcc_version = os.environ["TARGET_GCC_VERSION"]
|
|
||||||
known_toolchains = [
|
known_toolchains = [
|
||||||
("arm-linux-androideabi-" + gcc_version, "arm", "arm-linux-androideabi"),
|
("arm-linux-androideabi-" + gcc_version, "arm", "arm-linux-androideabi"),
|
||||||
]
|
]
|
||||||
elif ARCH =="x86":
|
elif ARCH == "arm64":
|
||||||
known_toolchains = [
|
known_toolchains = [
|
||||||
("i686-android-linux-4.4.3", "x86", "i686-android-linux")
|
("aarch64-linux-android-" + gcc_version, "aarch64", "aarch64-linux-android")
|
||||||
|
]
|
||||||
|
elif ARCH =="x86" or ARCH == "x86_64":
|
||||||
|
known_toolchains = [
|
||||||
|
("i686-android-linux" + gcc_version, "x86", "i686-android-linux")
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
known_toolchains = []
|
known_toolchains = []
|
||||||
@@ -101,10 +102,10 @@ def FindToolchain():
|
|||||||
toolchain_info = (label, platform, target);
|
toolchain_info = (label, platform, target);
|
||||||
if os.path.exists(ToolPath("addr2line", toolchain_info)):
|
if os.path.exists(ToolPath("addr2line", toolchain_info)):
|
||||||
TOOLCHAIN_INFO = toolchain_info
|
TOOLCHAIN_INFO = toolchain_info
|
||||||
print "Using toolchain from :" + ToolPath("", TOOLCHAIN_INFO)
|
print "Using toolchain from: " + ToolPath("", TOOLCHAIN_INFO)
|
||||||
return toolchain_info
|
return toolchain_info
|
||||||
|
|
||||||
raise Exception("Could not find tool chain")
|
raise Exception("Could not find tool chain for (%s, %s, %s)" % (label, platform, target))
|
||||||
|
|
||||||
def SymbolInformation(lib, addr):
|
def SymbolInformation(lib, addr):
|
||||||
"""Look up symbol information about an address.
|
"""Look up symbol information about an address.
|
||||||
|
|||||||
Reference in New Issue
Block a user