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: make more items programmatically accessible #26019

Closed
wants to merge 2 commits 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
79 changes: 61 additions & 18 deletions doc/api/report.md
Expand Up @@ -78,12 +78,26 @@ is provided below for reference.
]
},
"nativeStack": [
" [pc=0xa7ef87] [/home/nodeuser/project/node/out/Release/node]",
" [pc=0xa81adb] report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::string, v8::Local<v8::String>) [/home/nodeuser/project/node/out/Release/node]",
" [pc=0xa834f2] report::OnUncaughtException(v8::FunctionCallbackInfo<v8::Value> const&) [/home/nodeuser/project/node/out/Release/node]",
" [pc=0xbe6b78] [/home/nodeuser/project/node/out/Release/node]",
" [pc=0xbe7596] v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/home/nodeuser/project/node/out/Release/node]",
" [pc=0x1930cae] [/home/nodeuser/project/node/out/Release/node]"
{
"pc": "0x000055b57f07a9ef",
"symbol": "report::GetNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, v8::Local<v8::String>, std::ostream&) [./node]"
},
{
"pc": "0x000055b57f07cf03",
"symbol": "report::GetReport(v8::FunctionCallbackInfo<v8::Value> const&) [./node]"
},
{
"pc": "0x000055b57f1bccfd",
"symbol": " [./node]"
},
{
"pc": "0x000055b57f1be048",
"symbol": "v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [./node]"
},
{
"pc": "0x000055b57feeda0e",
"symbol": " [./node]"
}
],
"javascriptHeap": {
"totalMemory": 6127616,
Expand Down Expand Up @@ -175,46 +189,75 @@ is provided below for reference.
"details": ""
},
{
"repeat": 0,
"firesInMsFromNow": 94403548320796,
"expired": true,
"type": "timer",
"is_active": false,
"is_referenced": false,
"address": "0x00007fff5fbfeab0",
"details": "repeat: 0, timeout expired: 18075165916 ms ago"
"address": "0x00007fff5fbfeab0"
},
{
"type": "check",
"is_active": true,
"is_referenced": false,
"address": "0x00007fff5fbfeb48",
"details": ""
"address": "0x00007fff5fbfeb48"
},
{
"type": "idle",
"is_active": false,
"is_referenced": true,
"address": "0x00007fff5fbfebc0",
"details": ""
"address": "0x00007fff5fbfebc0"
},
{
"type": "prepare",
"is_active": false,
"is_referenced": false,
"address": "0x00007fff5fbfec38",
"details": ""
"address": "0x00007fff5fbfec38"
},
{
"type": "check",
"is_active": false,
"is_referenced": false,
"address": "0x00007fff5fbfecb0",
"details": ""
"address": "0x00007fff5fbfecb0"
},
{
"type": "async",
"is_active": true,
"is_referenced": false,
"address": "0x000000010188f2e0",
"details": ""
"address": "0x000000010188f2e0"
},
{
"width": 204,
"height": 55,
"fd": 17,
"writeQueueSize": 0,
"readable": true,
"writable": true,
"type": "tty",
"is_active": false,
"is_referenced": true,
"address": "0x000055b581db0e18"
},
{
"signum": 28,
"signal": "SIGWINCH",
"type": "signal",
"is_active": true,
"is_referenced": false,
"address": "0x000055b581d80010"
},
{
"width": 204,
"height": 55,
"fd": 19,
"writeQueueSize": 0,
"readable": true,
"writable": true,
"type": "tty",
"is_active": true,
"is_referenced": true,
"address": "0x000055b581df59f8"
},
{
"type": "loop",
Expand Down
15 changes: 7 additions & 8 deletions src/node_report.cc
Expand Up @@ -216,9 +216,8 @@ void GetNodeReport(Isolate* isolate,
// Obtain the current time and the pid (platform dependent)
TIME_TYPE tm_struct;
LocalTime(&tm_struct);
std::string str = "NA";
WriteNodeReport(
isolate, env, message, location, str, out, stackstr, &tm_struct);
isolate, env, message, location, "", out, stackstr, &tm_struct);
}

// Internal function to coordinate and write the various
Expand Down Expand Up @@ -249,7 +248,7 @@ static void WriteNodeReport(Isolate* isolate,
if (!filename.empty())
writer.json_keyvalue("filename", filename);
else
writer.json_keyvalue("filename", "''");
writer.json_keyvalue("filename", JSONWriter::Null{});

// Report dump event and module load date/time stamps
char timebuf[64];
Expand Down Expand Up @@ -431,13 +430,13 @@ static void PrintNativeStack(JSONWriter* writer) {
const int size = sym_ctx->GetStackTrace(frames, arraysize(frames));
writer->json_arraystart("nativeStack");
int i;
std::ostringstream buf;
for (i = 1; i < size; i++) {
void* frame = frames[i];
buf.str("");
buf << " [pc=" << frame << "] ";
buf << sym_ctx->LookupSymbol(frame).Display().c_str();
writer->json_element(buf.str());
writer->json_start();
writer->json_keyvalue("pc",
ValueToHexString(reinterpret_cast<uintptr_t>(frame)));
writer->json_keyvalue("symbol", sym_ctx->LookupSymbol(frame).Display());
writer->json_end();
}
writer->json_arrayend();
}
Expand Down
4 changes: 3 additions & 1 deletion src/node_report.h
Expand Up @@ -54,7 +54,6 @@ void GetNodeReport(v8::Isolate* isolate,
std::ostream& out);

// Function declarations - utility functions in src/node_report_utils.cc
void ReportEndpoints(uv_handle_t* h, std::ostringstream& out);
void WalkHandle(uv_handle_t* h, void* arg);
std::string EscapeJsonChars(const std::string& str);

Expand Down Expand Up @@ -157,6 +156,8 @@ class JSONWriter {
state_ = kAfterValue;
}

struct Null {}; // Usable as a JSON value.

private:
template <typename T,
typename test_for_number = typename std::
Expand All @@ -168,6 +169,7 @@ class JSONWriter {
out_ << number;
}

inline void write_value(Null null) { out_ << "null"; }
inline void write_value(const char* str) { write_string(str); }
inline void write_value(const std::string& str) { write_string(str); }

Expand Down