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

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: 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
Index: tools/cygprofile/patch_orderfile.py
diff --git a/tools/cygprofile/patch_orderfile.py b/tools/cygprofile/patch_orderfile.py
index ee5be906d2c7e4caa228e2ccb02945fddac2c73a..de26d2d89dd17ce9963b8ca25116c7d2c0e15471 100755
--- a/tools/cygprofile/patch_orderfile.py
+++ b/tools/cygprofile/patch_orderfile.py
@@ -102,6 +102,23 @@ def _GetSymbolInfosFromBinary(binary_filename):
p.wait()
+def _StripPrefixes(line):
pasko 2015/01/22 17:37:14 it strips only one prefix, so maybe name it _Strip
azarchs 2015/01/22 17:44:30 Done.
+ """Get the symbol from a line with a linker section name
pasko 2015/01/22 17:37:14 nit: full stop at the end of the sentence. (here a
azarchs 2015/01/22 17:44:30 Done.
+
+ Args:
+ line: a line from an orderfile, usually in the form
+ .text.SymbolName
pasko 2015/01/22 17:37:14 nit: 4 chars shift to the right
azarchs 2015/01/22 17:44:30 Done.
+
+ 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
Benoit L 2015/01/22 16:49:53 nit: You can also use the for prefix in _PREFIXES
azarchs 2015/01/22 17:10:12 Maybe it's because I'm used to C, C++, Java, C#, B
+
+
def _GetSymbolsFromStream(lines):
"""Get the symbols from an iterable of lines.
@@ -113,16 +130,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 = _StripPrefixes(line)
name = _RemoveClone(line)
- if name == '':
+ if name == '' or name == '*' or name == '.text':
pasko 2015/01/22 17:37:14 please enhance testGetSymbolsFromStream to verify
azarchs 2015/01/22 17:44:30 Done.
continue
- symbols.append(line)
+ if not line in unique_symbols:
+ symbols.append(line)
+ unique_symbols.add(line)
return symbols
@@ -191,8 +207,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') | tools/cygprofile/patch_orderfile_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698