summaryrefslogtreecommitdiff
path: root/src/node_v8_platform-inl.h
diff options
context:
space:
mode:
authorKelvin Jin <kelvinjin@google.com>2018-12-10 20:44:18 +0000
committerAli Ijaz Sheikh <ofrobots@google.com>2019-02-14 12:10:09 -0800
commit582c0d5a092b04616fef4b11b0fd893c181356f1 (patch)
tree9b81e3e3d701e561f957c09adb200ca95198865d /src/node_v8_platform-inl.h
parent7d60b6b21b7d47d22ac7a321eb5b47cf90d63ecf (diff)
downloadandroid-node-v8-582c0d5a092b04616fef4b11b0fd893c181356f1.tar.gz
android-node-v8-582c0d5a092b04616fef4b11b0fd893c181356f1.tar.bz2
android-node-v8-582c0d5a092b04616fef4b11b0fd893c181356f1.zip
trace_events: fix trace events JS API writing
The Trace Events JS API isn't functional if none of --trace-events-enabled or --trace-event-categories is passed as a CLI argument. This commit fixes that. In addition, we currently don't test the trace_events JS API in the casewhere no CLI args are provided. This commit adds that test. Fixes https://github.com/nodejs/node/issues/24944 PR-URL: https://github.com/nodejs/node/pull/24945 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'src/node_v8_platform-inl.h')
-rw-r--r--src/node_v8_platform-inl.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/node_v8_platform-inl.h b/src/node_v8_platform-inl.h
index ed91ee3a02..2c89ee9e52 100644
--- a/src/node_v8_platform-inl.h
+++ b/src/node_v8_platform-inl.h
@@ -85,7 +85,11 @@ struct V8Platform {
tracing_agent_->GetTracingController();
trace_state_observer_.reset(new NodeTraceStateObserver(controller));
controller->AddTraceStateObserver(trace_state_observer_.get());
- StartTracingAgent();
+ tracing_file_writer_ = tracing_agent_->DefaultHandle();
+ // Only start the tracing agent if we enabled any tracing categories.
+ if (!per_process::cli_options->trace_event_categories.empty()) {
+ StartTracingAgent();
+ }
// Tracing must be initialized before platform threads are created.
platform_ = new NodePlatform(thread_pool_size, controller);
v8::V8::InitializePlatform(platform_);
@@ -111,9 +115,9 @@ struct V8Platform {
}
inline void StartTracingAgent() {
- if (per_process::cli_options->trace_event_categories.empty()) {
- tracing_file_writer_ = tracing_agent_->DefaultHandle();
- } else {
+ // Attach a new NodeTraceWriter only if this function hasn't been called
+ // before.
+ if (tracing_file_writer_.IsDefaultHandle()) {
std::vector<std::string> categories =
SplitString(per_process::cli_options->trace_event_categories, ',');
@@ -163,6 +167,10 @@ namespace per_process {
extern struct V8Platform v8_platform;
}
+inline void StartTracingAgent() {
+ return per_process::v8_platform.StartTracingAgent();
+}
+
inline tracing::AgentWriterHandle* GetTracingAgentWriter() {
return per_process::v8_platform.GetTracingAgentWriter();
}