Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: expose ListNode<T>::prev_ on postmortem metadata #30027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/node_postmortem_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
37 changes: 22 additions & 15 deletions test/cctest/test_node_postmortem_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_);
Expand All @@ -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);
bnoordhuis marked this conversation as resolved.
Show resolved Hide resolved

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.
Expand All @@ -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);

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