OLD | NEW |
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 def IterUniqueSymbols(self): | 323 def IterUniqueSymbols(self): |
324 seen_aliases_lists = set() | 324 seen_aliases_lists = set() |
325 for s in self: | 325 for s in self: |
326 if not s.aliases: | 326 if not s.aliases: |
327 yield s | 327 yield s |
328 elif id(s.aliases) not in seen_aliases_lists: | 328 elif id(s.aliases) not in seen_aliases_lists: |
329 seen_aliases_lists.add(id(s.aliases)) | 329 seen_aliases_lists.add(id(s.aliases)) |
330 yield s | 330 yield s |
331 | 331 |
| 332 def CountUniqueSymbols(self): |
| 333 return sum(1 for s in self.IterUniqueSymbols()) |
| 334 |
332 @property | 335 @property |
333 def size(self): | 336 def size(self): |
334 if self._size is None: | 337 if self._size is None: |
335 if self.IsBss(): | 338 if self.IsBss(): |
336 self._size = sum(s.size for s in self) | 339 self._size = sum(s.size for s in self) |
337 else: | 340 else: |
338 self._size = sum(s.size for s in self.IterUniqueSymbols()) | 341 self._size = sum(s.size for s in self.IterUniqueSymbols()) |
339 return self._size | 342 return self._size |
340 | 343 |
341 @property | 344 @property |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 697 |
695 def _ExtractPrefixBeforeSeparator(string, separator, count=1): | 698 def _ExtractPrefixBeforeSeparator(string, separator, count=1): |
696 idx = -len(separator) | 699 idx = -len(separator) |
697 prev_idx = None | 700 prev_idx = None |
698 for _ in xrange(count): | 701 for _ in xrange(count): |
699 idx = string.find(separator, idx + len(separator)) | 702 idx = string.find(separator, idx + len(separator)) |
700 if idx < 0: | 703 if idx < 0: |
701 break | 704 break |
702 prev_idx = idx | 705 prev_idx = idx |
703 return string[:prev_idx] | 706 return string[:prev_idx] |
OLD | NEW |