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

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Oct 18, 2019

Make ListNode<T> postmortem easier to find last items in the queue.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 18, 2019
@addaleax
Copy link
Member

Does this come from some other PR? I feel like I’ve seen this before 😄

@legendecas
Copy link
Member Author

@addaleax Yes, I extracted them from #29207, since there are no longer failures for #29207 to pass the test without this improvement.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this approach isn't wrong, you could also export the offset of the prev_ field and then use that:

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

And then:

diff --git a/test/cctest/test_node_postmortem_metadata.cc b/test/cctest/test_node_postmortem_metadata.cc
index 79b766939b..0eac0240cd 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;
@@ -143,12 +145,12 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
   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 prev =
+      head + nodedbg_offset_ListNode_HandleWrap__prev___uintptr_t;
+  prev = *reinterpret_cast<uintptr_t*>(prev);
 
   auto expected = reinterpret_cast<uintptr_t>(&obj);
-  auto calculated = next -
+  auto calculated = prev -
       nodedbg_offset_HandleWrap__handle_wrap_queue___ListNode_HandleWrap;
   EXPECT_EQ(expected, calculated);
 
@@ -177,13 +179,13 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
   auto queue = reinterpret_cast<uintptr_t>((*env)->req_wrap_queue());
   auto head = queue +
       nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
-  auto next =
+  auto prev =
       head + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
-  next = *reinterpret_cast<uintptr_t*>(next);
+  prev = *reinterpret_cast<uintptr_t*>(prev);
 
   auto expected = reinterpret_cast<uintptr_t>(&obj);
   auto calculated =
-      next - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
+      prev - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
   EXPECT_EQ(expected, calculated);
 
   obj.Dispatched();

If nothing else, the logic should probably also be updated for the ReqWrap list.

Make ListNode<T> postmortem easier to find last items in the queue.
@legendecas legendecas changed the title test: loose postmortem handle wrap queue assertion src: expose ListNode<T>::prev_ on postmortem metadata Oct 19, 2019
@legendecas
Copy link
Member Author

@bnoordhuis That would be much simpler.

I've updated the patch to also make sure coverage on both metadata (the next and prev).

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Oct 22, 2019

Landed in 45efe67

@Trott Trott closed this Oct 22, 2019
Trott pushed a commit that referenced this pull request Oct 22, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 23, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 23, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Oct 23, 2019
@legendecas legendecas deleted the test-postmortem branch October 27, 2019 15:59
targos pushed a commit that referenced this pull request Nov 8, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
targos pushed a commit that referenced this pull request Nov 10, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
targos pushed a commit that referenced this pull request Nov 11, 2019
Make ListNode<T> postmortem easier to find last items in the queue.

PR-URL: #30027
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants