Skip to content

Commit 046f66a

Browse files
mykmelezjasnell
authored andcommitted
src: fix building --without-v8-plartform
* declare v8_platform.platform_ unconditionally v8_platform.platform_ is referenced by node::Start without regard to the value of NODE_USE_V8_PLATFORM, so it should be declared unconditionally, otherwise Node fails to compile when !NODE_USE_V8_PLATFORM. * update v8_platform.StartInspector signature The call signature of v8_platform.StartInspector needs to be the same whether or not NODE_USE_V8_PLATFORM, otherwise Node will fail to compile if HAVE_INSPECTOR and !NODE_USE_V8_PLATFORM. * don't call tracing_agent->Start w/nullptr node::tracing::Agent::Start can't accept a nullptr argument to its platform parameter, so don't call it when Node is compiled with NODE_USE_V8_PLATFORM=0. * refactor tracing_agent into v8_platform Move tracing_agent global into the v8_platform struct, renaming it to tracing_agent_; CHECK(tracing_agent_ == nullptr) in StartTracingAgent() to detect double calls; and relace another tracing_agent->Stop() call with a call to StopTracingAgent(). PR-URL: #11088 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 7d2dc90 commit 046f66a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/node.cc

+21-6
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ static uv_async_t dispatch_debug_messages_async;
200200

201201
static Mutex node_isolate_mutex;
202202
static v8::Isolate* node_isolate;
203-
static tracing::Agent* tracing_agent;
204203

205204
static node::DebugOptions debug_options;
206205

@@ -228,16 +227,33 @@ static struct {
228227
}
229228
#endif // HAVE_INSPECTOR
230229

230+
void StartTracingAgent() {
231+
CHECK(tracing_agent_ == nullptr);
232+
tracing_agent_ = new tracing::Agent();
233+
tracing_agent_->Start(platform_, trace_enabled_categories);
234+
}
235+
236+
void StopTracingAgent() {
237+
tracing_agent_->Stop();
238+
}
239+
231240
v8::Platform* platform_;
241+
tracing::Agent* tracing_agent_;
232242
#else // !NODE_USE_V8_PLATFORM
233243
void Initialize(int thread_pool_size) {}
234244
void PumpMessageLoop(Isolate* isolate) {}
235245
void Dispose() {}
236246
bool StartInspector(Environment *env, const char* script_path,
237-
int port, bool wait) {
247+
const node::DebugOptions& options) {
238248
env->ThrowError("Node compiled with NODE_USE_V8_PLATFORM=0");
239249
return false; // make compiler happy
240250
}
251+
252+
void StartTracingAgent() {
253+
fprintf(stderr, "Node compiled with NODE_USE_V8_PLATFORM=0, "
254+
"so event tracing is not available.\n");
255+
}
256+
void StopTracingAgent() {}
241257
#endif // !NODE_USE_V8_PLATFORM
242258
} v8_platform;
243259

@@ -3386,7 +3402,7 @@ void SetupProcessObject(Environment* env,
33863402
void SignalExit(int signo) {
33873403
uv_tty_reset_mode();
33883404
if (trace_enabled) {
3389-
tracing_agent->Stop();
3405+
v8_platform.StopTracingAgent();
33903406
}
33913407
#ifdef __FreeBSD__
33923408
// FreeBSD has a nasty bug, see RegisterSignalHandler for details
@@ -4533,15 +4549,14 @@ int Start(int argc, char** argv) {
45334549
if (trace_enabled) {
45344550
fprintf(stderr, "Warning: Trace event is an experimental feature "
45354551
"and could change at any time.\n");
4536-
tracing_agent = new tracing::Agent();
4537-
tracing_agent->Start(v8_platform.platform_, trace_enabled_categories);
4552+
v8_platform.StartTracingAgent();
45384553
}
45394554
V8::Initialize();
45404555
v8_initialized = true;
45414556
const int exit_code =
45424557
Start(uv_default_loop(), argc, argv, exec_argc, exec_argv);
45434558
if (trace_enabled) {
4544-
tracing_agent->Stop();
4559+
v8_platform.StopTracingAgent();
45454560
}
45464561
v8_initialized = false;
45474562
V8::Dispose();

0 commit comments

Comments
 (0)