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>
pull/30069/head
legendecas 2019-10-18 23:38:14 +08:00 committed by Rich Trott
parent 639085e410
commit 45efe67a84
2 changed files with 24 additions and 15 deletions

View File

@ -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" {

View File

@ -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();