summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlegendecas <legendecas@gmail.com>2019-10-18 23:38:14 +0800
committerRich Trott <rtrott@gmail.com>2019-10-22 13:45:42 -0500
commit45efe67a84d382fed3c86d56f56beffc6bb0a136 (patch)
tree90360a25046fe19e7409e4fe8410bc77198fa882
parent639085e410e805303b4511edee4c2a315006a7f8 (diff)
downloadandroid-node-v8-45efe67a84d382fed3c86d56f56beffc6bb0a136.tar.gz
android-node-v8-45efe67a84d382fed3c86d56f56beffc6bb0a136.tar.bz2
android-node-v8-45efe67a84d382fed3c86d56f56beffc6bb0a136.zip
src: expose ListNode<T>::prev_ on postmortem metadata
Make ListNode<T> postmortem easier to find last items in the queue. PR-URL: https://github.com/nodejs/node/pull/30027 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
-rw-r--r--src/node_postmortem_metadata.cc2
-rw-r--r--test/cctest/test_node_postmortem_metadata.cc37
2 files changed, 24 insertions, 15 deletions
diff --git a/src/node_postmortem_metadata.cc b/src/node_postmortem_metadata.cc
index 05800f79b0..ccb347e951 100644
--- a/src/node_postmortem_metadata.cc
+++ b/src/node_postmortem_metadata.cc
@@ -27,9 +27,11 @@
HandleWrap::handle_wrap_queue_) \
V(Environment_HandleWrapQueue, head_, ListNode_HandleWrap, \
Environment::HandleWrapQueue::head_) \
+ V(ListNode_HandleWrap, prev_, uintptr_t, ListNode<HandleWrap>::prev_) \
V(ListNode_HandleWrap, next_, uintptr_t, ListNode<HandleWrap>::next_) \
V(Environment_ReqWrapQueue, head_, ListNode_ReqWrapQueue, \
Environment::ReqWrapQueue::head_) \
+ V(ListNode_ReqWrap, prev_, uintptr_t, ListNode<ReqWrapBase>::prev_) \
V(ListNode_ReqWrap, next_, uintptr_t, ListNode<ReqWrapBase>::next_)
extern "C" {
diff --git a/test/cctest/test_node_postmortem_metadata.cc b/test/cctest/test_node_postmortem_metadata.cc
index 79b766939b..f33d40eb5c 100644
--- a/test/cctest/test_node_postmortem_metadata.cc
+++ b/test/cctest/test_node_postmortem_metadata.cc
@@ -19,8 +19,10 @@ extern uintptr_t
extern uintptr_t
nodedbg_offset_Environment__req_wrap_queue___Environment_ReqWrapQueue;
extern uintptr_t nodedbg_offset_ExternalString__data__uintptr_t;
+extern uintptr_t nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t;
extern uintptr_t nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
extern uintptr_t nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
+extern uintptr_t nodedbg_offset_ListNode_HandleWrap__prev___uintptr_t;
extern uintptr_t nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
extern uintptr_t
nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
@@ -129,6 +131,12 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
const Argv argv;
Env env{handle_scope, argv};
+ auto queue = reinterpret_cast<uintptr_t>((*env)->handle_wrap_queue());
+ auto head = queue +
+ nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
+ auto tail = head + nodedbg_offset_ListNode_HandleWrap__prev___uintptr_t;
+ tail = *reinterpret_cast<uintptr_t*>(tail);
+
uv_tcp_t handle;
auto obj_template = v8::FunctionTemplate::New(isolate_);
@@ -140,16 +148,12 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
.ToLocalChecked();
TestHandleWrap obj(*env, object, &handle);
- auto queue = reinterpret_cast<uintptr_t>((*env)->handle_wrap_queue());
- auto head = queue +
- nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
- auto next =
- head + nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
- next = *reinterpret_cast<uintptr_t*>(next);
+ auto last = tail + nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
+ last = *reinterpret_cast<uintptr_t*>(last);
auto expected = reinterpret_cast<uintptr_t>(&obj);
- auto calculated = next -
- nodedbg_offset_HandleWrap__handle_wrap_queue___ListNode_HandleWrap;
+ auto calculated =
+ last - nodedbg_offset_HandleWrap__handle_wrap_queue___ListNode_HandleWrap;
EXPECT_EQ(expected, calculated);
obj.persistent().Reset(); // ~HandleWrap() expects an empty handle.
@@ -160,6 +164,13 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
const Argv argv;
Env env{handle_scope, argv};
+ auto queue = reinterpret_cast<uintptr_t>((*env)->req_wrap_queue());
+ auto head =
+ queue +
+ nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
+ auto tail = head + nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t;
+ tail = *reinterpret_cast<uintptr_t*>(tail);
+
auto obj_template = v8::FunctionTemplate::New(isolate_);
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
@@ -174,16 +185,12 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
// ARM64 CI machinies.
for (auto it : *(*env)->req_wrap_queue()) (void) &it;
- auto queue = reinterpret_cast<uintptr_t>((*env)->req_wrap_queue());
- auto head = queue +
- nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
- auto next =
- head + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
- next = *reinterpret_cast<uintptr_t*>(next);
+ auto last = tail + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
+ last = *reinterpret_cast<uintptr_t*>(last);
auto expected = reinterpret_cast<uintptr_t>(&obj);
auto calculated =
- next - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
+ last - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
EXPECT_EQ(expected, calculated);
obj.Dispatched();