Skip to content

Commit 693bf73

Browse files
legendecastargos
authored andcommitted
src: expose ListNode<T>::prev_ on postmortem metadata
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]>
1 parent a86648c commit 693bf73

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/node_postmortem_metadata.cc

+2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
HandleWrap::handle_wrap_queue_) \
2828
V(Environment_HandleWrapQueue, head_, ListNode_HandleWrap, \
2929
Environment::HandleWrapQueue::head_) \
30+
V(ListNode_HandleWrap, prev_, uintptr_t, ListNode<HandleWrap>::prev_) \
3031
V(ListNode_HandleWrap, next_, uintptr_t, ListNode<HandleWrap>::next_) \
3132
V(Environment_ReqWrapQueue, head_, ListNode_ReqWrapQueue, \
3233
Environment::ReqWrapQueue::head_) \
34+
V(ListNode_ReqWrap, prev_, uintptr_t, ListNode<ReqWrapBase>::prev_) \
3335
V(ListNode_ReqWrap, next_, uintptr_t, ListNode<ReqWrapBase>::next_)
3436

3537
extern "C" {

test/cctest/test_node_postmortem_metadata.cc

+22-15
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ extern uintptr_t
1919
extern uintptr_t
2020
nodedbg_offset_Environment__req_wrap_queue___Environment_ReqWrapQueue;
2121
extern uintptr_t nodedbg_offset_ExternalString__data__uintptr_t;
22+
extern uintptr_t nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t;
2223
extern uintptr_t nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
2324
extern uintptr_t nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
25+
extern uintptr_t nodedbg_offset_ListNode_HandleWrap__prev___uintptr_t;
2426
extern uintptr_t nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
2527
extern uintptr_t
2628
nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
@@ -129,6 +131,12 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
129131
const Argv argv;
130132
Env env{handle_scope, argv};
131133

134+
auto queue = reinterpret_cast<uintptr_t>((*env)->handle_wrap_queue());
135+
auto head = queue +
136+
nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
137+
auto tail = head + nodedbg_offset_ListNode_HandleWrap__prev___uintptr_t;
138+
tail = *reinterpret_cast<uintptr_t*>(tail);
139+
132140
uv_tcp_t handle;
133141

134142
auto obj_template = v8::FunctionTemplate::New(isolate_);
@@ -140,16 +148,12 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
140148
.ToLocalChecked();
141149
TestHandleWrap obj(*env, object, &handle);
142150

143-
auto queue = reinterpret_cast<uintptr_t>((*env)->handle_wrap_queue());
144-
auto head = queue +
145-
nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
146-
auto next =
147-
head + nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
148-
next = *reinterpret_cast<uintptr_t*>(next);
151+
auto last = tail + nodedbg_offset_ListNode_HandleWrap__next___uintptr_t;
152+
last = *reinterpret_cast<uintptr_t*>(last);
149153

150154
auto expected = reinterpret_cast<uintptr_t>(&obj);
151-
auto calculated = next -
152-
nodedbg_offset_HandleWrap__handle_wrap_queue___ListNode_HandleWrap;
155+
auto calculated =
156+
last - nodedbg_offset_HandleWrap__handle_wrap_queue___ListNode_HandleWrap;
153157
EXPECT_EQ(expected, calculated);
154158

155159
obj.persistent().Reset(); // ~HandleWrap() expects an empty handle.
@@ -160,6 +164,13 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
160164
const Argv argv;
161165
Env env{handle_scope, argv};
162166

167+
auto queue = reinterpret_cast<uintptr_t>((*env)->req_wrap_queue());
168+
auto head =
169+
queue +
170+
nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
171+
auto tail = head + nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t;
172+
tail = *reinterpret_cast<uintptr_t*>(tail);
173+
163174
auto obj_template = v8::FunctionTemplate::New(isolate_);
164175
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
165176

@@ -174,16 +185,12 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
174185
// ARM64 CI machinies.
175186
for (auto it : *(*env)->req_wrap_queue()) (void) &it;
176187

177-
auto queue = reinterpret_cast<uintptr_t>((*env)->req_wrap_queue());
178-
auto head = queue +
179-
nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue;
180-
auto next =
181-
head + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
182-
next = *reinterpret_cast<uintptr_t*>(next);
188+
auto last = tail + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t;
189+
last = *reinterpret_cast<uintptr_t*>(last);
183190

184191
auto expected = reinterpret_cast<uintptr_t>(&obj);
185192
auto calculated =
186-
next - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
193+
last - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
187194
EXPECT_EQ(expected, calculated);
188195

189196
obj.Dispatched();

0 commit comments

Comments
 (0)