summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgengjiawen <technicalcute@gmail.com>2019-04-23 22:50:54 +0800
committerMichaƫl Zasso <targos@protonmail.com>2019-04-27 12:04:36 +0200
commit38f3526f27c91181ec80ea488c177a49252aeb12 (patch)
tree6187fb53ff3c6b0c735a27afe72d76dd1ae2264b
parent31ac8b9080d6c5808f1f47ffa7a33d2ca09fa6f2 (diff)
downloadandroid-node-v8-38f3526f27c91181ec80ea488c177a49252aeb12.tar.gz
android-node-v8-38f3526f27c91181ec80ea488c177a49252aeb12.tar.bz2
android-node-v8-38f3526f27c91181ec80ea488c177a49252aeb12.zip
report: print common items first for readability
PR-URL: https://github.com/nodejs/node/pull/27367 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
-rw-r--r--doc/api/report.md34
-rw-r--r--src/node_report_utils.cc10
-rw-r--r--test/report/test-report-uv-handles.js16
3 files changed, 38 insertions, 22 deletions
diff --git a/doc/api/report.md b/doc/api/report.md
index 90ec1b7f18..40e3050ee4 100644
--- a/doc/api/report.md
+++ b/doc/api/report.md
@@ -190,13 +190,13 @@ is provided below for reference.
"details": ""
},
{
- "repeat": 0,
- "firesInMsFromNow": 94403548320796,
- "expired": true,
"type": "timer",
"is_active": false,
"is_referenced": false,
- "address": "0x00007fff5fbfeab0"
+ "address": "0x00007fff5fbfeab0",
+ "repeat": 0,
+ "firesInMsFromNow": 94403548320796,
+ "expired": true
},
{
"type": "check",
@@ -229,36 +229,36 @@ is provided below for reference.
"address": "0x000000010188f2e0"
},
{
+ "type": "tty",
+ "is_active": false,
+ "is_referenced": true,
+ "address": "0x000055b581db0e18",
"width": 204,
"height": 55,
"fd": 17,
"writeQueueSize": 0,
"readable": true,
- "writable": true,
- "type": "tty",
- "is_active": false,
- "is_referenced": true,
- "address": "0x000055b581db0e18"
+ "writable": true
},
{
- "signum": 28,
- "signal": "SIGWINCH",
"type": "signal",
"is_active": true,
"is_referenced": false,
- "address": "0x000055b581d80010"
+ "address": "0x000055b581d80010",
+ "signum": 28,
+ "signal": "SIGWINCH"
},
{
+ "type": "tty",
+ "is_active": true,
+ "is_referenced": true,
+ "address": "0x000055b581df59f8",
"width": 204,
"height": 55,
"fd": 19,
"writeQueueSize": 0,
"readable": true,
- "writable": true,
- "type": "tty",
- "is_active": true,
- "is_referenced": true,
- "address": "0x000055b581df59f8"
+ "writable": true
},
{
"type": "loop",
diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc
index 81fdeda040..24f3b6175d 100644
--- a/src/node_report_utils.cc
+++ b/src/node_report_utils.cc
@@ -126,6 +126,11 @@ void WalkHandle(uv_handle_t* h, void* arg) {
uv_any_handle* handle = reinterpret_cast<uv_any_handle*>(h);
writer->json_start();
+ writer->json_keyvalue("type", type);
+ 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",
+ ValueToHexString(reinterpret_cast<uint64_t>(h)));
switch (h->type) {
case UV_FS_EVENT:
@@ -216,11 +221,6 @@ void WalkHandle(uv_handle_t* h, void* arg) {
static_cast<bool>(uv_is_writable(&handle->stream)));
}
- writer->json_keyvalue("type", type);
- 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",
- ValueToHexString(reinterpret_cast<uint64_t>(h)));
writer->json_end();
}
diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js
index f03791f134..5167716894 100644
--- a/test/report/test-report-uv-handles.js
+++ b/test/report/test-report-uv-handles.js
@@ -97,6 +97,22 @@ if (process.argv[2] === 'child') {
const reports = helper.findReports(child.pid, tmpdir.path);
assert.deepStrictEqual(reports, [], report_msg, reports);
+ // Test libuv handle key order
+ {
+ const get_libuv = /"libuv":\s\[([\s\S]*?)\]/gm;
+ const get_handle_inner = /{([\s\S]*?),*?}/gm;
+ const libuv_handles_str = get_libuv.exec(stdout)[1];
+ const libuv_handles_array = libuv_handles_str.match(get_handle_inner);
+ for (const i of libuv_handles_array) {
+ // Exclude nested structure
+ if (i.includes('type')) {
+ const handle_keys = i.match(/(".*"):/gm);
+ assert(handle_keys[0], 'type');
+ assert(handle_keys[1], 'is_active');
+ }
+ }
+ }
+
const report = JSON.parse(stdout);
const prefix = common.isWindows ? '\\\\?\\' : '';
const expected_filename = `${prefix}${__filename}`;