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

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

Issue 2881563003: supersize: Make Disassemble() work for downloaded .size files (Closed)
Patch Set: self-review 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 """Classes that comprise the data model for binary size analysis. 4 """Classes that comprise the data model for binary size analysis.
5 5
6 The primary classes are Symbol, and SymbolGroup. 6 The primary classes are Symbol, and SymbolGroup.
7 7
8 Description of common properties: 8 Description of common properties:
9 * address: The start address of the symbol. 9 * address: The start address of the symbol.
10 May be 0 (e.g. for .bss or for SymbolGroups). 10 May be 0 (e.g. for .bss or for SymbolGroups).
(...skipping 24 matching lines...) Expand all
35 35
36 36
37 METADATA_GIT_REVISION = 'git_revision' 37 METADATA_GIT_REVISION = 'git_revision'
38 METADATA_APK_FILENAME = 'apk_file_name' # Path relative to output_directory. 38 METADATA_APK_FILENAME = 'apk_file_name' # Path relative to output_directory.
39 METADATA_MAP_FILENAME = 'map_file_name' # Path relative to output_directory. 39 METADATA_MAP_FILENAME = 'map_file_name' # Path relative to output_directory.
40 METADATA_ELF_ARCHITECTURE = 'elf_arch' # "Machine" field from readelf -h 40 METADATA_ELF_ARCHITECTURE = 'elf_arch' # "Machine" field from readelf -h
41 METADATA_ELF_FILENAME = 'elf_file_name' # Path relative to output_directory. 41 METADATA_ELF_FILENAME = 'elf_file_name' # Path relative to output_directory.
42 METADATA_ELF_MTIME = 'elf_mtime' # int timestamp in utc. 42 METADATA_ELF_MTIME = 'elf_mtime' # int timestamp in utc.
43 METADATA_ELF_BUILD_ID = 'elf_build_id' 43 METADATA_ELF_BUILD_ID = 'elf_build_id'
44 METADATA_GN_ARGS = 'gn_args' 44 METADATA_GN_ARGS = 'gn_args'
45 METADATA_TOOL_PREFIX = 'tool_prefix' # Path relative to SRC_ROOT.
45 46
46 47
47 SECTION_TO_SECTION_NAME = { 48 SECTION_TO_SECTION_NAME = {
48 'b': '.bss', 49 'b': '.bss',
49 'd': '.data', 50 'd': '.data',
50 'r': '.rodata', 51 'r': '.rodata',
51 't': '.text', 52 't': '.text',
52 } 53 }
53 54
54 FLAG_ANONYMOUS = 1 55 FLAG_ANONYMOUS = 1
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 for symbol in self: 450 for symbol in self:
450 filtered_and_kept[int(bool(func(symbol)))].append(symbol) 451 filtered_and_kept[int(bool(func(symbol)))].append(symbol)
451 except: 452 except:
452 logging.warning('Filter failed on symbol %r', symbol) 453 logging.warning('Filter failed on symbol %r', symbol)
453 raise 454 raise
454 455
455 return self._CreateTransformed(filtered_and_kept[1], 456 return self._CreateTransformed(filtered_and_kept[1],
456 filtered_symbols=filtered_and_kept[0], 457 filtered_symbols=filtered_and_kept[0],
457 section_name=self.section_name) 458 section_name=self.section_name)
458 459
459 def WhereBiggerThan(self, min_size): 460 def WhereSizeBiggerThan(self, min_size):
460 return self.Filter(lambda s: s.size >= min_size) 461 return self.Filter(lambda s: s.size >= min_size)
461 462
463 def WherePssBiggerThan(self, min_pss):
464 return self.Filter(lambda s: s.pss >= min_pss)
465
462 def WhereInSection(self, section): 466 def WhereInSection(self, section):
463 if len(section) == 1: 467 if len(section) == 1:
464 ret = self.Filter(lambda s: s.section == section) 468 ret = self.Filter(lambda s: s.section == section)
465 ret.section_name = SECTION_TO_SECTION_NAME[section] 469 ret.section_name = SECTION_TO_SECTION_NAME[section]
466 else: 470 else:
467 ret = self.Filter(lambda s: s.section_name == section) 471 ret = self.Filter(lambda s: s.section_name == section)
468 ret.section_name = section 472 ret.section_name = section
469 return ret 473 return ret
470 474
471 def WhereIsTemplate(self): 475 def WhereIsTemplate(self):
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 749
746 750
747 def _ExtractSuffixAfterSeparator(string, separator, count): 751 def _ExtractSuffixAfterSeparator(string, separator, count):
748 prev_idx = len(string) + 1 752 prev_idx = len(string) + 1
749 for _ in xrange(count): 753 for _ in xrange(count):
750 idx = string.rfind(separator, 0, prev_idx - 1) 754 idx = string.rfind(separator, 0, prev_idx - 1)
751 if idx < 0: 755 if idx < 0:
752 break 756 break
753 prev_idx = idx 757 prev_idx = idx
754 return string[:prev_idx] 758 return string[:prev_idx]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698