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

Side by Side Diff: tools/dump-cpp.py

Issue 1884493003: Dump C++ symbols and merge into v8 log. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « tools/codemap.js ('k') | tools/dumpcpp.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided
13 # with the distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29
30 # This script executes the tickprocessor, collects all dumped C++ symbols,
fmeawad 2016/04/20 22:54:22 It no longer executes the "tickprocessor"
lpy 2016/04/20 23:10:37 Done.
31 # and merges them into v8.log.
fmeawad 2016/04/20 22:54:22 back into ...
lpy 2016/04/20 23:10:37 Done.
32
33 import os
34 import platform
35 import re
36 import subprocess
37 import sys
38
39 def isFileExecutable(fPath):
40 return os.path.isfile(fPath) and os.access(fPath, os.X_OK)
41
42 if __name__ == '__main__':
43 JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js',
44 'profile.js', 'logreader.js', 'tickprocessor.js', 'SourceMap.js',
fmeawad 2016/04/20 22:54:22 Do we still need the tickprocessor.js? can we avoi
lpy 2016/04/20 23:10:37 Yes, we need to import it.
fmeawad 2016/04/20 23:15:11 We should make the functionality in tickprocessor
45 'dumpcpp.js']
46 tools_path = os.path.dirname(os.path.realpath(__file__))
47 on_windows = True if platform.system() == 'Windows' else False
48 for i in range(0, len(JS_FILES)):
49 JS_FILES[i] = os.path.join(tools_path, JS_FILES[i])
50
51 args = []
52 log_file = 'v8.log'
53 debug = False
54 for i in range(1, len(sys.argv)):
55 if sys.argv[i] == '--debug':
56 debug = True
57 continue
58 args.append(sys.argv[i])
59 if not sys.argv[i].startswith('-'):
60 log_file = sys.argv[i]
61
62 if on_windows:
63 args.append('--windows')
64
65 with open(log_file, 'r') as f:
66 lines = f.readlines()
67
68 d8_line = re.search(',\"(.*d8)', ''.join(lines))
69 if d8_line:
70 d8_exec = d8_line.groups()[0]
71 else:
72 print 'No d8 binary path found in {}.'.format(log_file)
fmeawad 2016/04/20 22:54:21 I think that would give you the path to v8.log?
lpy 2016/04/20 23:10:37 I am not sure if it's guaranteed that we can have
fmeawad 2016/04/20 23:15:11 Then the error message is misleading
73 exit(-1)
74
75 if on_windows:
76 args = [d8_exec] + JS_FILES + ['--'] + args
77 else:
78 args = [d8_exec] + JS_FILES + ['--'] + args
fmeawad 2016/04/20 22:54:21 I do not see a different between the if and else c
lpy 2016/04/20 23:10:37 Done.
79
80 with open(log_file) as f:
81 sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=f)
82 out, err = sp.communicate()
83 if debug:
84 print err
85 returncode = sp.returncode
86 if returncode != 0:
fmeawad 2016/04/20 22:54:22 No need to store the return code, just use it.
lpy 2016/04/20 23:10:37 Done.
87 print out
88 exit(-1)
89
90 if on_windows and out:
91 out = re.sub('\r+\n', '\n', out)
92
93 is_written = False if out else True
94 with open(log_file, 'w+') as f:
95 for line in lines:
96 if not is_written and line.startswith('tick'):
97 f.write(out)
98 is_written = True
99 f.write(line)
OLDNEW
« no previous file with comments | « tools/codemap.js ('k') | tools/dumpcpp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698