★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/dfd47aa1e8Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
report: make more items programmatically accessible
Prefer structured output over stringified information
for libuv handles and the native stack trace.

PR-URL: #26019
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Feb 13, 2019
1 parent 23868ba commit dfd47aa1e8668c981e87d79a2fc3d0be40858789
Showing with 132 additions and 75 deletions.
  1. +61 −18 doc/api/report.md
  2. +7 −8 src/node_report.cc
  3. +3 −1 src/node_report.h
  4. +61 −48 src/node_report_utils.cc
@@ -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,
@@ -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",
@@ -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
@@ -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];
@@ -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();
}
@@ -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);

@@ -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::
@@ -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); }

Loading

0 comments on commit dfd47aa

Please sign in to comment.