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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/dump-cpp.py
diff --git a/tools/dump-cpp.py b/tools/dump-cpp.py
new file mode 100644
index 0000000000000000000000000000000000000000..5c1af78a8f6c1c4c67c17f9c182dfaf4dece320d
--- /dev/null
+++ b/tools/dump-cpp.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script executes the tickprocessor, collects all dumped C++ symbols,
+# and merges them into v8.log.
+
+import os
+import platform
+import re
+import subprocess
+import sys
+
+def isFileExecutable(fPath):
+ return os.path.isfile(fPath) and os.access(fPath, os.X_OK)
+
+if __name__ == '__main__':
+ JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js', 'profile.js', 'logreader.js', 'tickprocessor.js', 'SourceMap.js', 'dump-cpp.js']
fmeawad 2016/04/19 12:52:25 loose the "-" in the file name, all other file nam
lpy 2016/04/19 21:02:20 Done.
+ tools_path = os.path.dirname(os.path.realpath(__file__))
+ on_windows = True if platform.system() == 'Windows' else False
+ for i in range(0, len(JS_FILES)):
+ JS_FILES[i] = os.path.join(tools_path, JS_FILES[i])
+
+ args = []
+ log_file = 'v8.log'
+ debug = False
+ for i in range(1, len(sys.argv)):
+ if sys.argv[i] == '--debug':
+ debug = True
+ continue
+ args.append(sys.argv[i])
+ if not sys.argv[i].startswith('-'):
+ log_file = sys.argv[i]
+
+ if on_windows:
+ args.append('--windows')
+
+ with open(log_file, 'r') as f:
+ lines = f.readlines()
+
+ d8_line = re.search(',\"(.*d8)', ''.join(lines))
+ if d8_line:
+ d8_exec = d8_line.groups()[0]
+ else:
+ print 'No d8 binary path found in {}.'.format(log_file)
+ exit(-1)
+
+ if on_windows:
+ args = [d8_exec] + JS_FILES + ['--'] + args
+ else:
+ args = [d8_exec] + JS_FILES + ['--'] + args
+
+ with open(log_file) as f:
+ sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=f)
+ out, err = sp.communicate()
+ if debug:
+ print err
+ returncode = sp.returncode
+ if returncode != 0:
+ print out
+ exit(-1)
+
+ if on_windows and out:
fmeawad 2016/04/19 12:52:25 Have you tried it on a windows machine?
lpy 2016/04/19 21:02:20 No I haven't tried it on windows.
+ out = re.sub('\r+\n', '\n', out)
+
+ iswritten = False if out else True
fmeawad 2016/04/19 12:52:25 is_written
lpy 2016/04/19 21:02:20 Done.
+ with open(log_file, 'w+') as f:
+ for line in lines:
+ if not iswritten and line.startswith('tick'):
+ f.write(out)
+ iswritten = True
+ f.write(line)
« no previous file with comments | « tools/dump-cpp.js ('k') | tools/tickprocessor.js » ('j') | tools/tickprocessor.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698