Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Updating TTD options parsing to use new node_options APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kaufman authored and kfarnung committed Oct 3, 2018
1 parent e0fdb65 commit d507dc3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,44 @@ void ProcessArgv(std::vector<std::string>* 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() &&
Expand Down
11 changes: 11 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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=<uri>
std::string ttdReplayDebugUri; // replay-debug=<uri>
bool ttdBreakFirst = false; // --break-first
int64_t ttdRecordInterval = -1; // --record-interval=<val>
int64_t ttdRecordHistoryLength = -1; // --record-history
bool ttdDisableAutoTrace = false; // --disable-auto-trace
#endif

inline PerIsolateOptions* get_per_isolate_options();
};

Expand Down

0 comments on commit d507dc3

Please sign in to comment.