Chromium Code Reviews| 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): |