Chromium Code Reviews| Index: tools/binary_size/libsupersize/diff.py |
| diff --git a/tools/binary_size/libsupersize/diff.py b/tools/binary_size/libsupersize/diff.py |
| index 178a06a8eb4d0a6556f2b7eea4f82e6d93a4f257..d8789f904df9d6062ca1d960b75bdc4219808d21 100644 |
| --- a/tools/binary_size/libsupersize/diff.py |
| +++ b/tools/binary_size/libsupersize/diff.py |
| @@ -4,10 +4,41 @@ |
| """Logic for diffing two SizeInfo objects.""" |
| import collections |
| +import re |
| import models |
| +def _SymbolKey(symbol): |
| + """Returns a tuple that can be used to see if two Symbol are the same. |
| + |
| + Keys are not guaranteed to be unique within a SymbolGroup. When multiple |
| + symbols have the same key, they will be matched up in order of appearance. |
| + |
| + Examples of symbols with shared keys: |
| + "** merge strings" |
| + "** symbol gap 3", "** symbol gap 5" |
| + "foo() [clone ##]" |
| + "CSWTCH.61", "CSWTCH.62" |
| + "._468", "._467" |
| + ".L__unnamed_1193", ".L__unnamed_712" |
| + """ |
| + name = symbol.full_name or symbol.name |
| + if name: |
|
estevenson
2017/05/03 17:29:06
nit: this check seems superfluous since the rest o
agrieve
2017/05/03 18:27:08
Done.
|
| + clone_idx = name.find(' [clone ') |
| + if clone_idx != -1: |
| + name = name[:clone_idx] |
| + if name.startswith('*'): |
| + # "symbol gap 3 (bar)" -> "symbol gaps" |
| + name = re.sub(r'\s+\d+( \(.*\))?$', 's', name) |
| + |
| + if '.' not in name: |
| + return (symbol.section_name, name) |
| + # Compiler or Linker generated symbol. |
| + name = re.sub(r'[.0-9]', '', name) # Strip out all numbers and dots. |
|
estevenson
2017/05/03 17:29:06
Just to confirm I understand:
On Linux there are
agrieve
2017/05/03 18:27:07
Updated the pydoc to make confirm the "why".
But
|
| + return (symbol.section_name, name, symbol.object_path) |
| + |
| + |
| def _CloneSymbol(sym, size): |
| """Returns a copy of |sym| with an updated |size|. |
| @@ -101,7 +132,7 @@ def _NegateAndClone(before_symbols, matched_before_aliases, |
| def _DiffSymbolGroups(before, after): |
| before_symbols_by_key = collections.defaultdict(list) |
| for s in before: |
| - before_symbols_by_key[s._Key()].append(s) |
| + before_symbols_by_key[_SymbolKey(s)].append(s) |
| similar = [] |
| diffed_symbol_by_after_aliases = {} |
| @@ -113,7 +144,7 @@ def _DiffSymbolGroups(before, after): |
| # Step 1: Create all delta symbols and record unmatched symbols. |
| for after_sym in after: |
| - matching_syms = before_symbols_by_key.get(after_sym._Key()) |
| + matching_syms = before_symbols_by_key.get(_SymbolKey(after_sym)) |
| if matching_syms: |
| before_sym = matching_syms.pop(0) |
| if before_sym.IsGroup() and after_sym.IsGroup(): |