From d507dc3706cb133bf7fe7233c890bb83ce420191 Mon Sep 17 00:00:00 2001 From: Mike Kaufman Date: Sat, 25 Aug 2018 11:38:03 -0700 Subject: [PATCH] Updating TTD options parsing to use new node_options APIs --- src/node.cc | 38 ++++++++++++++++++++++++++++++++++++++ src/node_options.cc | 11 +++++++++++ src/node_options.h | 11 +++++++++++ 3 files changed, 60 insertions(+) diff --git a/src/node.cc b/src/node.cc index 30bb829184b..16864c947a9 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2542,6 +2542,44 @@ void ProcessArgv(std::vector* args, for (const std::string& cve : per_process_opts->security_reverts) Revert(cve.c_str()); +#if ENABLE_TTD_NODE + if (per_process_opts->ttdRecord) { + s_doTTRecord = true; + } + if (per_process_opts->ttdDebug) { + s_doTTRecord = true; + s_doTTEnableDebug = true; + s_ttdSnapInterval = 500; + s_ttdSnapHistoryLength = 4; + } + if (per_process_opts->ttdReplayUri.length() > 0) { + s_doTTReplay = true; + // TODO(mkaufman): update TTD APIs to take a std::string + s_ttoptReplayUri = per_process_opts->ttdReplayUri.c_str(); + s_ttoptReplayUriLength = per_process_opts->ttdReplayUri.length(); + } + if (per_process_opts->ttdReplayDebugUri.length() > 0) { + s_doTTReplay = true; + s_doTTEnableDebug = true; + s_ttoptReplayUri = per_process_opts->ttdReplayDebugUri.c_str(); + s_ttoptReplayUriLength = per_process_opts->ttdReplayUri.length(); + } + if (per_process_opts->ttdBreakFirst) { + s_ttdStartupMode = (0x100 | 0x1); + per_process_opts-> + per_isolate->per_env->debug_options->break_first_line = true; + } + if (per_process_opts->ttdRecordInterval > 0) { + s_ttdSnapInterval = per_process_opts->ttdRecordInterval; + } + if (per_process_opts->ttdRecordHistoryLength > 0) { + s_ttdSnapHistoryLength = per_process_opts->ttdRecordHistoryLength; + } + if (per_process_opts->ttdDisableAutoTrace) { + s_ttAutoTraceEnabled = false; + } +#endif + // TODO(addaleax): Move this validation to the option parsers. auto env_opts = per_process_opts->per_isolate->per_env; if (!env_opts->userland_loader.empty() && diff --git a/src/node_options.cc b/src/node_options.cc index 46f529cff2e..9c8491ad1bc 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -291,6 +291,17 @@ PerProcessOptionsParser::PerProcessOptionsParser() { #endif #endif +#if ENABLE_TTD_NODE + AddOption("--record", &PerProcessOptions::ttdRecord); + AddOption("--tt-debug", &PerProcessOptions::ttdDebug); + AddOption("--replay", &PerProcessOptions::ttdReplayUri); + AddOption("--replay-debug", &PerProcessOptions::ttdReplayUri); + AddOption("--break-first", &PerProcessOptions::ttdBreakFirst); + AddOption("--record-interval", &PerProcessOptions::ttdRecordInterval); + AddOption("--record-history", &PerProcessOptions::ttdRecordHistoryLength); + AddOption("--disable-auto-trace", &PerProcessOptions::ttdDisableAutoTrace); +#endif + Insert(&PerIsolateOptionsParser::instance, &PerProcessOptions::get_per_isolate_options); } diff --git a/src/node_options.h b/src/node_options.h index 71615cf0839..2d79dc92a31 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -137,6 +137,17 @@ class PerProcessOptions { #endif #endif +#if ENABLE_TTD_NODE + bool ttdRecord = false; // --record + bool ttdDebug = false; // --tt-debug + std::string ttdReplayUri; // replay= + std::string ttdReplayDebugUri; // replay-debug= + bool ttdBreakFirst = false; // --break-first + int64_t ttdRecordInterval = -1; // --record-interval= + int64_t ttdRecordHistoryLength = -1; // --record-history + bool ttdDisableAutoTrace = false; // --disable-auto-trace +#endif + inline PerIsolateOptions* get_per_isolate_options(); };