Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: print information for snapshot at environment exit in debug #37967

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/embed_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Maybe<int> SpinEventLoop(Environment* env) {
if (env->is_stopping()) return Nothing<int>();

env->set_trace_sync_io(false);
env->PrintInfoForSnapshotIfDebug();
env->VerifyNoStrongBaseObjects();
return EmitProcessExit(env);
}
Expand Down
19 changes: 19 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,25 @@ void Environment::RemoveUnmanagedFd(int fd) {
}
}

void Environment::PrintInfoForSnapshotIfDebug() {
if (enabled_debug_list()->enabled(DebugCategory::MKSNAPSHOT)) {
fprintf(stderr, "BaseObjects at the exit of the Environment:\n");
PrintAllBaseObjects();
fprintf(stderr, "\nNative modules without cache:\n");
for (const auto& s : native_modules_without_cache) {
fprintf(stderr, "%s\n", s.c_str());
}
fprintf(stderr, "\nNative modules with cache:\n");
for (const auto& s : native_modules_with_cache) {
fprintf(stderr, "%s\n", s.c_str());
}
fprintf(stderr, "\nStatic bindings (need to be registered):\n");
for (const auto mod : internal_bindings) {
fprintf(stderr, "%s:%s\n", mod->nm_filename, mod->nm_modname);
}
}
}

void Environment::PrintAllBaseObjects() {
size_t i = 0;
std::cout << "BaseObjects\n";
Expand Down
2 changes: 2 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ class Environment : public MemoryRetainer {
void CreateProperties();
void DeserializeProperties(const EnvSerializeInfo* info);

void PrintInfoForSnapshotIfDebug();
void PrintAllBaseObjects();
void VerifyNoStrongBaseObjects();
void EnqueueDeserializeRequest(DeserializeRequestCallback cb,
Expand Down Expand Up @@ -1121,6 +1122,7 @@ class Environment : public MemoryRetainer {
// List of id's that have been destroyed and need the destroy() cb called.
inline std::vector<double>* destroy_async_id_list();

std::set<struct node_module*> internal_bindings;
std::set<std::string> native_modules_with_cache;
std::set<std::string> native_modules_without_cache;
// This is only filled during deserialization. We use a vector since
Expand Down
1 change: 1 addition & 0 deletions src/node_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
node_module* mod = FindModule(modlist_internal, *module_v, NM_F_INTERNAL);
if (mod != nullptr) {
exports = InitModule(env, mod, module);
env->internal_bindings.insert(mod);
} else if (!strcmp(*module_v, "constants")) {
exports = Object::New(env->isolate());
CHECK(
Expand Down