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

Unified Diff: tools/binary_size/map2size.py

Issue 2795593005: //tools/binary_size: Various enhancements to console.py (Closed)
Patch Set: Review fixes Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/match_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/map2size.py
diff --git a/tools/binary_size/map2size.py b/tools/binary_size/map2size.py
index 03f4483f890cc729f3ca6c86d63684acb48e862b..188f71337983c3e12967bda2dc3cb1c09df54892 100755
--- a/tools/binary_size/map2size.py
+++ b/tools/binary_size/map2size.py
@@ -95,6 +95,10 @@ def _NormalizeNames(symbol_group):
symbol.full_name = symbol.name
symbol.name = re.sub(r'\(.*\)', '', symbol.full_name)
+ # Don't bother storing both if they are the same.
+ if symbol.full_name == symbol.name:
+ symbol.full_name = ''
+
logging.debug('Found name prefixes of: %r', found_prefixes)
@@ -109,9 +113,9 @@ def _NormalizeObjectPaths(symbol_group):
# Convert ../../third_party/... -> third_party/...
path = path[6:]
if path.endswith(')'):
- # Convert foo/bar.a(baz.o) -> foo/bar.a/(baz.o)
+ # Convert foo/bar.a(baz.o) -> foo/bar.a/baz.o
start_idx = path.index('(')
- path = os.path.join(path[:start_idx], path[start_idx:])
+ path = os.path.join(path[:start_idx], path[start_idx + 1:-1])
symbol.object_path = path
@@ -148,17 +152,16 @@ def _RemoveDuplicatesAndCalculatePadding(symbol_group):
Symbols must already be sorted by |address|.
"""
- to_remove = set()
- all_symbols = symbol_group.symbols
- for i, symbol in enumerate(all_symbols[1:]):
- prev_symbol = all_symbols[i]
+ to_remove = []
+ for i, symbol in enumerate(symbol_group[1:]):
+ prev_symbol = symbol_group[i]
if prev_symbol.section_name != symbol.section_name:
continue
if symbol.address > 0 and prev_symbol.address > 0:
# Fold symbols that are at the same address (happens in nm output).
if symbol.address == prev_symbol.address:
symbol.size = max(prev_symbol.size, symbol.size)
- to_remove.add(i + 1)
+ to_remove.add(symbol)
continue
# Even with symbols at the same address removed, overlaps can still
# happen. In this case, padding will be negative (and this is fine).
@@ -185,8 +188,7 @@ def _RemoveDuplicatesAndCalculatePadding(symbol_group):
# Map files have no overlaps, so worth special-casing the no-op case.
if to_remove:
logging.info('Removing %d overlapping symbols', len(to_remove))
- symbol_group.symbols = (
- [s for i, s in enumerate(all_symbols) if i not in to_remove])
+ symbol_group -= models.SymbolGroup(to_remove)
def AddOptions(parser):
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/match_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698