Skip to content

Commit

Permalink
[Android] Update android_platform stack tool to understand arm64, x86…
Browse files Browse the repository at this point in the history
…_64 and mips stacks

Pulls in some changes from the Android repo to enable symbolisation of arm64,
x86_64 and mips stack traces.  Also updates some of our local modifications to
deal with 64 bit addresses.

BUG=354405, 346626
NOTRY=true

Review URL: https://codereview.chromium.org/267683006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268475 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rmcilroy@chromium.org committed May 6, 2014
1 parent 95092d6 commit b863ab1
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
4 changes: 2 additions & 2 deletions third_party/android_platform/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Name: Android Platform engineering tools
Short Name: android platform development
URL: https://android.googlesource.com/platform/development
Version: 0
Date: 2013/07/03
Revision: f56a37e
Date: 2014/05/02
Revision: 1b10ec4
License: Apache 2.0
License File: NOT_SHIPPED
Security Critical: no
Expand Down
2 changes: 1 addition & 1 deletion third_party/android_platform/development/scripts/stack
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def PrintUsage():
print " argument information. Also, the 'stack data' section will be"
print " printed."
print
print " --arch=arm|x86"
print " --arch=arm|arm64|x86_64|x86|mips"
print " the target architecture"
print
print " FILE should contain a stack trace in it somewhere"
Expand Down
26 changes: 20 additions & 6 deletions third_party/android_platform/development/scripts/stack_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ def ConvertTrace(lines, more_info):
thread_line = re.compile("(.*)(\-\-\- ){15}\-\-\-")
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]+.*)")

width = "{8}"
if symbol.ARCH == "arm64" or symbol.ARCH == "x86_64":
width = "{16}"

# Matches LOG(FATAL) lines, like the following example:
# [FATAL:source_file.cc(33)] Check failed: !instances_.empty()
log_fatal_line = re.compile("(\[FATAL\:.*\].*)$")

# 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
# tool to operate on AndroidFeedback provided system logs. AndroidFeedback
Expand All @@ -86,28 +92,36 @@ def ConvertTrace(lines, more_info):
# Or lines from AndroidFeedback crash report system logs like:
# 03-25 00:51:05.520 I/DEBUG ( 65): #00 pc 001cf42e /data/data/com.my.project/lib/libmyproject.so
# Please note the spacing differences.
trace_line = re.compile("(.*)\#(?P<frame>[0-9]+)[ \t]+(..)[ \t]+(0x)?(?P<address>[0-9a-f]{0,8})[ \t]+(?P<lib>[^\r\n \t]*)(?P<symbol_present> \((?P<symbol_name>.*)\))?") # pylint: disable-msg=C6310
trace_line = re.compile("(.*)\#(?P<frame>[0-9]+)[ \t]+(..)[ \t]+(0x)?(?P<address>[0-9a-f]{0,16})[ \t]+(?P<lib>[^\r\n \t]*)(?P<symbol_present> \((?P<symbol_name>.*)\))?") # pylint: disable-msg=C6310

# Matches lines emitted by src/base/debug/stack_trace_android.cc, like:
# #00 0x7324d92d /data/app-lib/org.chromium.native_test-1/libbase.cr.so+0x0006992d
# This pattern includes the unused named capture groups <symbol_present> and
# <symbol_name> so that it can interoperate with the |trace_line| regex.
debug_trace_line = re.compile('(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) '
'(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]{8,8})'
'(?P<symbol_present>)(?P<symbol_name>)')
debug_trace_line = re.compile(
'(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]' + width + ') '
'(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]' + width + ')'
'(?P<symbol_present>)(?P<symbol_name>)')

