trace_events: stop tracing agent in process.exit()

PR-URL: https://github.com/nodejs/node/pull/18005
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
Andreas Madsen 2018-01-05 16:40:18 +01:00
parent acf56be536
commit 6aac05bf47
No known key found for this signature in database
GPG Key ID: 2FEE61B3C9E40F20
2 changed files with 25 additions and 0 deletions

View File

@ -2029,6 +2029,9 @@ static void WaitForInspectorDisconnect(Environment* env) {
static void Exit(const FunctionCallbackInfo<Value>& args) {
WaitForInspectorDisconnect(Environment::GetCurrent(args));
if (trace_enabled) {
v8_platform.StopTracingAgent();
}
exit(args[0]->Int32Value());
}

View File

@ -0,0 +1,22 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const FILE_NAME = 'node_trace.1.log';
common.refreshTmpDir();
process.chdir(common.tmpDir);
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',
'-e', 'process.exit()' ]);
proc.once('exit', common.mustCall(() => {
assert(common.fileExists(FILE_NAME));
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
const traces = JSON.parse(data.toString()).traceEvents;
assert(traces.length > 0);
}));
}));