This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inspector: track async stacks when necessary
With this change, we do async stack tracking only when explicitly requested by the inspector client. This avoids unnecessary overhead for clients that might not be interested in async stack traces. PR-URL: nodejs/node#16308 Fixes: nodejs/node#16180 Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
- Loading branch information
Showing
6 changed files
with
142 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
common.skipIf32Bits(); | ||
|
||
const assert = require('assert'); | ||
const async_wrap = process.binding('async_wrap'); | ||
const { kTotals } = async_wrap.constants; | ||
const inspector = require('inspector'); | ||
|
||
const setDepth = 'Debugger.setAsyncCallStackDepth'; | ||
|
||
function verifyAsyncHookDisabled(message) { | ||
assert.strictEqual(async_wrap.async_hook_fields[kTotals], 0); | ||
} | ||
|
||
function verifyAsyncHookEnabled(message) { | ||
assert.strictEqual(async_wrap.async_hook_fields[kTotals], 4); | ||
} | ||
|
||
// By default inspector async hooks should not have been installed. | ||
verifyAsyncHookDisabled('inspector async hook should be disabled at startup'); | ||
|
||
const session = new inspector.Session(); | ||
verifyAsyncHookDisabled('creating a session should not enable async hooks'); | ||
|
||
session.connect(); | ||
verifyAsyncHookDisabled('connecting a session should not enable async hooks'); | ||
|
||
session.post('Debugger.enable', () => { | ||
verifyAsyncHookDisabled('enabling debugger should not enable async hooks'); | ||
|
||
session.post(setDepth, { invalid: 'message' }, () => { | ||
verifyAsyncHookDisabled('invalid message should not enable async hooks'); | ||
|
||
session.post(setDepth, { maxDepth: 'five' }, () => { | ||
verifyAsyncHookDisabled('invalid maxDepth (string) should not enable ' + | ||
'async hooks'); | ||
|
||
session.post(setDepth, { maxDepth: NaN }, () => { | ||
verifyAsyncHookDisabled('invalid maxDepth (NaN) should not enable ' + | ||
'async hooks'); | ||
|
||
session.post(setDepth, { maxDepth: 10 }, () => { | ||
verifyAsyncHookEnabled('valid message should enable async hooks'); | ||
|
||
session.post(setDepth, { maxDepth: 0 }, () => { | ||
verifyAsyncHookDisabled('Setting maxDepth to 0 should disable ' + | ||
'async hooks'); | ||
|
||
runTestSet2(session); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function runTestSet2(session) { | ||
session.post(setDepth, { maxDepth: 32 }, () => { | ||
verifyAsyncHookEnabled('valid message should enable async hooks'); | ||
|
||
session.post('Debugger.disable', () => { | ||
verifyAsyncHookDisabled('Debugger.disable should disable async hooks'); | ||
|
||
session.post('Debugger.enable', () => { | ||
verifyAsyncHookDisabled('Enabling debugger should not enable hooks'); | ||
|
||
session.post(setDepth, { maxDepth: 64 }, () => { | ||
verifyAsyncHookEnabled('valid message should enable async hooks'); | ||
|
||
session.disconnect(); | ||
verifyAsyncHookDisabled('Disconnecting session should disable ' + | ||
'async hooks'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
22 changes: 0 additions & 22 deletions
22
test/sequential/test-inspector-async-hook-teardown-at-debug-end.js
This file was deleted.
Oops, something went wrong.