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 12 matching lines...) Expand all Loading... |
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 # Usage: process-ticks.py <logfile> | 30 # Usage: process-ticks.py <logfile> |
31 # Where <logfile> is the log file name (eg, v8.log). | 31 # Where <logfile> is the log file name (eg, v8.log). |
32 | 32 |
33 import subprocess, re, sys, tickprocessor, getopt | 33 import subprocess, re, sys, tickprocessor |
34 | 34 |
35 class LinuxTickProcessor(tickprocessor.TickProcessor): | 35 class LinuxTickProcessor(tickprocessor.TickProcessor): |
36 | 36 |
37 def ParseVMSymbols(self, filename, start, end): | 37 def ParseVMSymbols(self, filename, start, end): |
38 """Extract symbols and add them to the cpp entries.""" | 38 """Extract symbols and add them to the cpp entries.""" |
39 # Extra both dynamic and non-dynamic symbols. | 39 # Extra both dynamic and non-dynamic symbols. |
40 command = 'nm -C -n "%s"; nm -C -n -D "%s"' % (filename, filename) | 40 command = 'nm -C -n "%s"; nm -C -n -D "%s"' % (filename, filename) |
41 process = subprocess.Popen(command, shell=True, | 41 process = subprocess.Popen(command, shell=True, |
42 stdout=subprocess.PIPE, | 42 stdout=subprocess.PIPE, |
43 stderr=subprocess.STDOUT) | 43 stderr=subprocess.STDOUT) |
44 pipe = process.stdout | 44 pipe = process.stdout |
45 try: | 45 try: |
46 for line in pipe: | 46 for line in pipe: |
47 row = re.match('^([0-9a-fA-F]{8}) . (.*)$', line) | 47 row = re.match('^([0-9a-fA-F]{8}) . (.*)$', line) |
48 if row: | 48 if row: |
49 addr = int(row.group(1), 16) | 49 addr = int(row.group(1), 16) |
50 if addr < start and addr < end - start: | 50 if addr < start and addr < end - start: |
51 addr += start | 51 addr += start |
52 self.cpp_entries.Insert(addr, tickprocessor.CodeEntry(addr, row.group(
2))) | 52 self.cpp_entries.Insert(addr, tickprocessor.CodeEntry(addr, row.group(
2))) |
53 finally: | 53 finally: |
54 pipe.close() | 54 pipe.close() |
55 | 55 |
56 | 56 |
57 def Usage(): | 57 class LinuxCmdLineProcessor(tickprocessor.CmdLineProcessor): |
58 print("Usage: linux-tick-processor.py --{js,gc,compiler,other} logfile-name")
; | 58 |
59 sys.exit(2) | 59 def GetRequiredArgsNames(self): |
| 60 return 'log_file' |
| 61 |
| 62 def ProcessRequiredArgs(self, args): |
| 63 if len(args) != 1: |
| 64 self.PrintUsageAndExit() |
| 65 else: |
| 66 self.log_file = args[0] |
| 67 |
60 | 68 |
61 def Main(): | 69 def Main(): |
62 # parse command line options | 70 cmdline_processor = LinuxCmdLineProcessor() |
63 ignore_unknown = False | 71 cmdline_processor.ProcessArguments() |
64 state = None; | |
65 try: | |
66 opts, args = getopt.getopt(sys.argv[1:], "jgco", ["js", "gc", "compiler", "o
ther", "ignore-unknown"]) | |
67 except getopt.GetoptError: | |
68 usage() | |
69 # process options. | |
70 for key, value in opts: | |
71 if key in ("-j", "--js"): | |
72 state = 0 | |
73 if key in ("-g", "--gc"): | |
74 state = 1 | |
75 if key in ("-c", "--compiler"): | |
76 state = 2 | |
77 if key in ("-o", "--other"): | |
78 state = 3 | |
79 if key in ("--ignore-unknown"): | |
80 ignore_unknown = True | |
81 # do the processing. | |
82 if len(args) != 1: | |
83 Usage(); | |
84 tick_processor = LinuxTickProcessor() | 72 tick_processor = LinuxTickProcessor() |
85 tick_processor.ProcessLogfile(args[0], state, ignore_unknown) | 73 cmdline_processor.RunLogfileProcessing(tick_processor) |
86 tick_processor.PrintResults() | 74 tick_processor.PrintResults() |
87 | 75 |
| 76 |
88 if __name__ == '__main__': | 77 if __name__ == '__main__': |
89 Main() | 78 Main() |
OLD | NEW |