def main(argv): parser = argparse.ArgumentParser() parser.add_argument('inputs', nargs='+', help='Input .size files to load. For a single file, ' 'it will be mapped to variables as: size_info & ' 'symbols (where symbols = size_info.symbols). For ' 'multiple inputs, the names will be size_info1, ' 'symbols1, etc.') parser.add_argument('--query', help='Print the result of the given snippet. Example: ' 'symbols.WhereInSection("d").' 'WhereBiggerThan(100)') paths.AddOptions(parser) args = helpers.AddCommonOptionsAndParseArgs(parser, argv) for path in args.inputs: if not path.endswith('.size'): parser.error('All inputs must end with ".size"') size_infos = [map2size.Analyze(p) for p in args.inputs] lazy_paths = paths.LazyPaths(args=args, input_file=args.inputs[0]) session = _Session(size_infos, lazy_paths) if args.query: logging.info('Running query from command-line.') session.Eval(args.query) else: logging.info('Entering interactive console.') session.GoInteractive()
def test_Map2Size(self): with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: _RunApp('map2size.py', '--output-directory', _TEST_DATA_DIR, '--map-file', _TEST_MAP_PATH, '', temp_file.name) size_info = map2size.Analyze(temp_file.name) sym_strs = (repr(sym) for sym in size_info.symbols) stats = describe.DescribeSizeInfoCoverage(size_info) return itertools.chain(stats, sym_strs)
def main(argv): parser = argparse.ArgumentParser() parser.add_argument('input_file', help='Path to input file. Can be a linker .map file, or ' 'a .size file.') parser.add_argument('--report-dir', metavar='PATH', required=True, help='Write output to the specified directory. An HTML ' 'report is generated here.') parser.add_argument('--include-bss', action='store_true', help='Include symbols from .bss (which consume no real ' 'space)') parser.add_argument('--include-symbols', action='store_true', help='Use per-symbol granularity rather than per-file.') paths.AddOptions(parser) args = helpers.AddCommonOptionsAndParseArgs(parser, argv) lazy_paths = paths.LazyPaths(args=args, input_file=args.input_file) size_info = map2size.Analyze(args.input_file, lazy_paths) symbols = size_info.symbols if not args.include_bss: symbols = symbols.WhereInSection('b').Inverted() symbols = symbols.WhereBiggerThan(0) # Copy report boilerplate into output directory. This also proves that the # output directory is safe for writing, so there should be no problems writing # the nm.out file later. _CopyTemplateFiles(args.report_dir) logging.info('Creating JSON objects') tree_root = _MakeCompactTree(symbols, args.include_symbols) logging.info('Serializing') with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file: out_file.write('var tree_data=') # Use separators without whitespace to get a smaller file. json.dump(tree_root, out_file, ensure_ascii=False, check_circular=False, separators=(',', ':')) print 'Report saved to ' + args.report_dir + '/index.html'
def _CloneSizeInfo(self): if not IntegrationTest.size_info: lazy_paths = paths.LazyPaths(output_directory=_TEST_DATA_DIR) IntegrationTest.size_info = map2size.Analyze( _TEST_MAP_PATH, lazy_paths) return copy.deepcopy(IntegrationTest.size_info)
def _GetParsedMap(self): if not IntegrationTest.size_info: IntegrationTest.size_info = map2size.Analyze( _TEST_MAP_PATH, output_directory=_TEST_DATA_DIR) return copy.deepcopy(IntegrationTest.size_info)