stack.py: Added support for libmonochrome_64.so and other .so files
You can still have the old behaviour by putting 'libchrome.so' as the
--fallback-so-file argument.
Bug: 1284954
Change-Id: Ibd15dac2fa3805c82657c64c37e93c4d25e5631e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792886
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1029759}
NOKEYCHECK=True
GitOrigin-RevId: 8589ba8f609158a8e6d5b67b0154ba351db64eb5
diff --git a/development/scripts/stack.py b/development/scripts/stack.py
index 0bc8669..53664b1 100755
--- a/development/scripts/stack.py
+++ b/development/scripts/stack.py
@@ -89,10 +89,10 @@
print(" --arch=arm|arm64|x64|x86|mips")
print(" the target architecture")
print()
- print(" --fallback-monochrome")
- print(" fallback to monochrome instead of chrome if fail to detect")
- print(" shared lib which is loaded from APK, this doesn't work for")
- print(" component build.")
+ print(" --fallback-so-file=name")
+ print(" fallback to given .so file (eg. libmonochrome_64.so) instead")
+ print(" of libmonochrome.so if we fail to detect the shared lib which")
+ print(" is loaded from APK, this doesn't work for component build.")
print()
print(" --quiet")
print(" Show less logging")
@@ -149,7 +149,7 @@
options, arguments = getopt.getopt(argv, "p", [
"pass-through", "more-info", "less-info", "chrome-symbols-dir=",
"output-directory=", "apks-directory=", "symbols-dir=", "symbols-zip=",
- "arch=", "fallback-monochrome", "verbose", "quiet", "help",
+ "arch=", "fallback-so-file=", "verbose", "quiet", "help",
])
except getopt.GetoptError:
PrintUsage()
@@ -157,7 +157,7 @@
pass_through = False
zip_arg = None
more_info = False
- fallback_monochrome = False
+ fallback_so_file = None
arch_defined = False
apks_directory = None
log_level = logging.INFO
@@ -185,8 +185,8 @@
more_info = True
elif option == "--less-info":
more_info = False
- elif option == "--fallback-monochrome":
- fallback_monochrome = True
+ elif option == "--fallback-so-file":
+ fallback_so_file = value
elif option == "--verbose":
log_level = logging.DEBUG
elif option == "--quiet":
@@ -215,7 +215,7 @@
'on the first unrelated line or EOF)')
with llvm_symbolizer.LLVMSymbolizer() as symbolizer:
stack_core.StreamingConvertTrace(sys.stdin, {}, more_info,
- fallback_monochrome, arch_defined,
+ fallback_so_file, arch_defined,
symbolizer, apks_directory, pass_through)
else:
logging.info('Searching for native crashes in: %s',
@@ -238,7 +238,7 @@
logging.info('Searching for Chrome symbols from within: %s',
':'.join((os.path.normpath(d) for d in chrome_search_path)))
stack_core.ConvertTrace(lines, load_vaddrs, more_info,
- fallback_monochrome, arch_defined,
+ fallback_so_file, arch_defined,
test_symbolizer or symbolizer, apks_directory)
if rootdir:
diff --git a/development/scripts/stack_core.py b/development/scripts/stack_core.py
index 0d04f16..545fcf4 100755
--- a/development/scripts/stack_core.py
+++ b/development/scripts/stack_core.py
@@ -37,8 +37,7 @@
_DEFAULT_JOBS=8
_CHUNK_SIZE = 1000
-_BASE_APK = 'base.apk'
-_FALLBACK_SO = 'libchrome.so'
+_FALLBACK_SO = 'libmonochrome.so'
# pylint: disable=line-too-long
@@ -164,14 +163,14 @@
print('-----------------------------------------------------\n')
-def StreamingConvertTrace(_, load_vaddrs, more_info, fallback_monochrome,
+def StreamingConvertTrace(_, load_vaddrs, more_info, fallback_so_file,
arch_defined, llvm_symbolizer, apks_directory,
pass_through):
"""Symbolize stacks on the fly as they are read from an input stream."""
- if fallback_monochrome:
+ if fallback_so_file:
global _FALLBACK_SO
- _FALLBACK_SO = 'libmonochrome.so'
+ _FALLBACK_SO = fallback_so_file
useful_lines = []
so_dirs = []
in_stack = False
@@ -210,13 +209,13 @@
ConvertStreamingChunk()
-def ConvertTrace(lines, load_vaddrs, more_info, fallback_monochrome,
- arch_defined, llvm_symbolizer, apks_directory):
+def ConvertTrace(lines, load_vaddrs, more_info, fallback_so_file, arch_defined,
+ llvm_symbolizer, apks_directory):
"""Convert strings containing native crash to a stack."""
- if fallback_monochrome:
+ if fallback_so_file:
global _FALLBACK_SO
- _FALLBACK_SO = 'libmonochrome.so'
+ _FALLBACK_SO = fallback_so_file
start = time.time()
chunks = [lines[i: i+_CHUNK_SIZE] for i in range(0, len(lines), _CHUNK_SIZE)]
@@ -363,7 +362,7 @@
# APK name with _FALLBACK_SO, unless an APKs directory was
# explicitly specified (in which case, the correct .so should always
# be identified, and using a fallback could be misleading).
- line = line.replace('/' + _BASE_APK, '/' + _FALLBACK_SO)
+ line = line.replace('.apk', '.apk/' + _FALLBACK_SO)
logging.debug("Can't detect shared library in APK, fallback to" +
" library " + _FALLBACK_SO)
# For trace lines specifically, the address may need to be adjusted