OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2008 the V8 project authors. All rights reserved. | 3 # Copyright 2008 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 # Usage: process-ticks.py <binary> <logfile> | 31 # Usage: process-ticks.py <binary> <logfile> |
32 # | 32 # |
33 # Where <binary> is the binary program name (eg, v8_shell.exe) and | 33 # Where <binary> is the binary program name (eg, v8_shell.exe) and |
34 # <logfile> is the log file name (eg, v8.log). | 34 # <logfile> is the log file name (eg, v8.log). |
35 # | 35 # |
36 # This tick processor expects to find a map file for the binary named | 36 # This tick processor expects to find a map file for the binary named |
37 # binary.map if the binary is named binary.exe. The tick processor | 37 # binary.map if the binary is named binary.exe. The tick processor |
38 # only works for statically linked executables - no information about | 38 # only works for statically linked executables - no information about |
39 # shared libraries is logged from v8 on Windows. | 39 # shared libraries is logged from v8 on Windows. |
40 | 40 |
41 import os, re, sys, tickprocessor, getopt | 41 import os, re, sys, tickprocessor |
42 | 42 |
43 class WindowsTickProcessor(tickprocessor.TickProcessor): | 43 class WindowsTickProcessor(tickprocessor.TickProcessor): |
44 | 44 |
45 def Unmangle(self, name): | 45 def Unmangle(self, name): |
46 """Performs very simple unmangling of C++ names. | 46 """Performs very simple unmangling of C++ names. |
47 | 47 |
48 Does not handle arguments and template arguments. The mangled names have | 48 Does not handle arguments and template arguments. The mangled names have |
49 the form: | 49 the form: |
50 | 50 |
51 ?LookupInDescriptor@JSObject@internal@v8@@...arguments info... | 51 ?LookupInDescriptor@JSObject@internal@v8@@...arguments info... |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 self.cpp_entries.Insert(addr, tickprocessor.CodeEntry(addr, name)); | 100 self.cpp_entries.Insert(addr, tickprocessor.CodeEntry(addr, name)); |
101 i = min_addr | 101 i = min_addr |
102 # Mark the pages for which there are functions in the map file. | 102 # Mark the pages for which there are functions in the map file. |
103 while i < max_addr: | 103 while i < max_addr: |
104 page = i >> 12 | 104 page = i >> 12 |
105 self.vm_extent[page] = 1 | 105 self.vm_extent[page] = 1 |
106 i += 4096 | 106 i += 4096 |
107 finally: | 107 finally: |
108 map_file.close() | 108 map_file.close() |
109 | 109 |
110 def Usage(): | 110 |
111 print("Usage: windows-tick-processor.py binary logfile-name"); | 111 class WindowsCmdLineProcessor(tickprocessor.CmdLineProcessor): |
112 sys.exit(2) | 112 |
| 113 def __init__(self): |
| 114 super(WindowsCmdLineProcessor, self).__init__() |
| 115 self.binary_file = None |
| 116 |
| 117 def GetRequiredArgsNames(self): |
| 118 return 'binary log_file' |
| 119 |
| 120 def ProcessRequiredArgs(self, args): |
| 121 if len(args) != 2: |
| 122 self.PrintUsageAndExit() |
| 123 else: |
| 124 self.binary_file = args[0] |
| 125 self.log_file = args[1] |
| 126 |
113 | 127 |
114 def Main(): | 128 def Main(): |
115 # parse command line options | 129 cmdline_processor = WindowsCmdLineProcessor() |
116 ignore_unknown = False | 130 cmdline_processor.ProcessArguments() |
117 state = None; | |
118 try: | |
119 opts, args = getopt.getopt(sys.argv[1:], "jgco", ["js", "gc", "compiler", "o
ther", "ignore-unknown"]) | |
120 except getopt.GetoptError: | |
121 usage() | |
122 # process options. | |
123 for key, value in opts: | |
124 if key in ("-j", "--js"): | |
125 state = 0 | |
126 if key in ("-g", "--gc"): | |
127 state = 1 | |
128 if key in ("-c", "--compiler"): | |
129 state = 2 | |
130 if key in ("-o", "--other"): | |
131 state = 3 | |
132 if key in ("--ignore-unknown"): | |
133 ignore_unknown = True | |
134 # do the processing. | |
135 if len(args) != 2: | |
136 Usage(); | |
137 tickprocessor = WindowsTickProcessor() | 131 tickprocessor = WindowsTickProcessor() |
138 tickprocessor.ParseMapFile(args[0]) | 132 tickprocessor.ParseMapFile(cmdline_processor.binary_file) |
139 tickprocessor.ProcessLogfile(args[1], state, ignore_unknown) | 133 cmdline_processor.RunLogfileProcessing(tickprocessor) |
140 tickprocessor.PrintResults() | 134 tickprocessor.PrintResults() |
141 | 135 |
142 if __name__ == '__main__': | 136 if __name__ == '__main__': |
143 Main() | 137 Main() |
OLD | NEW |