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

Unified Diff: tools/binary_size/binary_size_utils.py

Issue 2785483002: Reland of V2 of //tools/binary_size rewrite (diffs). (Closed)
Patch Set: add missing name= Created 3 years, 9 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/analyze.py ('k') | tools/binary_size/console.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/binary_size_utils.py
diff --git a/tools/binary_size/binary_size_utils.py b/tools/binary_size/binary_size_utils.py
deleted file mode 100644
index 67335c2b6d37885833bdc3781f0e681bb358d59d..0000000000000000000000000000000000000000
--- a/tools/binary_size/binary_size_utils.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Common utilities for tools that deal with binary size information.
-"""
-
-import logging
-import re
-
-
-def ParseNm(nm_lines):
- """Parse nm output, returning data for all relevant (to binary size)
- symbols and ignoring the rest.
-
- Args:
- nm_lines: an iterable over lines of nm output.
-
- Yields:
- (symbol name, symbol type, symbol size, source file path).
-
- Path may be None if nm couldn't figure out the source file.
- """
-
- # Match lines with size, symbol, optional location, optional discriminator
- sym_re = re.compile(r'^([0-9a-f]{8,}) ' # address (8+ hex digits)
- '([0-9a-f]{8,}) ' # size (8+ hex digits)
- '(.) ' # symbol type, one character
- '([^\t]+)' # symbol name, separated from next by tab
- '(?:\t(.*):[\d\?]+)?.*$') # location
- # Match lines with addr but no size.
- addr_re = re.compile(r'^[0-9a-f]{8,} (.) ([^\t]+)(?:\t.*)?$')
- # Match lines that don't have an address at all -- typically external symbols.
- noaddr_re = re.compile(r'^ {8,} (.) (.*)$')
- # Match lines with no symbol name, only addr and type
- addr_only_re = re.compile(r'^[0-9a-f]{8,} (.)$')
-
- seen_lines = set()
- for line in nm_lines:
- line = line.rstrip()
- if line in seen_lines:
- # nm outputs identical lines at times. We don't want to treat
- # those as distinct symbols because that would make no sense.
- continue
- seen_lines.add(line)
- match = sym_re.match(line)
- if match:
- address, size, sym_type, sym = match.groups()[0:4]
- size = int(size, 16)
- if sym_type in ('B', 'b'):
- continue # skip all BSS for now.
- path = match.group(5)
- yield sym, sym_type, size, path, address
- continue
- match = addr_re.match(line)
- if match:
- # sym_type, sym = match.groups()[0:2]
- continue # No size == we don't care.
- match = noaddr_re.match(line)
- if match:
- sym_type, sym = match.groups()
- if sym_type in ('U', 'w'):
- continue # external or weak symbol
- match = addr_only_re.match(line)
- if match:
- continue # Nothing to do.
-
-
- # If we reach this part of the loop, there was something in the
- # line that we didn't expect or recognize.
- logging.warning('nm output parser failed to parse: %s', repr(line))
« no previous file with comments | « tools/binary_size/analyze.py ('k') | tools/binary_size/console.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698