diff options
author | cjihrig <cjihrig@gmail.com> | 2019-02-03 12:07:35 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-02-05 12:09:45 -0500 |
commit | 2ed556c11f1092e1207d3bba2dc01b29a61017a6 (patch) | |
tree | 24f5ae9f4f183c538b217ea2ea4a6178bc0cf89a /src | |
parent | 63ab54248b7dbd315d3e196b456073efd248fc89 (diff) | |
download | android-node-v8-2ed556c11f1092e1207d3bba2dc01b29a61017a6.tar.gz android-node-v8-2ed556c11f1092e1207d3bba2dc01b29a61017a6.tar.bz2 android-node-v8-2ed556c11f1092e1207d3bba2dc01b29a61017a6.zip |
report: print libuv handle addresses as hex
PR-URL: https://github.com/nodejs/node/pull/25910
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_report.h | 4 | ||||
-rw-r--r-- | src/node_report_utils.cc | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/node_report.h b/src/node_report.h index ac4b304b77..9b67dcf1c5 100644 --- a/src/node_report.h +++ b/src/node_report.h @@ -53,10 +53,12 @@ void GetNodeReport(v8::Isolate* isolate, v8::Local<v8::String> 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 <typename T> +std::string ValueToHexString(T value); // Function declarations - export functions in src/node_report_module.cc void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info); diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index b86c633657..d013eb9167 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<bool>(uv_is_active(h))); writer->json_keyvalue("is_referenced", static_cast<bool>(uv_has_ref(h))); writer->json_keyvalue("address", - std::to_string(reinterpret_cast<int64_t>(h))); + ValueToHexString(reinterpret_cast<uint64_t>(h))); writer->json_keyvalue("details", data.str()); 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", |