diff options
author | Miroslav Bajtoš <mbajtoss@gmail.com> | 2017-07-17 17:51:26 +0300 |
---|---|---|
committer | Timothy Gu <timothygu99@gmail.com> | 2017-08-17 15:52:39 +0300 |
commit | a0895ed6c484fc3b322c70bcbf36080b1fe70154 (patch) | |
tree | 89501c4b775237148975c269ea414f5069285897 /src/node_config.cc | |
parent | b616e879474f72333a73db1d879abf5b5ba36f1d (diff) |
inspector: enable async stack traces
Implement a special async_hooks listener that forwards information
about async tasks to V8Inspector asyncTask* API, thus enabling
DevTools feature "async stack traces".
The feature is enabled only on 64bit platforms due to a technical
limitation of V8 Inspector: inspector uses a pointer as a task id,
while async_hooks use 64bit numbers as ids.
To avoid performance penalty of async_hooks when not debugging,
the new listener is enabled only when the process enters a debug mode:
- When the process is started with `--inspect` or `--inspect-brk`,
the listener is enabled immediately and async stack traces
lead all the way to the first tick of the event loop.
- When the debug mode is enabled via SIGUSR1 or `_debugProcess()`,
the listener is enabled together with the debugger. As a result,
only async operations started after the signal was received
will be correctly observed and reported to V8 Inspector. For example,
a `setInterval()` called in the first tick of the event will not be
shown in the async stack trace when the callback is invoked. This
behaviour is consistent with Chrome DevTools.
Last but not least, this commit fixes handling of InspectorAgent's
internal property `enabled_` to ensure it's set back to `false`
after the debugger is deactivated (typically via `process._debugEnd()`).
Fixes: https://github.com/nodejs/node/issues/11370
PR-URL: https://github.com/nodejs/node/pull/13870
Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Reviewed-by: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_config.cc')
-rw-r--r-- | src/node_config.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/node_config.cc b/src/node_config.cc index 041e18f6b76..d4fb991c581 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -13,6 +13,7 @@ using v8::Boolean; using v8::Context; using v8::Integer; using v8::Local; +using v8::Number; using v8::Object; using v8::ReadOnly; using v8::String; @@ -30,6 +31,15 @@ using v8::Value; True(env->isolate()), ReadOnly).FromJust(); \ } while (0) +#define READONLY_PROPERTY(obj, name, value) \ + do { \ + obj->DefineOwnProperty(env->context(), \ + OneByteString(env->isolate(), name), \ + value, \ + ReadOnly).FromJust(); \ + } while (0) + + static void InitConfig(Local<Object> target, Local<Value> unused, Local<Context> context) { @@ -91,6 +101,10 @@ static void InitConfig(Local<Object> target, if (config_expose_http2) READONLY_BOOLEAN_PROPERTY("exposeHTTP2"); + + READONLY_PROPERTY(target, + "bits", + Number::New(env->isolate(), 8 * sizeof(intptr_t))); } // InitConfig } // namespace node |