def LoadAndPostProcessSizeInfo(path): """Returns a SizeInfo for the given |path|.""" logging.debug('Loading results from: %s', path) size_info = file_format.LoadSizeInfo(path) logging.info('Normalizing symbol names') _NormalizeNames(size_info.raw_symbols) logging.info('Calculating padding') _CalculatePadding(size_info.raw_symbols) logging.info('Loaded %d symbols', len(size_info.raw_symbols)) return size_info
def Analyze(path, lazy_paths=None): """Returns a SizeInfo for the given |path|. Args: path: Can be a .size file, or a .map(.gz). If the latter, then lazy_paths must be provided as well. """ if path.endswith('.size'): logging.debug('Loading results from: %s', path) size_info = file_format.LoadSizeInfo(path) # Recompute derived values (padding and function names). logging.info('Calculating padding') _RemoveDuplicatesAndCalculatePadding(size_info.symbols) logging.info('Deriving signatures') # Re-parse out function parameters. _NormalizeNames(size_info.symbols) return size_info elif not path.endswith('.map') and not path.endswith('.map.gz'): raise Exception('Expected input to be a .map or a .size') else: # output_directory needed for source file information. lazy_paths.VerifyOutputDirectory() # tool_prefix needed for c++filt. lazy_paths.VerifyToolPrefix() with _OpenMaybeGz(path) as map_file: section_sizes, symbols = linker_map_parser.MapFileParser().Parse( map_file) size_info = models.SizeInfo(section_sizes, models.SymbolGroup(symbols)) # Map file for some reason doesn't unmangle all names. logging.info('Calculating padding') _RemoveDuplicatesAndCalculatePadding(size_info.symbols) # Unmangle prints its own log statement. _UnmangleRemainingSymbols(size_info.symbols, lazy_paths.tool_prefix) logging.info('Extracting source paths from .ninja files') all_found = _ExtractSourcePaths(size_info.symbols, lazy_paths.output_directory) assert all_found, ( 'One or more source file paths could not be found. Likely caused by ' '.ninja files being generated at a different time than the .map file.' ) # Resolve paths prints its own log statement. logging.info('Normalizing names') _NormalizeNames(size_info.symbols) logging.info('Normalizing paths') _NormalizeObjectPaths(size_info.symbols) if logging.getLogger().isEnabledFor(logging.INFO): for line in describe.DescribeSizeInfoCoverage(size_info): logging.info(line) logging.info('Finished analyzing %d symbols', len(size_info.symbols)) return size_info
def Analyze(path, output_directory=None, tool_prefix=''): if path.endswith('.size'): logging.debug('Loading results from: %s', path) size_info = file_format.LoadSizeInfo(path) # Recompute derived values (padding and function names). logging.info('Calculating padding') _RemoveDuplicatesAndCalculatePadding(size_info.symbols) logging.info('Deriving signatures') # Re-parse out function parameters. _NormalizeNames(size_info.symbols) return size_info elif not path.endswith('.map') and not path.endswith('.map.gz'): raise Exception('Expected input to be a .map or a .size') else: # Verify tool_prefix early. output_directory, tool_prefix = (_DetectToolPrefix( tool_prefix, path, output_directory)) with _OpenMaybeGz(path) as map_file: section_sizes, symbols = linker_map_parser.MapFileParser().Parse( map_file) timestamp = datetime.datetime.utcfromtimestamp(os.path.getmtime(path)) size_info = models.SizeInfo(section_sizes, models.SymbolGroup(symbols), timestamp=timestamp) # Map file for some reason doesn't unmangle all names. logging.info('Calculating padding') _RemoveDuplicatesAndCalculatePadding(size_info.symbols) # Unmangle prints its own log statement. _UnmangleRemainingSymbols(size_info.symbols, tool_prefix) logging.info('Extracting source paths from .ninja files') _ExtractSourcePaths(size_info.symbols, output_directory) # Resolve paths prints its own log statement. logging.info('Normalizing names') _NormalizeNames(size_info.symbols) logging.info('Normalizing paths') _NormalizeObjectPaths(size_info.symbols) if logging.getLogger().isEnabledFor(logging.INFO): for line in describe.DescribeSizeInfoCoverage(size_info): logging.info(line) logging.info('Finished analyzing %d symbols', len(size_info.symbols)) return size_info
def LoadAndPostProcessSizeInfo(path): """Returns a SizeInfo for the given |path|.""" logging.debug('Loading results from: %s', path) size_info = file_format.LoadSizeInfo(path) _PostProcessSizeInfo(size_info) return size_info