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

Side by Side Diff: tools/cygprofile/patch_orderfile.py

Issue 859873002: Fix the prefix removal in patch_orderfile.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address pasko's comment. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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")
111 if missing_symbols > 0:
112 sys.stderr.write ("WARNING: %d missing symbols." % missing_symbols)
108 113
109 sys.stderr.write ("number of addresses: " + str(len(addresses)) + "\n") 114 sys.stderr.write ("number of addresses: " + str(len(addresses)) + "\n")
110 total_size = 0 115 total_size = 0
111 for addr in addresses: 116 for addr in addresses:
112 (functions, size) = binary_search (addr, 0, len(uniqueAddrs)) 117 (functions, size) = binary_search (addr, 0, len(uniqueAddrs))
113 total_size = total_size + size 118 total_size = total_size + size
114 for function in functions: 119 for function in functions:
115 for prefix in prefixes: 120 for prefix in prefixes:
116 print prefix + function 121 print prefix + function
117 122
118 # The following is needed otherwise Gold only applies a partial sort. 123 # The following is needed otherwise Gold only applies a partial sort.
119 print '.text' # gets methods not in a section, such as assembly 124 print '.text' # gets methods not in a section, such as assembly
120 print '.text.*' # gets everything else 125 print '.text.*' # gets everything else
121 sys.stderr.write ("total_size: " + str(total_size) + "\n") 126 sys.stderr.write ("total_size: " + str(total_size) + "\n")
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698