summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMatt Loring <mattloring@google.com>2015-11-25 06:08:58 -0800
committerMyles Borins <mborins@us.ibm.com>2016-03-02 14:01:11 -0800
commit0164e12a6c3532faf25d589324584ba089eedbc5 (patch)
treeea6828cfd527bb0b7b067a517e3f509c33b2bedd /tools
parent86907c3e791ccedbbe187a1d15bdf06a54fc6a83 (diff)
downloadnodejs-0164e12a6c3532faf25d589324584ba089eedbc5.tar.gz
nodejs-0164e12a6c3532faf25d589324584ba089eedbc5.tar.bz2
nodejs-0164e12a6c3532faf25d589324584ba089eedbc5.zip
tools: add --prof-process flag to node binary
This change cleans up outstanding comments on #3032. It improves error handling when no isolate file is provided and adds the --prof-process flag to the node binary which executes the tick processor on the provided isolate file. PR-URL: https://github.com/nodejs/node/pull/4021 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/install.py44
-rwxr-xr-xtools/js2c.py2
-rw-r--r--tools/rpm/node.spec4
-rw-r--r--tools/v8-prof/polyfill.js93
-rw-r--r--tools/v8-prof/tick-processor.js51
5 files changed, 1 insertions, 193 deletions
diff --git a/tools/install.py b/tools/install.py
index 99cbbf249..ead93966f 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -127,48 +127,6 @@ def subdir_files(path, dest, action):
for subdir, files in ret.items():
action(files, subdir + '/')
-def build_tick_processor(action):
- tmp_script = 'out/Release/tick-processor'
- if action == install:
- # construct script
- scripts = [
- 'tools/v8-prof/polyfill.js',
- 'deps/v8/tools/splaytree.js',
- 'deps/v8/tools/codemap.js',
- 'deps/v8/tools/csvparser.js',
- 'deps/v8/tools/consarray.js',
- 'deps/v8/tools/csvparser.js',
- 'deps/v8/tools/consarray.js',
- 'deps/v8/tools/profile.js',
- 'deps/v8/tools/profile_view.js',
- 'deps/v8/tools/logreader.js',
- 'deps/v8/tools/tickprocessor.js',
- 'deps/v8/tools/SourceMap.js',
- 'deps/v8/tools/tickprocessor-driver.js']
- args = []
- if sys.platform == 'win32':
- args.append('--windows')
- elif sys.platform == 'darwin':
- args.append('--nm=' + abspath(install_path, 'share/doc/node') + '/mac-nm')
- args.append('--mac')
- with open(tmp_script, 'w') as out_file:
- # Add #! line to run with node
- out_file.write('#! ' + abspath(install_path, 'bin/node') + '\n')
- # inject arguments
- for arg in args:
- out_file.write('process.argv.splice(2, 0, \'' + arg + '\');\n')
- # cat in source files
- for script in scripts:
- with open(script) as in_file:
- shutil.copyfileobj(in_file, out_file)
- # make executable
- st = os.stat(tmp_script)
- os.chmod(tmp_script, st.st_mode | stat.S_IEXEC)
- # perform installations
- action([tmp_script], 'share/doc/node/')
- if sys.platform == 'darwin':
- action(['deps/v8/tools/mac-nm'], 'share/doc/node/')
-
def files(action):
is_windows = sys.platform == 'win32'
@@ -183,8 +141,6 @@ def files(action):
action(['deps/v8/tools/gdbinit'], 'share/doc/node/')
- build_tick_processor(action)
-
if 'freebsd' in sys.platform or 'openbsd' in sys.platform:
action(['doc/node.1'], 'man/man1/')
else:
diff --git a/tools/js2c.py b/tools/js2c.py
index 0fc0ae0ee..ec9705ec6 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -310,7 +310,7 @@ def JS2C(source, target):
else:
ids.append((id, len(lines)))
- escaped_id = id.replace('/', '_')
+ escaped_id = id.replace('-', '_').replace('/', '_')
source_lines.append(SOURCE_DECLARATION % {
'id': id,
'escaped_id': escaped_id,
diff --git a/tools/rpm/node.spec b/tools/rpm/node.spec
index a86cdf74d..39b98ec55 100644
--- a/tools/rpm/node.spec
+++ b/tools/rpm/node.spec
@@ -94,7 +94,6 @@ done
/usr/include/*
/usr/lib/node_modules/
/usr/share/doc/node/gdbinit
-/usr/share/doc/node/tick-processor
/usr/share/man/man1/node.1.gz
/usr/share/systemtap/tapset/node.stp
%{_datadir}/%{name}/
@@ -102,9 +101,6 @@ done
%changelog
-* Tue Sep 22 2015 Matt Loring <mattloring@google.com>
-- Added tick processor.
-
* Tue Jul 7 2015 Ali Ijaz Sheikh <ofrobots@google.com>
- Added gdbinit.
diff --git a/tools/v8-prof/polyfill.js b/tools/v8-prof/polyfill.js
deleted file mode 100644
index 24661c700..000000000
--- a/tools/v8-prof/polyfill.js
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2012 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.
-
-// Node polyfill
-var fs = require('fs');
-var os = {
- system: function(name, args) {
- if (process.platform === 'linux' && name === 'nm') {
- // Filter out vdso and vsyscall entries.
- var arg = args[args.length - 1];
- if (arg === '[vdso]' ||
- arg == '[vsyscall]' ||
- /^[0-9a-f]+-[0-9a-f]+$/.test(arg)) {
- return '';
- }
- }
- return require('child_process').execFileSync(
- name, args, {encoding: 'utf8'});
- }
-};
-var print = console.log;
-function read(fileName) {
- return fs.readFileSync(fileName, 'utf8');
-}
-arguments = process.argv.slice(2);
-var quit = process.exit;
-
-// Polyfill "readline()".
-var fd = fs.openSync(arguments[arguments.length - 1], 'r');
-var buf = new Buffer(4096);
-var dec = new (require('string_decoder').StringDecoder)('utf-8');
-var line = '';
-versionCheck();
-function readline() {
- while (true) {
- var lineBreak = line.indexOf('\n');
- if (lineBreak !== -1) {
- var res = line.slice(0, lineBreak);
- line = line.slice(lineBreak + 1);
- return res;
- }
- var bytes = fs.readSync(fd, buf, 0, buf.length);
- line += dec.write(buf.slice(0, bytes));
- if (line.length === 0) {
- return false;
- }
- }
-}
-
-function versionCheck() {
- // v8-version looks like "v8-version,$major,$minor,$build,$patch,$candidate"
- // whereas process.versions.v8 is either "$major.$minor.$build" or
- // "$major.$minor.$build.$patch".
- var firstLine = readline();
- line = firstLine + '\n' + line;
- firstLine = firstLine.split(',');
- var curVer = process.versions.v8.split('.');
- if (firstLine.length !== 6 && firstLine[0] !== 'v8-version') {
- console.log('Unable to read v8-version from log file.');
- return;
- }
- // Compare major, minor and build; ignore the patch and candidate fields.
- for (var i = 0; i < 3; i++) {
- if (curVer[i] !== firstLine[i + 1]) {
- console.log('Testing v8 version different from logging version');
- return;
- }
- }
-}
diff --git a/tools/v8-prof/tick-processor.js b/tools/v8-prof/tick-processor.js
deleted file mode 100644
index b25bcb75a..000000000
--- a/tools/v8-prof/tick-processor.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict';
-var cp = require('child_process');
-var fs = require('fs');
-var path = require('path');
-
-var toolsPath = path.join(__dirname, '..', '..', 'deps', 'v8', 'tools');
-var scriptFiles = [
- path.join(__dirname, 'polyfill.js'),
- path.join(toolsPath, 'splaytree.js'),
- path.join(toolsPath, 'codemap.js'),
- path.join(toolsPath, 'csvparser.js'),
- path.join(toolsPath, 'consarray.js'),
- path.join(toolsPath, 'csvparser.js'),
- path.join(toolsPath, 'consarray.js'),
- path.join(toolsPath, 'profile.js'),
- path.join(toolsPath, 'profile_view.js'),
- path.join(toolsPath, 'logreader.js'),
- path.join(toolsPath, 'tickprocessor.js'),
- path.join(toolsPath, 'SourceMap.js'),
- path.join(toolsPath, 'tickprocessor-driver.js')];
-var tempScript = path.join(__dirname, 'tick-processor-tmp-' + process.pid);
-
-process.on('exit', function() {
- try { fs.unlinkSync(tempScript); } catch (e) {}
-});
-process.on('uncaughtException', function(err) {
- try { fs.unlinkSync(tempScript); } catch (e) {}
- throw err;
-});
-
-var inStreams = scriptFiles.map(function(f) {
- return fs.createReadStream(f);
-});
-var outStream = fs.createWriteStream(tempScript);
-inStreams.reduce(function(prev, curr, i) {
- prev.on('end', function() {
- curr.pipe(outStream, { end: i === inStreams.length - 1});
- });
- return curr;
-});
-inStreams[0].pipe(outStream, { end: false });
-outStream.on('close', function() {
- var tickArguments = [tempScript];
- if (process.platform === 'darwin') {
- tickArguments.push('--mac', '--nm=' + path.join(toolsPath, 'mac-nm'));
- } else if (process.platform === 'win32') {
- tickArguments.push('--windows');
- }
- tickArguments.push.apply(tickArguments, process.argv.slice(2));
- var processTicks = cp.spawn(process.execPath, tickArguments, { stdio: 'inherit' });
-});