Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 import commands | 6 import commands |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 orderfile = sys.argv[1] | 10 orderfile = sys.argv[1] |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 elif (addr < nm_addr): | 56 elif (addr < nm_addr): |
| 57 return binary_search (addr, start, halfway) | 57 return binary_search (addr, start, halfway) |
| 58 elif (addr >= nm_addr + sym_size): | 58 elif (addr >= nm_addr + sym_size): |
| 59 return binary_search (addr, halfway, end) | 59 return binary_search (addr, halfway, end) |
| 60 else: | 60 else: |
| 61 raise Exception("ERROR: did not expect this case") | 61 raise Exception("ERROR: did not expect this case") |
| 62 | 62 |
| 63 f = open (orderfile) | 63 f = open (orderfile) |
| 64 lines = f.readlines() | 64 lines = f.readlines() |
| 65 profiled_list = [] | 65 profiled_list = [] |
| 66 prefixes = ['.text.', '.text.startup.', '.text.hot.', '.text.unlikely.'] | 66 prefixes = ['.text.startup.', '.text.hot.', '.text.unlikely.', '.text.'] |
| 67 for line in lines: | 67 for line in lines: |
| 68 for prefix in prefixes: | 68 for prefix in prefixes: |
| 69 line = line.replace(prefix, '') | 69 line = line.replace(prefix, '') |
| 70 functionName = line.split('.clone.')[0].strip() | 70 functionName = line.split('.clone.')[0].strip() |
| 71 if (functionName == ''): | 71 if (functionName == ''): |
| 72 continue | 72 continue |
| 73 profiled_list.append(functionName) | 73 profiled_list.append(functionName) |
| 74 | 74 |
| 75 # Symbol names are not unique. Since the order file uses symbol names, the | 75 # Symbol names are not unique. Since the order file uses symbol names, the |
| 76 # patched order file pulls in all symbols with the same name. Multiple function | 76 # patched order file pulls in all symbols with the same name. Multiple function |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 87 functionAddress = int (line.split()[0].strip(), 16) | 87 functionAddress = int (line.split()[0].strip(), 16) |
| 88 try: | 88 try: |
| 89 functionAddressMap[functionName].append(functionAddress) | 89 functionAddressMap[functionName].append(functionAddress) |
| 90 except Exception: | 90 except Exception: |
| 91 functionAddressMap[functionName] = [functionAddress] | 91 functionAddressMap[functionName] = [functionAddress] |
| 92 functions.append(functionName) | 92 functions.append(functionName) |
| 93 | 93 |
| 94 sys.stderr.write ("profiled list size: " + str(len(profiled_list)) + "\n") | 94 sys.stderr.write ("profiled list size: " + str(len(profiled_list)) + "\n") |
| 95 addresses = [] | 95 addresses = [] |
| 96 symbols_found = 0 | 96 symbols_found = 0 |
| 97 missing_symbols = 0 | |
| 97 for function in profiled_list: | 98 for function in profiled_list: |
| 98 try: | 99 try: |
| 99 addrs = functionAddressMap[function] | 100 addrs = functionAddressMap[function] |
| 100 symbols_found = symbols_found + 1 | 101 symbols_found = symbols_found + 1 |
| 101 except Exception: | 102 except Exception: |
| 102 addrs = [] | 103 addrs = [] |
| 103 # sys.stderr.write ("WARNING: could not find symbol " + function + "\n") | 104 missing_symbols += 1 |
| 105 if missing_symbols < 100: | |
| 106 sys.stderr.write ("WARNING: could not find symbol " + function + "\n") | |
| 104 for addr in addrs: | 107 for addr in addrs: |
| 105 if not (addr in addresses): | 108 if not (addr in addresses): |
| 106 addresses.append(addr) | 109 addresses.append(addr) |
| 107 sys.stderr.write ("symbols found: " + str(symbols_found) + "\n") | 110 sys.stderr.write ("symbols found: " + str(symbols_found) + "\n") |
|
pasko-google - do not use
2015/01/19 18:36:50
can we also print the amount of missing symbols he
| |
| 108 | 111 |
| 109 sys.stderr.write ("number of addresses: " + str(len(addresses)) + "\n") | 112 sys.stderr.write ("number of addresses: " + str(len(addresses)) + "\n") |
| 110 total_size = 0 | 113 total_size = 0 |
| 111 for addr in addresses: | 114 for addr in addresses: |
| 112 (functions, size) = binary_search (addr, 0, len(uniqueAddrs)) | 115 (functions, size) = binary_search (addr, 0, len(uniqueAddrs)) |
| 113 total_size = total_size + size | 116 total_size = total_size + size |
| 114 for function in functions: | 117 for function in functions: |
| 115 for prefix in prefixes: | 118 for prefix in prefixes: |
| 116 print prefix + function | 119 print prefix + function |
| 117 | 120 |
| 118 # The following is needed otherwise Gold only applies a partial sort. | 121 # The following is needed otherwise Gold only applies a partial sort. |
| 119 print '.text' # gets methods not in a section, such as assembly | 122 print '.text' # gets methods not in a section, such as assembly |
| 120 print '.text.*' # gets everything else | 123 print '.text.*' # gets everything else |
| 121 sys.stderr.write ("total_size: " + str(total_size) + "\n") | 124 sys.stderr.write ("total_size: " + str(total_size) + "\n") |
| OLD | NEW |