Skip to content

Commit 1ecdb66

Browse files
joyeecheungtargos
authored andcommitted
src: expose BaseObject::kInternalFieldCount in post-mortem metadata
So that the debugger does not have to hard-code the number of internal fields of BaseObjects. PR-URL: #37111 Refs: #36943 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 35cf86c commit 1ecdb66

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/node_postmortem_metadata.cc

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
extern "C" {
3838
int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
39+
int nodedbg_const_BaseObject__kInternalFieldCount__int;
3940
uintptr_t nodedbg_offset_ExternalString__data__uintptr_t;
4041
uintptr_t nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
4142

@@ -50,6 +51,8 @@ namespace node {
5051
int GenDebugSymbols() {
5152
nodedbg_const_ContextEmbedderIndex__kEnvironment__int =
5253
ContextEmbedderIndex::kEnvironment;
54+
nodedbg_const_BaseObject__kInternalFieldCount__int =
55+
BaseObject::kInternalFieldCount;
5356

5457
nodedbg_offset_ExternalString__data__uintptr_t = NODE_OFF_EXTSTR_DATA;
5558
nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue =

test/cctest/test_node_postmortem_metadata.cc

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern uintptr_t
1414
nodedbg_offset_Environment__handle_wrap_queue___Environment_HandleWrapQueue;
1515
extern int debug_symbols_generated;
1616
extern int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
17+
extern int nodedbg_const_BaseObject__kInternalFieldCount__int;
1718
extern uintptr_t
1819
nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
1920
extern uintptr_t
@@ -68,6 +69,12 @@ TEST_F(DebugSymbolsTest, ContextEmbedderEnvironmentIndex) {
6869
kEnvironmentIndex);
6970
}
7071

72+
TEST_F(DebugSymbolsTest, BaseObjectkInternalFieldCount) {
73+
int kInternalFieldCount = node::BaseObject::kInternalFieldCount;
74+
EXPECT_EQ(nodedbg_const_BaseObject__kInternalFieldCount__int,
75+
kInternalFieldCount);
76+
}
77+
7178
TEST_F(DebugSymbolsTest, ExternalStringDataOffset) {
7279
EXPECT_EQ(nodedbg_offset_ExternalString__data__uintptr_t,
7380
NODE_OFF_EXTSTR_DATA);
@@ -89,7 +96,8 @@ TEST_F(DebugSymbolsTest, BaseObjectPersistentHandle) {
8996
Env env{handle_scope, argv};
9097

9198
v8::Local<v8::ObjectTemplate> obj_templ = v8::ObjectTemplate::New(isolate_);
92-
obj_templ->SetInternalFieldCount(1);
99+
obj_templ->SetInternalFieldCount(
100+
nodedbg_const_BaseObject__kInternalFieldCount__int);
93101

94102
v8::Local<v8::Object> object =
95103
obj_templ->NewInstance(env.context()).ToLocalChecked();
@@ -139,7 +147,8 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
139147
uv_tcp_t handle;
140148

141149
auto obj_template = v8::FunctionTemplate::New(isolate_);
142-
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
150+
obj_template->InstanceTemplate()->SetInternalFieldCount(
151+
nodedbg_const_BaseObject__kInternalFieldCount__int);
143152

144153
v8::Local<v8::Object> object = obj_template->GetFunction(env.context())
145154
.ToLocalChecked()
@@ -171,7 +180,8 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
171180
tail = *reinterpret_cast<uintptr_t*>(tail);
172181

173182
auto obj_template = v8::FunctionTemplate::New(isolate_);
174-
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
183+
obj_template->InstanceTemplate()->SetInternalFieldCount(
184+
nodedbg_const_BaseObject__kInternalFieldCount__int);
175185

176186
v8::Local<v8::Object> object = obj_template->GetFunction(env.context())
177187
.ToLocalChecked()

0 commit comments

Comments
 (0)