| Index: tools/binary_size/libsupersize/models.py
|
| diff --git a/tools/binary_size/libsupersize/models.py b/tools/binary_size/libsupersize/models.py
|
| index 1140e1296a9d8f644368ef60507a62f2526db824..026a8ec7a70eef724b6652a505dd3d29eb8de9aa 100644
|
| --- a/tools/binary_size/libsupersize/models.py
|
| +++ b/tools/binary_size/libsupersize/models.py
|
| @@ -333,18 +333,6 @@ class SymbolGroup(BaseSymbol):
|
| 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):
|
| - seen_aliases_lists = set()
|
| - for s in self:
|
| - if not s.aliases:
|
| - yield s
|
| - elif id(s.aliases) not in seen_aliases_lists:
|
| - seen_aliases_lists.add(id(s.aliases))
|
| - yield s
|
| -
|
| - def CountUniqueSymbols(self):
|
| - return sum(1 for s in self.IterUniqueSymbols())
|
| -
|
| @property
|
| def size(self):
|
| if self._size is None:
|
| @@ -376,6 +364,28 @@ class SymbolGroup(BaseSymbol):
|
| def IsGroup(self):
|
| return True
|
|
|
| + def IterUniqueSymbols(self):
|
| + """Yields all symbols, but only one from each alias group."""
|
| + seen_aliases_lists = set()
|
| + for s in self:
|
| + if not s.aliases:
|
| + yield s
|
| + elif id(s.aliases) not in seen_aliases_lists:
|
| + seen_aliases_lists.add(id(s.aliases))
|
| + yield s
|
| +
|
| + def IterLeafSymbols(self):
|
| + """Yields all symbols, recursing into subgroups."""
|
| + for s in self:
|
| + if s.IsGroup():
|
| + for x in s.IterLeafSymbols():
|
| + yield x
|
| + else:
|
| + yield s
|
| +
|
| + def CountUniqueSymbols(self):
|
| + return sum(1 for s in self.IterUniqueSymbols())
|
| +
|
| def _CreateTransformed(self, symbols, filtered_symbols=None, name=None,
|
| full_name=None, section_name=None, is_sorted=None):
|
| if is_sorted is None:
|
| @@ -397,10 +407,9 @@ class SymbolGroup(BaseSymbol):
|
| return self._CreateTransformed(cluster_symbols.ClusterSymbols(self))
|
|
|
| def Sorted(self, cmp_func=None, key=None, reverse=False):
|
| - # Default to sorting by abs(size) then name.
|
| if cmp_func is None and key is None:
|
| - cmp_func = lambda a, b: cmp((a.IsBss(), abs(b.size), a.name),
|
| - (b.IsBss(), abs(a.size), b.name))
|
| + cmp_func = lambda a, b: cmp((a.IsBss(), abs(b.pss), a.name),
|
| + (b.IsBss(), abs(a.pss), b.name))
|
|
|
| after_symbols = sorted(self._symbols, cmp_func, key, reverse)
|
| return self._CreateTransformed(
|
| @@ -411,7 +420,8 @@ class SymbolGroup(BaseSymbol):
|
| return self.Sorted(key=(lambda s:s.name), reverse=reverse)
|
|
|
| def SortedByAddress(self, reverse=False):
|
| - return self.Sorted(key=(lambda s:s.address), reverse=reverse)
|
| + return self.Sorted(key=(lambda s:(s.address, s.object_path, s.name)),
|
| + reverse=reverse)
|
|
|
| def SortedByCount(self, reverse=False):
|
| return self.Sorted(key=(lambda s:len(s) if s.IsGroup() else 1),
|
| @@ -544,9 +554,10 @@ class SymbolGroup(BaseSymbol):
|
| after_syms.extend(symbols)
|
| else:
|
| filtered_symbols.extend(symbols)
|
| - return self._CreateTransformed(
|
| + grouped = self._CreateTransformed(
|
| after_syms, filtered_symbols=filtered_symbols,
|
| section_name=self.section_name, is_sorted=False)
|
| + return grouped
|
|
|
| def GroupBySectionName(self):
|
| return self.GroupBy(lambda s: s.section_name)
|
| @@ -581,8 +592,8 @@ class SymbolGroup(BaseSymbol):
|
| return _ExtractPrefixBeforeSeparator(name, '::', depth)
|
| return self.GroupBy(extract_namespace, min_count=min_count)
|
|
|
| - def GroupBySourcePath(self, depth=0, fallback='{no path}',
|
| - fallback_to_object_path=True, min_count=0):
|
| + def GroupByPath(self, depth=0, fallback='{no path}',
|
| + fallback_to_object_path=True, min_count=0):
|
| """Groups by source_path.
|
|
|
| Args:
|
| @@ -604,23 +615,6 @@ class SymbolGroup(BaseSymbol):
|
| return _ExtractPrefixBeforeSeparator(path, os.path.sep, depth)
|
| return self.GroupBy(extract_path, min_count=min_count)
|
|
|
| - def GroupByObjectPath(self, depth=0, fallback='{no path}', min_count=0):
|
| - """Groups by object_path.
|
| -
|
| - Args:
|
| - depth: When 0 (default), groups by entire path. When 1, groups by
|
| - top-level directory, when 2, groups by top 2 directories, etc.
|
| - fallback: Use this value when no namespace exists.
|
| - min_count: Miniumum number of symbols for a group. If fewer than this many
|
| - symbols end up in a group, they will not be put within a group.
|
| - Use a negative value to omit symbols entirely rather than
|
| - include them outside of a group.
|
| - """
|
| - def extract_path(symbol):
|
| - path = symbol.object_path or fallback
|
| - return _ExtractPrefixBeforeSeparator(path, os.path.sep, depth)
|
| - return self.GroupBy(extract_path, min_count=min_count)
|
| -
|
|
|
| class SymbolDiff(SymbolGroup):
|
| """A SymbolGroup subclass representing a diff of two other SymbolGroups.
|
|
|