src: implement runtime option --no-node-snapshot for debugging
PR-URL: https://github.com/nodejs/node/pull/28567 Refs: https://github.com/nodejs/node/issues/28558 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
db55c3cfc1
commit
581bddc656
25
src/node.cc
25
src/node.cc
@ -1052,16 +1052,21 @@ int Start(int argc, char** argv) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Isolate::CreateParams params;
|
Isolate::CreateParams params;
|
||||||
// TODO(joyeecheung): collect external references and set it in
|
const std::vector<size_t>* indexes = nullptr;
|
||||||
// params.external_references.
|
std::vector<intptr_t> external_references;
|
||||||
std::vector<intptr_t> external_references = {
|
|
||||||
reinterpret_cast<intptr_t>(nullptr)};
|
bool force_no_snapshot =
|
||||||
v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob();
|
per_process::cli_options->per_isolate->no_node_snapshot;
|
||||||
const std::vector<size_t>* indexes =
|
if (!force_no_snapshot) {
|
||||||
NodeMainInstance::GetIsolateDataIndexes();
|
v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob();
|
||||||
if (blob != nullptr) {
|
if (blob != nullptr) {
|
||||||
params.external_references = external_references.data();
|
// TODO(joyeecheung): collect external references and set it in
|
||||||
params.snapshot_blob = blob;
|
// params.external_references.
|
||||||
|
external_references.push_back(reinterpret_cast<intptr_t>(nullptr));
|
||||||
|
params.external_references = external_references.data();
|
||||||
|
params.snapshot_blob = blob;
|
||||||
|
indexes = NodeMainInstance::GetIsolateDataIndexes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeMainInstance main_instance(¶ms,
|
NodeMainInstance main_instance(¶ms,
|
||||||
|
@ -522,6 +522,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
|
|||||||
"track heap object allocations for heap snapshots",
|
"track heap object allocations for heap snapshots",
|
||||||
&PerIsolateOptions::track_heap_objects,
|
&PerIsolateOptions::track_heap_objects,
|
||||||
kAllowedInEnvironment);
|
kAllowedInEnvironment);
|
||||||
|
AddOption("--no-node-snapshot",
|
||||||
|
"", // It's a debug-only option.
|
||||||
|
&PerIsolateOptions::no_node_snapshot,
|
||||||
|
kAllowedInEnvironment);
|
||||||
|
|
||||||
// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS.
|
// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS.
|
||||||
AddOption("--abort-on-uncaught-exception",
|
AddOption("--abort-on-uncaught-exception",
|
||||||
|
@ -171,6 +171,7 @@ class PerIsolateOptions : public Options {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() };
|
std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() };
|
||||||
bool track_heap_objects = false;
|
bool track_heap_objects = false;
|
||||||
|
bool no_node_snapshot = false;
|
||||||
|
|
||||||
#ifdef NODE_REPORT
|
#ifdef NODE_REPORT
|
||||||
bool report_uncaught_exception = false;
|
bool report_uncaught_exception = false;
|
||||||
|
5
test/parallel/test-no-node-snapshot.js
Normal file
5
test/parallel/test-no-node-snapshot.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Flags: --no-node-snapshot
|
||||||
|
|
||||||
|
require('../common');
|
@ -79,6 +79,8 @@ const undocumented = difference(process.allowedNodeEnvironmentFlags,
|
|||||||
// Remove intentionally undocumented options.
|
// Remove intentionally undocumented options.
|
||||||
assert(undocumented.delete('--debug-arraybuffer-allocations'));
|
assert(undocumented.delete('--debug-arraybuffer-allocations'));
|
||||||
assert(undocumented.delete('--experimental-worker'));
|
assert(undocumented.delete('--experimental-worker'));
|
||||||
|
assert(undocumented.delete('--no-node-snapshot'));
|
||||||
|
|
||||||
assert.strictEqual(undocumented.size, 0,
|
assert.strictEqual(undocumented.size, 0,
|
||||||
'The following options are not documented as allowed in ' +
|
'The following options are not documented as allowed in ' +
|
||||||
`NODE_OPTIONS in ${cliMd}: ${[...undocumented].join(' ')}`);
|
`NODE_OPTIONS in ${cliMd}: ${[...undocumented].join(' ')}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user