OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Utilities to get and manipulate symbols from a binary.""" | 6 """Utilities to get and manipulate symbols from a binary.""" |
7 | 7 |
8 import collections | 8 import collections |
9 import logging | |
9 import os | 10 import os |
10 import re | 11 import re |
11 import subprocess | 12 import subprocess |
12 import sys | 13 import sys |
13 | 14 |
14 sys.path.insert( | 15 sys.path.insert( |
15 0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, | 16 0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, |
16 'third_party', 'android_platform', 'development', | 17 'third_party', 'android_platform', 'development', |
17 'scripts')) | 18 'scripts')) |
18 import symbol | 19 import symbol |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 110 |
110 def CreateNameToSymbolInfo(symbol_infos): | 111 def CreateNameToSymbolInfo(symbol_infos): |
111 """Create a dict {name: symbol_info, ...}. | 112 """Create a dict {name: symbol_info, ...}. |
112 | 113 |
113 Args: | 114 Args: |
114 symbol_infos: iterable of SymbolInfo instances | 115 symbol_infos: iterable of SymbolInfo instances |
115 | 116 |
116 Returns: | 117 Returns: |
117 a dict {name: symbol_info, ...} | 118 a dict {name: symbol_info, ...} |
118 """ | 119 """ |
119 return {symbol_info.name: symbol_info for symbol_info in symbol_infos} | 120 symbol_infos_by_name = {} |
Benoit L
2015/02/23 14:09:49
This function no longer does what it says in its d
azarchs
2015/02/23 15:39:37
I'd say it's functionality relative the documentat
| |
121 duplicated_symbols = set() | |
pasko
2015/02/23 14:28:13
They rather 'collided' than were 'duplicated'. So
azarchs
2015/02/23 15:39:37
Done.
| |
122 for symbol_info in symbol_infos: | |
123 if symbol_info.name in symbol_infos_by_name: | |
124 # If a symbol appears at multiple offsets, keep the lowest offset. | |
125 duplicated_symbols.add(symbol_info.name) | |
126 if symbol_infos_by_name[symbol_info.name].offset > symbol_info.offset: | |
127 symbol_infos_by_name[symbol_info.name] = symbol_info | |
128 else: | |
129 symbol_infos_by_name[symbol_info.name] = symbol_info | |
130 if len(duplicated_symbols) > 0: | |
131 logging.warning('%d symbols were found at more than one offset.' % | |
132 len(duplicated_symbols)) | |
133 duplicated_symbols_to_show = min(50, len(duplicated_symbols)) | |
134 logging.warning('First %d duplicated symbols:\n%s' % ( | |
pasko
2015/02/23 14:28:13
I would prefer warning level on the level of check
azarchs
2015/02/23 15:39:38
Done.
| |
135 duplicated_symbols_to_show, | |
136 '\n'.join(list(duplicated_symbols)[:duplicated_symbols_to_show]))) | |
137 return symbol_infos_by_name | |
OLD | NEW |