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

report: include information about event loop itself #25906

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/report.md
Original file line number Diff line number Diff line change
@@ -215,6 +215,11 @@ is provided below for reference.
"is_referenced": false,
"address": "0x000000010188f2e0",
"details": ""
},
{
"type": "loop",
"is_active": true,
"address": "0x000055fc7b2cb180"
}
],
"environmentVariables": {
11 changes: 10 additions & 1 deletion src/node_report.cc
Original file line number Diff line number Diff line change
@@ -311,9 +311,18 @@ static void WriteNodeReport(Isolate* isolate,
#endif

writer.json_arraystart("libuv");
if (env != nullptr)
if (env != nullptr) {
uv_walk(env->event_loop(), WalkHandle, static_cast<void*>(&writer));

writer.json_start();
writer.json_keyvalue("type", "loop");
writer.json_keyvalue("is_active",
static_cast<bool>(uv_loop_alive(env->event_loop())));
writer.json_keyvalue("address",
ValueToHexString(reinterpret_cast<int64_t>(env->event_loop())));
writer.json_end();
}

writer.json_arrayend();

// Report operating system information
9 changes: 8 additions & 1 deletion src/node_report.h
Original file line number Diff line number Diff line change
@@ -57,8 +57,15 @@ void GetNodeReport(v8::Isolate* isolate,
void ReportEndpoints(uv_handle_t* h, std::ostringstream& out);
void WalkHandle(uv_handle_t* h, void* arg);
std::string EscapeJsonChars(const std::string& str);

template <typename T>
std::string ValueToHexString(T value);
std::string ValueToHexString(T value) {
std::stringstream hex;

hex << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex <<
value;
return hex.str();
}

// Function declarations - export functions in src/node_report_module.cc
void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info);
9 changes: 0 additions & 9 deletions src/node_report_utils.cc
Original file line number Diff line number Diff line change
@@ -214,15 +214,6 @@ void WalkHandle(uv_handle_t* h, void* arg) {
writer->json_end();
}

template <typename T>
std::string ValueToHexString(T value) {
std::stringstream hex;

hex << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex <<
value;
return hex.str();
}

std::string EscapeJsonChars(const std::string& str) {
const std::string control_symbols[0x20] = {
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",