Skip to content

Commit 6c51ec3

Browse files
committed
report: include information about event loop itself
PR-URL: #25906 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 197efb7 commit 6c51ec3

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

doc/api/report.md

+5
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ is provided below for reference.
215215
"is_referenced": false,
216216
"address": "0x000000010188f2e0",
217217
"details": ""
218+
},
219+
{
220+
"type": "loop",
221+
"is_active": true,
222+
"address": "0x000055fc7b2cb180"
218223
}
219224
],
220225
"environmentVariables": {

src/node_report.cc

+10-1
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,18 @@ static void WriteNodeReport(Isolate* isolate,
311311
#endif
312312

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

317+
writer.json_start();
318+
writer.json_keyvalue("type", "loop");
319+
writer.json_keyvalue("is_active",
320+
static_cast<bool>(uv_loop_alive(env->event_loop())));
321+
writer.json_keyvalue("address",
322+
ValueToHexString(reinterpret_cast<int64_t>(env->event_loop())));
323+
writer.json_end();
324+
}
325+
317326
writer.json_arrayend();
318327

319328
// Report operating system information

src/node_report.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,15 @@ void GetNodeReport(v8::Isolate* isolate,
5757
void ReportEndpoints(uv_handle_t* h, std::ostringstream& out);
5858
void WalkHandle(uv_handle_t* h, void* arg);
5959
std::string EscapeJsonChars(const std::string& str);
60+
6061
template <typename T>
61-
std::string ValueToHexString(T value);
62+
std::string ValueToHexString(T value) {
63+
std::stringstream hex;
64+
65+
hex << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex <<
66+
value;
67+
return hex.str();
68+
}
6269

6370
// Function declarations - export functions in src/node_report_module.cc
6471
void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info);

src/node_report_utils.cc

-9
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,6 @@ void WalkHandle(uv_handle_t* h, void* arg) {
214214
writer->json_end();
215215
}
216216

217-
template <typename T>
218-
std::string ValueToHexString(T value) {
219-
std::stringstream hex;
220-
221-
hex << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex <<
222-
value;
223-
return hex.str();
224-
}
225-
226217
std::string EscapeJsonChars(const std::string& str) {
227218
const std::string control_symbols[0x20] = {
228219
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",

0 commit comments

Comments
 (0)