def load(path, log_header='Loading a heap profile dump: '): """Loads a heap profile dump. Args: path: A file path string to load. log_header: A preceding string for log messages. Returns: A loaded Dump object. Raises: ParsingException for invalid heap profile dumps. """ dump = Dump(path, os.stat(path).st_mtime) with open(path, 'r') as f: dump.load_file(f, log_header) return dump
def load_basic_files(dump_path, multiple, no_dump=False, alternative_dirs=None): prefix = SubCommand._find_prefix(dump_path) # If the target process is estimated to be working on Android, converts # a path in the Android device to a path estimated to be corresponding in # the host. Use --alternative-dirs to specify the conversion manually. if not alternative_dirs: alternative_dirs = SubCommand._estimate_alternative_dirs(prefix) if alternative_dirs: for device, host in alternative_dirs.iteritems(): LOGGER.info('Assuming %s on device as %s on host' % (device, host)) symbol_data_sources = SymbolDataSources(prefix, alternative_dirs) symbol_data_sources.prepare() bucket_set = BucketSet() bucket_set.load(prefix) if not no_dump: if multiple: dump_list = DumpList.load( SubCommand._find_all_dumps(dump_path)) else: dump = Dump.load(dump_path) symbol_mapping_cache = SymbolMappingCache() with open(prefix + '.cache.function', 'a+') as cache_f: symbol_mapping_cache.update( FUNCTION_SYMBOLS, bucket_set, SymbolFinder(FUNCTION_SYMBOLS, symbol_data_sources), cache_f) with open(prefix + '.cache.typeinfo', 'a+') as cache_f: symbol_mapping_cache.update( TYPEINFO_SYMBOLS, bucket_set, SymbolFinder(TYPEINFO_SYMBOLS, symbol_data_sources), cache_f) with open(prefix + '.cache.sourcefile', 'a+') as cache_f: symbol_mapping_cache.update( SOURCEFILE_SYMBOLS, bucket_set, SymbolFinder(SOURCEFILE_SYMBOLS, symbol_data_sources), cache_f) bucket_set.symbolize(symbol_mapping_cache) if no_dump: return bucket_set elif multiple: return (bucket_set, dump_list) else: return (bucket_set, dump)
def load_basic_files( dump_path, multiple, no_dump=False, alternative_dirs=None): prefix = SubCommand._find_prefix(dump_path) # If the target process is estimated to be working on Android, converts # a path in the Android device to a path estimated to be corresponding in # the host. Use --alternative-dirs to specify the conversion manually. if not alternative_dirs: alternative_dirs = SubCommand._estimate_alternative_dirs(prefix) if alternative_dirs: for device, host in alternative_dirs.iteritems(): LOGGER.info('Assuming %s on device as %s on host' % (device, host)) symbol_data_sources = SymbolDataSources(prefix, alternative_dirs) symbol_data_sources.prepare() bucket_set = BucketSet() bucket_set.load(prefix) if not no_dump: if multiple: dump_list = DumpList.load(SubCommand._find_all_dumps(dump_path)) else: dump = Dump.load(dump_path) symbol_mapping_cache = SymbolMappingCache() with open(prefix + '.cache.function', 'a+') as cache_f: symbol_mapping_cache.update( FUNCTION_SYMBOLS, bucket_set, SymbolFinder(FUNCTION_SYMBOLS, symbol_data_sources), cache_f) with open(prefix + '.cache.typeinfo', 'a+') as cache_f: symbol_mapping_cache.update( TYPEINFO_SYMBOLS, bucket_set, SymbolFinder(TYPEINFO_SYMBOLS, symbol_data_sources), cache_f) with open(prefix + '.cache.sourcefile', 'a+') as cache_f: symbol_mapping_cache.update( SOURCEFILE_SYMBOLS, bucket_set, SymbolFinder(SOURCEFILE_SYMBOLS, symbol_data_sources), cache_f) bucket_set.symbolize(symbol_mapping_cache) if no_dump: return bucket_set elif multiple: return (bucket_set, dump_list) else: return (bucket_set, dump)