From 8caeef1819b584f81077809008e699537dd33461 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 31 Oct 2019 13:58:56 +1100 Subject: [PATCH] symbols: add a symbol installation script --- .gitignore | 3 +++ symbols.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 symbols.py diff --git a/.gitignore b/.gitignore index 053d330..a9a2842 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ /release /sanitizer /tidy + +/dumps +/symbols diff --git a/symbols.py b/symbols.py new file mode 100755 index 0000000..af0bd23 --- /dev/null +++ b/symbols.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +""" +Installs a provided symbol file into the symbols repository at the correct +subdirectory for `minidump_stackwalk` to automatically find. +""" + +if __name__ == '__main__': + import argparse + import os + import shutil + import sys + + def main(): + default_dst = os.path.join( + os.path.dirname( + os.path.realpath(__file__) + ), + "symbols" + ) + + parser = argparse.ArgumentParser() + parser.add_argument('--dst', dest='dst', type=str, required=False, default=default_dst) + parser.add_argument('src', type=str) + + args = parser.parse_args() + + with open(args.src) as f: + header = f.readline() + + field, system, arch, id, name = header.strip().split(' ') + print(f"Installing {name}: {id}", file=sys.stderr) + + dst_dir = os.path.join(args.dst, name, id) + os.makedirs(dst_dir, exist_ok=True) + + dst_path = os.path.join(dst_dir, f"{name}.sym") + shutil.copyfile(args.src, dst_path) + + main()