Chromium Code Reviews| Index: tools/binary_size/libsupersize/models.py |
| diff --git a/tools/binary_size/libsupersize/models.py b/tools/binary_size/libsupersize/models.py |
| index 18280164bfdf3b1b301216ca66563fce990f513d..1140e1296a9d8f644368ef60507a62f2526db824 100644 |
| --- a/tools/binary_size/libsupersize/models.py |
| +++ b/tools/binary_size/libsupersize/models.py |
| @@ -55,6 +55,7 @@ FLAG_STARTUP = 2 |
| FLAG_UNLIKELY = 4 |
| FLAG_REL = 8 |
| FLAG_REL_LOCAL = 16 |
| +FLAG_GENERATED_SOURCE = 32 |
| class SizeInfo(object): |
| @@ -136,6 +137,17 @@ class BaseSymbol(object): |
| return bool(self.flags & FLAG_ANONYMOUS) |
| @property |
| + def generated_source(self): |
| + return bool(self.flags & FLAG_GENERATED_SOURCE) |
| + |
| + @generated_source.setter |
| + def generated_source(self, value): |
| + if value: |
| + self.flags |= FLAG_GENERATED_SOURCE |
| + else: |
| + self.flags &= ~FLAG_GENERATED_SOURCE |
| + |
| + @property |
| def num_aliases(self): |
| return len(self.aliases) if self.aliases else 1 |
| @@ -155,6 +167,8 @@ class BaseSymbol(object): |
| parts.append('rel') |
| if flags & FLAG_REL_LOCAL: |
| parts.append('rel.loc') |
| + if flags & FLAG_GENERATED_SOURCE: |
| + parts.append('gen') |
| # Not actually a part of flags, but useful to show it here. |
| if self.aliases: |
| parts.append('{} aliases'.format(self.num_aliases)) |
| @@ -166,10 +180,9 @@ class BaseSymbol(object): |
| def IsGroup(self): |
| return False |
| - def IsGenerated(self): |
| - # TODO(agrieve): Also match generated functions such as: |
| - # startup._GLOBAL__sub_I_page_allocator.cc |
| - return self.name.endswith(']') and not self.name.endswith('[]') |
| + def IsGeneratedByToolchain(self): |
| + return '.' in self.name or ( |
| + self.name.endswith(']') and not self.name.endswith('[]')) |
| class Symbol(BaseSymbol): |
| @@ -302,22 +315,22 @@ class SymbolGroup(BaseSymbol): |
| @property |
| def address(self): |
| - first = self._symbols[0].address |
| + first = self._symbols[0].address if self else 0 |
|
estevenson
2017/05/05 19:14:58
probably obvious but what is the "if self" for?
agrieve
2017/05/06 00:37:29
it checks for the case of a SymbolGroup with no ch
|
| return first if all(s.address == first for s in self._symbols) else 0 |
| @property |
| def flags(self): |
| - first = self._symbols[0].flags |
| + first = self._symbols[0].flags if self else 0 |
| return first if all(s.flags == first for s in self._symbols) else 0 |
| @property |
| def object_path(self): |
| - first = self._symbols[0].object_path |
| + first = self._symbols[0].object_path if self else '' |
| return first if all(s.object_path == first for s in self._symbols) else '' |
| @property |
| def source_path(self): |
| - first = self._symbols[0].source_path |
| + first = self._symbols[0].source_path if self else '' |
| return first if all(s.source_path == first for s in self._symbols) else '' |
| def IterUniqueSymbols(self): |
| @@ -430,13 +443,20 @@ class SymbolGroup(BaseSymbol): |
| ret.section_name = section |
| return ret |
| - def WhereIsGenerated(self): |
| - return self.Filter(lambda s: s.IsGenerated()) |
| + def WhereSourceIsGenerated(self): |
| + return self.Filter(lambda s: s.generated_source) |
| + |
| + def WhereGeneratedByToolchain(self): |
| + return self.Filter(lambda s: s.IsGeneratedByToolchain()) |
| def WhereNameMatches(self, pattern): |
| regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern)) |
| return self.Filter(lambda s: regex.search(s.name)) |
| + def WhereFullNameMatches(self, pattern): |
|
estevenson
2017/05/05 19:14:58
Does it make sense to just add this to WhereNameMa
agrieve
2017/05/06 00:37:29
This is certainly a place where I'm not sure what
|
| + regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern)) |
| + return self.Filter(lambda s: regex.search(s.full_name or s.name)) |
| + |
| def WhereObjectPathMatches(self, pattern): |
| regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern)) |
| return self.Filter(lambda s: regex.search(s.object_path)) |
| @@ -469,6 +489,9 @@ class SymbolGroup(BaseSymbol): |
| end = start + 1 |
| return self.Filter(lambda s: s.address >= start and s.address < end) |
| + def WhereHasPath(self): |
| + return self.Filter(lambda s: s.source_path or s.object_path) |
| + |
| def WhereHasAnyAttribution(self): |
| return self.Filter(lambda s: s.name or s.source_path or s.object_path) |
| @@ -489,6 +512,8 @@ class SymbolGroup(BaseSymbol): |
| def GroupBy(self, func, min_count=0): |
| """Returns a SymbolGroup of SymbolGroups, indexed by |func|. |
| + Symbols within each subgroup maintain their relative ordering. |
| + |
| Args: |
| func: Grouping function. Passed a symbol and returns a string for the |
| name of the subgroup to put the symbol in. If None is returned, the |