if not symbol.CHROME_SYMBOLS_DIR: constants.CheckOutputDirectory() print("Reading Android symbols from: " + os.path.normpath(symbol.SYMBOLS_DIR)) chrome_search_path = symbol.GetLibrarySearchPaths() print("Searching for Chrome symbols from within: " + ':'.join( (os.path.normpath(d) for d in chrome_search_path))) rootdir = None if zip_arg: rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) if not arguments or arguments[0] == "-": print "Reading native crash info from stdin" with llvm_symbolizer.LLVMSymbolizer() as symbolizer: stack_core.StreamingConvertTrace(sys.stdin, {}, more_info, fallback_monochrome, arch_defined, symbolizer) else: print "Searching for native crashes in: " + os.path.realpath( arguments[0]) f = open(arguments[0], "r") lines = f.readlines() f.close() version = stack_libs.GetTargetAndroidVersionNumber(lines) if version is None: print("Unknown Android release, " "consider passing --packed-lib.") elif version < _ANDROID_M_MAJOR_VERSION and not packed_libs:
def main(argv, test_symbolizer=None): try: options, arguments = getopt.getopt(argv, "", [ "more-info", "less-info", "chrome-symbols-dir=", "output-directory=", "apks-directory=", "symbols-dir=", "symbols-zip=", "arch=", "fallback-monochrome", "verbose", "quiet", "help", ]) except getopt.GetoptError: PrintUsage() zip_arg = None more_info = False fallback_monochrome = False arch_defined = False apks_directory = None log_level = logging.INFO for option, value in options: if option == "--help": PrintUsage() elif option == "--symbols-dir": symbol.SYMBOLS_DIR = os.path.abspath(os.path.expanduser(value)) elif option == "--symbols-zip": zip_arg = os.path.abspath(os.path.expanduser(value)) elif option == "--arch": symbol.ARCH = value arch_defined = True elif option == "--chrome-symbols-dir": symbol.CHROME_SYMBOLS_DIR = os.path.join(constants.DIR_SOURCE_ROOT, value) elif option == "--output-directory": constants.SetOutputDirectory(os.path.abspath(value)) elif option == "--apks-directory": apks_directory = os.path.abspath(value) elif option == "--more-info": more_info = True elif option == "--less-info": more_info = False elif option == "--fallback-monochrome": fallback_monochrome = True elif option == "--verbose": log_level = logging.DEBUG elif option == "--quiet": log_level = logging.WARNING if len(arguments) > 1: PrintUsage() logging.basicConfig(level=log_level) # Do an up-front test that the output directory is known. if not symbol.CHROME_SYMBOLS_DIR: constants.CheckOutputDirectory() logging.info('Reading Android symbols from: %s', os.path.normpath(symbol.SYMBOLS_DIR)) chrome_search_path = symbol.GetLibrarySearchPaths() logging.info('Searching for Chrome symbols from within: %s', ':'.join( (os.path.normpath(d) for d in chrome_search_path))) rootdir = None if zip_arg: rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) if not arguments or arguments[0] == "-": logging.info( 'Reading native crash info from stdin (symbolization starts ' 'on the first unrelated line or EOF)') with llvm_symbolizer.LLVMSymbolizer() as symbolizer: stack_core.StreamingConvertTrace(sys.stdin, {}, more_info, fallback_monochrome, arch_defined, symbolizer, apks_directory) else: logging.info('Searching for native crashes in: %s', os.path.realpath(arguments[0])) f = open(arguments[0], "r") lines = f.readlines() f.close() # This used to be required when ELF logical addresses did not align with # physical addresses, which happened when relocations were converted to APS2 # format post-link via relocation_packer tool. load_vaddrs = {} with llvm_symbolizer.LLVMSymbolizer() as symbolizer: 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, test_symbolizer or symbolizer, apks_directory) if rootdir: # be a good citizen and clean up...os.rmdir and os.removedirs() don't work cmd = "rm -rf \"%s\"" % rootdir logging.info('cleaning up (%s)', cmd) os.system(cmd)