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

Unified Diff: tools/cygprofile/patch_orderfile.py

Issue 859303005: Only include unique lines when patching orderfile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from pasko Created 5 years, 11 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 | « no previous file | tools/cygprofile/patch_orderfile_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cygprofile/patch_orderfile.py
diff --git a/tools/cygprofile/patch_orderfile.py b/tools/cygprofile/patch_orderfile.py
index ee5be906d2c7e4caa228e2ccb02945fddac2c73a..6c8bc431413e65f68993f8fceb330575a86b40de 100755
--- a/tools/cygprofile/patch_orderfile.py
+++ b/tools/cygprofile/patch_orderfile.py
@@ -102,8 +102,26 @@ def _GetSymbolInfosFromBinary(binary_filename):
p.wait()
+def _StripPrefix(line):
+ """Get the symbol from a line with a linker section name.
+
+ Args:
+ line: a line from an orderfile, usually in the form:
+ .text.SymbolName
+
+ Returns:
+ The symbol, SymbolName in the example above.
+ """
+ line = line.rstrip('\n')
+ for prefix in _PREFIXES:
+ if line.startswith(prefix):
+ return line[len(prefix):]
+ return line # Unprefixed case
+
+
def _GetSymbolsFromStream(lines):
"""Get the symbols from an iterable of lines.
+ Filters out wildcards and lines which do not correspond to symbols.
Args:
lines: iterable of lines from an orderfile.
@@ -113,16 +131,15 @@ def _GetSymbolsFromStream(lines):
"""
# TODO(lizeb): Retain the prefixes later in the processing stages.
symbols = []
+ unique_symbols = set()
for line in lines:
- line = line.rstrip('\n')
- for prefix in _PREFIXES:
- if line.startswith(prefix):
- line = line[len(prefix):]
- break
+ line = _StripPrefix(line)
name = _RemoveClone(line)
- if name == '':
+ if name == '' or name == '*' or name == '.text':
continue
- symbols.append(line)
+ if not line in unique_symbols:
+ symbols.append(line)
+ unique_symbols.add(line)
return symbols
@@ -191,8 +208,13 @@ def _ExpandSymbolsWithDupsFromSameOffset(symbol_infos, offset_to_symbol_infos):
def _PrintSymbolsWithPrefixes(symbol_names, output_file):
"""For each symbol, outputs it to output_file with the prefixes."""
+ unique_outputs = set()
for name in symbol_names:
- output_file.write('\n'.join(prefix + name for prefix in _PREFIXES) + '\n')
+ for prefix in _PREFIXES:
+ linker_section = prefix + name
+ if not linker_section in unique_outputs:
+ output_file.write(linker_section + '\n')
+ unique_outputs.add(linker_section)
def main(argv):
« no previous file with comments | « no previous file | tools/cygprofile/patch_orderfile_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698