From 409282b77fa6fa4c8ebefe54473fe75fcbe3965f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 9 Sep 2021 17:51:50 -0700 Subject: [PATCH] stack: add support for a .zip of symbols. This is the one remaining feature in vendor/google/tools/stack that isn't in the "One True" stack script. Bug: http://b/199390145 Test: manual Change-Id: I9dd832f6fb5767c3ad3263c1ffc7dfdb0103e535 --- scripts/stack | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/stack b/scripts/stack index aaa32f417..718f49c0e 100755 --- a/scripts/stack +++ b/scripts/stack @@ -17,7 +17,11 @@ """stack symbolizes native crash dumps.""" import argparse +import atexit +import glob import sys +import tempfile +import zipfile import stack_core import symbol @@ -25,7 +29,9 @@ import symbol def main(): parser = argparse.ArgumentParser(description='Parse and symbolize crashes') parser.add_argument('--arch', help='the target architecture') - parser.add_argument('--syms', '--symdir', help='the symbols directory') + group = parser.add_mutually_exclusive_group() + group.add_argument('--symbols-dir', '--syms', '--symdir', help='the symbols directory') + group.add_argument('--symbols-zip', help='the symbols.zip file from a build') parser.add_argument('file', metavar='FILE', default='-', @@ -36,11 +42,16 @@ def main(): 'or if file is -, it reads from stdin.') args = parser.parse_args() - if args.arch: symbol.ARCH = args.arch - if args.syms: - symbol.SYMBOLS_DIR = args.syms + if args.symbols_dir: + symbol.SYMBOLS_DIR = args.symbols_dir + if args.symbols_zip: + tmp = tempfile.TemporaryDirectory() + atexit.register(tmp.cleanup) + with zipfile.ZipFile(args.symbols_zip) as zf: + zf.extractall(tmp.name) + symbol.SYMBOLS_DIR = glob.glob("%s/out/target/product/*/symbols" % tmp.name)[0] if args.file == '-': print("Reading native crash info from stdin") f = sys.stdin