diff --git a/doc/api/report.md b/doc/api/report.md index d41fca20ef5a74..a49d33d65e262b 100644 --- a/doc/api/report.md +++ b/doc/api/report.md @@ -171,49 +171,49 @@ is provided below for reference. "type": "async", "is_active": true, "is_referenced": false, - "address": "68090592", + "address": "0x0000000102910900", "details": "" }, { "type": "timer", "is_active": false, "is_referenced": false, - "address": "140723513949920", + "address": "0x00007fff5fbfeab0", "details": "repeat: 0, timeout expired: 18075165916 ms ago" }, { "type": "check", "is_active": true, "is_referenced": false, - "address": "140723513950072", + "address": "0x00007fff5fbfeb48", "details": "" }, { "type": "idle", "is_active": false, "is_referenced": true, - "address": "140723513950192", + "address": "0x00007fff5fbfebc0", "details": "" }, { "type": "prepare", "is_active": false, "is_referenced": false, - "address": "140723513950312", + "address": "0x00007fff5fbfec38", "details": "" }, { "type": "check", "is_active": false, "is_referenced": false, - "address": "140723513950432", + "address": "0x00007fff5fbfecb0", "details": "" }, { "type": "async", "is_active": true, "is_referenced": false, - "address": "39353856", + "address": "0x000000010188f2e0", "details": "" } ], diff --git a/src/node_report.h b/src/node_report.h index ac4b304b77d488..9b67dcf1c5b305 100644 --- a/src/node_report.h +++ b/src/node_report.h @@ -53,10 +53,12 @@ void GetNodeReport(v8::Isolate* isolate, v8::Local stackstr, std::ostream& out); -// Function declarations - utility functions in src/utilities.cc +// 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); +template +std::string ValueToHexString(T value); // Function declarations - export functions in src/node_report_module.cc void TriggerReport(const v8::FunctionCallbackInfo& info); diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index b86c633657da54..d013eb91677323 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -209,11 +209,20 @@ void WalkHandle(uv_handle_t* h, void* arg) { writer->json_keyvalue("is_active", static_cast(uv_is_active(h))); writer->json_keyvalue("is_referenced", static_cast(uv_has_ref(h))); writer->json_keyvalue("address", - std::to_string(reinterpret_cast(h))); + ValueToHexString(reinterpret_cast(h))); writer->json_keyvalue("details", data.str()); writer->json_end(); } +template +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",