# Examples of matched value lines include:
# bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so
# bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so (symbol)
# 03-25 00:51:05.530 I/DEBUG ( 65): bea4170c 8018e4e9 /data/data/com.my.project/lib/libmyproject.so
# Again, note the spacing differences.
value_line = re.compile("(.*)([0-9a-f]{8})[ \t]+([0-9a-f]{8})[ \t]+([^\r\n \t]*)( \((.*)\))?")
value_line = re.compile("(.*)([0-9a-f]" + width + ")[ \t]+([0-9a-f]" + width + ")[ \t]+([^\r\n \t]*)( \((.*)\))?")
# Lines from 'code around' sections of the output will be matched before
# value lines because otheriwse the 'code around' sections will be confused as
# value lines.
#
# Examples include:
# 801cf40c ffffc4cc 00b2f2c5 00b2f1c7 00c1e1a8
# 03-25 00:51:05.530 I/DEBUG ( 65): 801cf40c ffffc4cc 00b2f2c5 00b2f1c7 00c1e1a8
code_line = re.compile("(.*)[ \t]*[a-f0-9]{8}[ \t]*[a-f0-9]{8}[ \t]*[a-f0-9]{8}[ \t]*[a-f0-9]{8}[ \t]*[a-f0-9]{8}[ \t]*[ \r\n]") # pylint: disable-msg=C6310
code_line = re.compile("(.*)[ \t]*[a-f0-9]" + width +
"[ \t]*[a-f0-9]" + width +
"[ \t]*[a-f0-9]" + width +
"[ \t]*[a-f0-9]" + width +
"[ \t]*[a-f0-9]" + width +
"[ \t]*[ \r\n]") # pylint: disable-msg=C6310

trace_lines = []
value_lines = []
Expand Down
42 changes: 37 additions & 5 deletions third_party/android_platform/development/scripts/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,29 @@ def ToolPath(tool, toolchain_info=None):
if ARCH == "arm":
toolchain_source = "arm-linux-androideabi-4.6"
toolchain_prefix = "arm-linux-androideabi"
else:
ndk = "ndk"
elif ARCH == "arm64":
toolchain_source = "aarch64-linux-android-4.8"
toolchain_prefix = "aarch64-linux-android"
ndk = "ndk_experimental"
elif ARCH == "x86":
toolchain_source = "x86-4.6"
toolchain_prefix = "i686-android-linux"
ndk = "ndk"
elif ARCH == "x86_64":
toolchain_source = "x86_64-4.8"
toolchain_prefix = "x86_64-linux-android"
ndk = "ndk_experimental"
elif ARCH == "mips":
toolchain_source = "mipsel-linux-android-4.6"
toolchain_prefix = "mipsel-linux-android"
ndk = "ndk"
else:
raise Exception("Could not find tool chain")

toolchain_subdir = (
"third_party/android_tools/ndk/toolchains/%s/prebuilt/linux-x86_64/bin" %
toolchain_source)
"third_party/android_tools/%s/toolchains/%s/prebuilt/linux-x86_64/bin" %
(ndk, toolchain_source))

return os.path.join(CHROME_SRC,
toolchain_subdir,
Expand All @@ -78,14 +94,29 @@ def FindToolchain():
return TOOLCHAIN_INFO

## Known toolchains, newer ones in the front.
if ARCH == "arm":
if ARCH == "arm64":
gcc_version = "4.8"
known_toolchains = [
("aarch64-linux-android-" + gcc_version, "aarch64", "aarch64-linux-android")
]
elif ARCH == "arm":
gcc_version = "4.6"
known_toolchains = [
("arm-linux-androideabi-4.6", "arm", "arm-linux-androideabi"),
("arm-linux-androideabi-" + gcc_version, "arm", "arm-linux-androideabi"),
]
elif ARCH =="x86":
known_toolchains = [
("i686-android-linux-4.4.3", "x86", "i686-android-linux")
]
elif ARCH =="x86_64":
known_toolchains = [
("x86_64-linux-android-4.8", "x86_64", "x86_64-linux-android")
]
elif ARCH == "mips":
gcc_version = "4.6"
known_toolchains = [
("mipsel-linux-android-" + gcc_version, "mips", "mipsel-linux-android")
]
else:
known_toolchains = []

Expand All @@ -94,6 +125,7 @@ def FindToolchain():
toolchain_info = (label, platform, target);
if os.path.exists(ToolPath("addr2line", toolchain_info)):
TOOLCHAIN_INFO = toolchain_info
print "Using toolchain from :" + ToolPath("", TOOLCHAIN_INFO)
return toolchain_info

raise Exception("Could not find tool chain")
Expand Down

0 comments on commit b863ab1

Please sign in to comment.