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

Nodejs v12 support #330

Closed
wants to merge 9 commits 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
3 changes: 1 addition & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:
fail-fast: false
matrix:
node:
- version: 8.x
- version: 10.x
- version: 11.x
- version: 12.x
- version: 14.x
mirror: https://nodejs.org/download/nightly
- version: 14.x
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "llnode",
"version": "2.2.0",
"version": "3.0.0",
"description": "An lldb plugin for Node.js and V8, which enables inspection of JavaScript states for insights into Node.js processes and their core dumps.",
"main": "index.js",
"directories": {
Expand Down
2 changes: 0 additions & 2 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class Constant {

inline std::string name() { return name_; }

protected:
friend class Constants;
explicit Constant(T value) : value_(value), status_(kValid), name_("") {}
Constant(T value, std::string name)
: value_(value), status_(kLoaded), name_(name) {}
Expand Down
6 changes: 3 additions & 3 deletions src/llscan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ bool FindJSObjectsVisitor::MapCacheEntry::Load(v8::Map map,
if (is_histogram) type_name = heap_object.GetTypeName(err);

v8::HeapObject descriptors_obj = map.InstanceDescriptors(err);
if (err.Fail()) return false;
RETURN_IF_INVALID(descriptors_obj, false);

v8::DescriptorArray descriptors(descriptors_obj);
own_descriptors_count_ = map.NumberOfOwnDescriptors(err);
Expand All @@ -1579,8 +1579,8 @@ bool FindJSObjectsVisitor::MapCacheEntry::Load(v8::Map map,
}

for (uint64_t i = 0; i < own_descriptors_count_; i++) {
v8::Value key = descriptors.GetKey(i, err);
if (err.Fail()) continue;
v8::Value key = descriptors.GetKey(i);
if (!key.Check()) continue;
properties_.emplace_back(key.ToString(err));
}

Expand Down
112 changes: 87 additions & 25 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void Map::Load() {
"class_Map__constructor__Object");
kInstanceDescriptorsOffset = LoadConstant({
"class_Map__instance_descriptors__DescriptorArray",
"class_Map__instance_descriptors_offset",
});
kBitField3Offset =
LoadConstant("class_Map__bit_field3__int", "class_Map__bit_field3__SMI");
Expand Down Expand Up @@ -322,18 +323,22 @@ void TwoByteString::Load() {


void ConsString::Load() {
kFirstOffset = LoadConstant("class_ConsString__first__String");
kSecondOffset = LoadConstant("class_ConsString__second__String");
kFirstOffset = LoadConstant({"class_ConsString__first__String",
"class_ConsString__first_offset__int"});
kSecondOffset = LoadConstant({"class_ConsString__second__String",
"class_ConsString__second_offset__int"});
}


void SlicedString::Load() {
kParentOffset = LoadConstant("class_SlicedString__parent__String");
kOffsetOffset = LoadConstant("class_SlicedString__offset__SMI");
kOffsetOffset = LoadConstant({"class_SlicedString__offset__SMI",
"class_SlicedString__offset_offset__int"});
}

void ThinString::Load() {
kActualOffset = LoadConstant("class_ThinString__actual__String");
kActualOffset = LoadConstant({"class_ThinString__actual__String",
"class_ThinString__actual_offset__int"});
}

void FixedArrayBase::Load() {
Expand All @@ -347,12 +352,26 @@ void FixedArray::Load() {


void FixedTypedArrayBase::Load() {
kBasePointerOffset = LoadOptionalConstant(
{"class_FixedTypedArrayBase__base_pointer__Object"}, 0);
kExternalPointerOffset = LoadOptionalConstant(
{"class_FixedTypedArrayBase__external_pointer__Object",
"class_FixedTypedArrayBase__external_pointer__uintptr_t"},
0);
}

void JSTypedArray::Load() {
kBasePointerOffset =
LoadConstant("class_FixedTypedArrayBase__base_pointer__Object");
kExternalPointerOffset =
LoadConstant("class_FixedTypedArrayBase__external_pointer__Object");
LoadOptionalConstant({"class_JSTypedArray__base_pointer__Object"}, 0);
kExternalPointerOffset = LoadOptionalConstant(
{"class_JSTypedArray__external_pointer__uintptr_t"}, 0);
}

// TODO(mmarchini): proper validation so that we log an error if neither classes
// were able to load their constants.
bool JSTypedArray::IsDataPointerInJSTypedArray() {
return kBasePointerOffset.Loaded() && kExternalPointerOffset.Loaded();
}

void Oddball::Load() {
kKindOffset = LoadConstant("class_Oddball__kind_offset__int");
Expand All @@ -369,19 +388,15 @@ void Oddball::Load() {

void JSArrayBuffer::Load() {
kBackingStoreOffset =
LoadConstant("class_JSArrayBuffer__backing_store__Object");
kByteLengthOffset = LoadConstant("class_JSArrayBuffer__byte_length__Object");

// v4 compatibility fix
if (kBackingStoreOffset == -1) {
common_->Load();
LoadConstant({"class_JSArrayBuffer__backing_store__Object",
"class_JSArrayBuffer__backing_store__uintptr_t"});
kByteLengthOffset =
LoadConstant({"class_JSArrayBuffer__byte_length__Object",
"class_JSArrayBuffer__byte_length__size_t"});

kBackingStoreOffset = kByteLengthOffset + common_->kPointerSize;
if (kBackingStoreOffset.Check()) {
}

kBitFieldOffset = kBackingStoreOffset + common_->kPointerSize;
if (common_->kPointerSize == 8) kBitFieldOffset += 4;

kWasNeuteredMask = LoadConstant("jsarray_buffer_was_neutered_mask");
kWasNeuteredShift = LoadConstant("jsarray_buffer_was_neutered_shift");

Expand All @@ -393,19 +408,45 @@ void JSArrayBuffer::Load() {
}


bool JSArrayBuffer::IsByteLengthScalar() {
return kByteLengthOffset.name() ==
"v8dbg_class_JSArrayBuffer__byte_length__size_t";
}

Constant<int64_t> JSArrayBuffer::BitFieldOffset() {
if (!kBackingStoreOffset.Check()) return Constant<int64_t>();

common_->Load();
int64_t kBitFieldOffset = *kBackingStoreOffset + common_->kPointerSize;
if (common_->kPointerSize == 8) kBitFieldOffset += 4;
return Constant<int64_t>(kBitFieldOffset);
}


void JSArrayBufferView::Load() {
kBufferOffset = LoadConstant("class_JSArrayBufferView__buffer__Object");
kByteOffsetOffset =
LoadConstant("class_JSArrayBufferView__raw_byte_offset__Object");
LoadConstant({"class_JSArrayBufferView__raw_byte_offset__Object",
"class_JSArrayBufferView__byte_offset__size_t"});
kByteLengthOffset =
LoadConstant("class_JSArrayBufferView__raw_byte_length__Object");
LoadConstant({"class_JSArrayBufferView__raw_byte_length__Object",
"class_JSArrayBufferView__byte_length__size_t"});
}

bool JSArrayBufferView::IsByteLengthScalar() {
return kByteLengthOffset.name() ==
"v8dbg_class_JSArrayBufferView__byte_length__size_t";
}

bool JSArrayBufferView::IsByteOffsetScalar() {
return kByteOffsetOffset.name() ==
"v8dbg_class_JSArrayBufferView__byte_offset__size_t";
}

void DescriptorArray::Load() {
kDetailsOffset = LoadConstant("prop_desc_details");
kKeyOffset = LoadConstant("prop_desc_key");
kValueOffset = LoadConstant("prop_desc_value");
kDetailsOffset = LoadConstant({"prop_desc_details"});
kKeyOffset = LoadConstant({"prop_desc_key"});
kValueOffset = LoadConstant({"prop_desc_value"});

kPropertyIndexMask = LoadConstant("prop_index_mask");
kPropertyIndexShift = LoadConstant("prop_index_shift");
Expand Down Expand Up @@ -455,8 +496,12 @@ void DescriptorArray::Load() {
kRepresentationDouble = 7;
}

kFirstIndex = LoadConstant("prop_idx_first");
kSize = LoadConstant("prop_desc_size");
// NOTE(mmarchini): removed from V8 7.2.
// https://github.com/v8/v8/commit/1ad0cd5
kFirstIndex = LoadOptionalConstant({"prop_idx_first"}, 0);
kSize = LoadConstant({"prop_desc_size"});
kHeaderSize = LoadOptionalConstant(
{"class_DescriptorArray__header_size__uintptr_t"}, 24);
}


Expand Down Expand Up @@ -505,7 +550,24 @@ void Frame::Load() {


void Symbol::Load() {
kNameOffset = LoadConstant("class_Symbol__name__Object");
// map is the last field of HeapObject
Constant<int64_t> maybe_name_offset =
LoadConstant({"class_HeapObject__map__Map"});
common_->Load();
if (maybe_name_offset.Check()) {
int name_offset = *maybe_name_offset;

name_offset += common_->kPointerSize;
// class Name extends HeapObject and has only one uint32 field
name_offset += sizeof(uint32_t);
// class Symbol extends Name and has one int32 field before name
name_offset += sizeof(int32_t);

kNameOffset =
LoadOptionalConstant({"class_Symbol__name__Object"}, name_offset);
} else {
kNameOffset = LoadConstant({"class_Symbol__name__Object"});
}
}


Expand Down
54 changes: 37 additions & 17 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ class ConsString : public Module {
public:
CONSTANTS_DEFAULT_METHODS(ConsString);

int64_t kFirstOffset;
int64_t kSecondOffset;
Constant<int64_t> kFirstOffset;
Constant<int64_t> kSecondOffset;

protected:
void Load();
Expand All @@ -308,7 +308,7 @@ class SlicedString : public Module {
CONSTANTS_DEFAULT_METHODS(SlicedString);

int64_t kParentOffset;
int64_t kOffsetOffset;
Constant<int64_t> kOffsetOffset;

protected:
void Load();
Expand All @@ -318,7 +318,7 @@ class ThinString : public Module {
public:
CONSTANTS_DEFAULT_METHODS(ThinString);

int64_t kActualOffset;
Constant<int64_t> kActualOffset;

protected:
void Load();
Expand Down Expand Up @@ -348,8 +348,21 @@ class FixedTypedArrayBase : public Module {
public:
CONSTANTS_DEFAULT_METHODS(FixedTypedArrayBase);

int64_t kBasePointerOffset;
int64_t kExternalPointerOffset;
Constant<int64_t> kBasePointerOffset;
Constant<int64_t> kExternalPointerOffset;

protected:
void Load();
};

class JSTypedArray : public Module {
public:
CONSTANTS_DEFAULT_METHODS(JSTypedArray);

Constant<int64_t> kBasePointerOffset;
Constant<int64_t> kExternalPointerOffset;

bool IsDataPointerInJSTypedArray();

protected:
void Load();
Expand Down Expand Up @@ -379,13 +392,15 @@ class JSArrayBuffer : public Module {

int64_t kKindOffset;

int64_t kBackingStoreOffset;
int64_t kByteLengthOffset;
int64_t kBitFieldOffset;
Constant<int64_t> kBackingStoreOffset;
Constant<int64_t> kByteLengthOffset;

int64_t kWasNeuteredMask;
int64_t kWasNeuteredShift;

Constant<int64_t> BitFieldOffset();
bool IsByteLengthScalar();

protected:
void Load();
};
Expand All @@ -395,8 +410,11 @@ class JSArrayBufferView : public Module {
CONSTANTS_DEFAULT_METHODS(JSArrayBufferView);

int64_t kBufferOffset;
int64_t kByteOffsetOffset;
int64_t kByteLengthOffset;
Constant<int64_t> kByteOffsetOffset;
Constant<int64_t> kByteLengthOffset;

bool IsByteLengthScalar();
bool IsByteOffsetScalar();

protected:
void Load();
Expand All @@ -406,9 +424,9 @@ class DescriptorArray : public Module {
public:
CONSTANTS_DEFAULT_METHODS(DescriptorArray);

int64_t kDetailsOffset;
int64_t kKeyOffset;
int64_t kValueOffset;
Constant<int64_t> kDetailsOffset;
Constant<int64_t> kKeyOffset;
Constant<int64_t> kValueOffset;

int64_t kPropertyIndexMask;
int64_t kPropertyIndexShift;
Expand All @@ -417,8 +435,10 @@ class DescriptorArray : public Module {

int64_t kRepresentationDouble;

int64_t kFirstIndex;
int64_t kSize;
Constant<int64_t> kFirstIndex;
Constant<int64_t> kHeaderSize;
Constant<int64_t> kSize;
Constant<int64_t> kEntrySize;

// node.js <= 7
int64_t kPropertyTypeMask = -1;
Expand Down Expand Up @@ -489,7 +509,7 @@ class Symbol : public Module {
public:
CONSTANTS_DEFAULT_METHODS(Symbol);

int64_t kNameOffset;
Constant<int64_t> kNameOffset;

protected:
void Load();
Expand Down
Loading