Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: tools/binary_size/libsupersize/console.py

Issue 2888693002: supersize: Add Print(idx). Sort subgroups in canned_queries. (Closed)
Patch Set: supersize: Add Print(idx). Sort subgroups in canned_queries. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """An interactive console for looking analyzing .size files.""" 5 """An interactive console for looking analyzing .size files."""
6 6
7 import argparse 7 import argparse
8 import atexit 8 import atexit
9 import code 9 import code
10 import contextlib 10 import contextlib
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ret.symbols = ret.symbols.Sorted() 103 ret.symbols = ret.symbols.Sorted()
104 return ret 104 return ret
105 105
106 def _PrintFunc(self, obj=None, verbose=False, recursive=False, use_pager=None, 106 def _PrintFunc(self, obj=None, verbose=False, recursive=False, use_pager=None,
107 to_file=None): 107 to_file=None):
108 """Prints out the given Symbol / SymbolGroup / SymbolDiff / SizeInfo. 108 """Prints out the given Symbol / SymbolGroup / SymbolDiff / SizeInfo.
109 109
110 For convenience, |obj| will be appended to the global "printed" list. 110 For convenience, |obj| will be appended to the global "printed" list.
111 111
112 Args: 112 Args:
113 obj: The object to be printed. Defaults to size_infos[-1]. 113 obj: The object to be printed. Defaults to size_infos[-1]. Also accepts an
114 index into the |printed| array for showing previous results.
114 verbose: Show more detailed output. 115 verbose: Show more detailed output.
115 recursive: Print children of nested SymbolGroups. 116 recursive: Print children of nested SymbolGroups.
116 use_pager: Pipe output through `less`. Ignored when |obj| is a Symbol. 117 use_pager: Pipe output through `less`. Ignored when |obj| is a Symbol.
117 default is to automatically pipe when output is long. 118 default is to automatically pipe when output is long.
118 to_file: Rather than print to stdio, write to the given file. 119 to_file: Rather than print to stdio, write to the given file.
119 """ 120 """
120 if not self._printed_variables or self._printed_variables[-1] != obj: 121 if isinstance(obj, int):
122 obj = self._printed_variables[obj]
123 elif not self._printed_variables or self._printed_variables[-1] != obj:
121 self._printed_variables.append(obj) 124 self._printed_variables.append(obj)
122 obj = obj if obj is not None else self._size_infos[-1] 125 obj = obj if obj is not None else self._size_infos[-1]
123 lines = describe.GenerateLines(obj, verbose=verbose, recursive=recursive) 126 lines = describe.GenerateLines(obj, verbose=verbose, recursive=recursive)
124 _WriteToStream(lines, use_pager=use_pager, to_file=to_file) 127 _WriteToStream(lines, use_pager=use_pager, to_file=to_file)
125 128
126 def _ElfPathAndToolPrefixForSymbol(self, symbol, elf_path, tool_prefix): 129 def _ElfPathAndToolPrefixForSymbol(self, symbol, elf_path, tool_prefix):
127 size_info = None 130 size_info = None
128 size_path = None 131 size_path = None
129 for size_info, size_path in zip(self._size_infos, self._size_paths): 132 for size_info, size_path in zip(self._size_infos, self._size_paths):
130 if symbol in size_info.raw_symbols: 133 if symbol in size_info.raw_symbols:
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 output_directory=args.output_directory, 354 output_directory=args.output_directory,
352 any_path_within_output_directory=args.inputs[0]) 355 any_path_within_output_directory=args.inputs[0])
353 session = _Session(size_infos, args.inputs, lazy_paths) 356 session = _Session(size_infos, args.inputs, lazy_paths)
354 357
355 if args.query: 358 if args.query:
356 logging.info('Running query from command-line.') 359 logging.info('Running query from command-line.')
357 session.Eval(args.query) 360 session.Eval(args.query)
358 else: 361 else:
359 logging.info('Entering interactive console.') 362 logging.info('Entering interactive console.')
360 session.GoInteractive() 363 session.GoInteractive()
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/canned_queries.py ('k') | tools/binary_size/libsupersize/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698