Nodejs v12 support by mmarchini · Pull Request #330 · nodejs/llnode · GitHub
Skip to content
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
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
Loading