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 BaseObject::kInternalFieldCount in post-mortem metadata #37111

Closed
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
3 changes: 3 additions & 0 deletions src/node_postmortem_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

extern "C" {
int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
int nodedbg_const_BaseObject__kInternalFieldCount__int;
uintptr_t nodedbg_offset_ExternalString__data__uintptr_t;
uintptr_t nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;

Expand All @@ -50,6 +51,8 @@ namespace node {
int GenDebugSymbols() {
nodedbg_const_ContextEmbedderIndex__kEnvironment__int =
ContextEmbedderIndex::kEnvironment;
nodedbg_const_BaseObject__kInternalFieldCount__int =
BaseObject::kInternalFieldCount;

nodedbg_offset_ExternalString__data__uintptr_t = NODE_OFF_EXTSTR_DATA;
nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue =
Expand Down
16 changes: 13 additions & 3 deletions test/cctest/test_node_postmortem_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern uintptr_t
nodedbg_offset_Environment__handle_wrap_queue___Environment_HandleWrapQueue;
extern int debug_symbols_generated;
extern int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
extern int nodedbg_const_BaseObject__kInternalFieldCount__int;
extern uintptr_t
nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
extern uintptr_t
Expand Down Expand Up @@ -68,6 +69,12 @@ TEST_F(DebugSymbolsTest, ContextEmbedderEnvironmentIndex) {
kEnvironmentIndex);
}

TEST_F(DebugSymbolsTest, BaseObjectkInternalFieldCount) {
int kInternalFieldCount = node::BaseObject::kInternalFieldCount;
EXPECT_EQ(nodedbg_const_BaseObject__kInternalFieldCount__int,
kInternalFieldCount);
}

TEST_F(DebugSymbolsTest, ExternalStringDataOffset) {
EXPECT_EQ(nodedbg_offset_ExternalString__data__uintptr_t,
NODE_OFF_EXTSTR_DATA);
Expand All @@ -89,7 +96,8 @@ TEST_F(DebugSymbolsTest, BaseObjectPersistentHandle) {
Env env{handle_scope, argv};

v8::Local<v8::ObjectTemplate> obj_templ = v8::ObjectTemplate::New(isolate_);
obj_templ->SetInternalFieldCount(1);
obj_templ->SetInternalFieldCount(
nodedbg_const_BaseObject__kInternalFieldCount__int);

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

auto obj_template = v8::FunctionTemplate::New(isolate_);
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
obj_template->InstanceTemplate()->SetInternalFieldCount(
nodedbg_const_BaseObject__kInternalFieldCount__int);

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

auto obj_template = v8::FunctionTemplate::New(isolate_);
obj_template->InstanceTemplate()->SetInternalFieldCount(1);
obj_template->InstanceTemplate()->SetInternalFieldCount(
nodedbg_const_BaseObject__kInternalFieldCount__int);

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