Skip to content

Revert "ValueObject: Fix a crash related to children address type com… #48

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

Merged
merged 1 commit into from
Oct 29, 2019
Merged
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
1 change: 0 additions & 1 deletion lldb/include/lldb/Core/ValueObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@ class ValueObject : public UserID {

private:
virtual CompilerType MaybeCalculateCompleteType();
void UpdateChildrenAddressType();

lldb::ValueObjectSP GetValueForExpressionPath_Impl(
llvm::StringRef expression_cstr,
Expand Down
113 changes: 0 additions & 113 deletions lldb/lit/SymbolFile/DWARF/DW_OP_piece-struct.s

This file was deleted.

53 changes: 0 additions & 53 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,58 +152,6 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
// Destructor
ValueObject::~ValueObject() {}

void ValueObject::UpdateChildrenAddressType() {
Value::ValueType value_type = m_value.GetValueType();
ExecutionContext exe_ctx(GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
const uint32_t type_info = GetCompilerType().GetTypeInfo();
const bool is_pointer_or_ref =
(type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;

switch (value_type) {
case Value::eValueTypeFileAddress:
// If this type is a pointer, then its children will be considered load
// addresses if the pointer or reference is dereferenced, but only if
// the process is alive.
//
// There could be global variables like in the following code:
// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
// Foo g_foo1;
// Foo g_foo2;
// LinkedListNode g_second_node = { &g_foo2, NULL };
// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
//
// When we aren't running, we should be able to look at these variables
// using the "target variable" command. Children of the "g_first_node"
// always will be of the same address type as the parent. But children
// of the "next" member of LinkedListNode will become load addresses if
// we have a live process, or remain a file address if it was a file
// address.
if (process_is_alive && is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeFile);
break;
case Value::eValueTypeHostAddress:
// Same as above for load addresses, except children of pointer or refs
// are always load addresses. Host addresses are used to store freeze
// dried variables. If this type is a struct, the entire struct
// contents will be copied into the heap of the
// LLDB process, but we do not currently follow any pointers.
if (is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeHost);
break;
case Value::eValueTypeLoadAddress:
case Value::eValueTypeScalar:
case Value::eValueTypeVector:
SetAddressTypeOfChildren(eAddressTypeLoad);
break;
}
}

bool ValueObject::UpdateValueIfNeeded(bool update_format) {

bool did_change_formats = false;
Expand Down Expand Up @@ -275,7 +223,6 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {
SetValueIsValid(success);

if (success) {
UpdateChildrenAddressType();
const uint64_t max_checksum_size = 128;
m_data.Checksum(m_value_checksum, max_checksum_size);
} else {
Expand Down
45 changes: 45 additions & 0 deletions lldb/source/Core/ValueObjectVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,51 @@ bool ValueObjectVariable::UpdateValue() {

Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
const uint32_t type_info = compiler_type.GetTypeInfo();
const bool is_pointer_or_ref =
(type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;

switch (value_type) {
case Value::eValueTypeFileAddress:
// If this type is a pointer, then its children will be considered load
// addresses if the pointer or reference is dereferenced, but only if
// the process is alive.
//
// There could be global variables like in the following code:
// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
// Foo g_foo1;
// Foo g_foo2;
// LinkedListNode g_second_node = { &g_foo2, NULL };
// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
//
// When we aren't running, we should be able to look at these variables
// using the "target variable" command. Children of the "g_first_node"
// always will be of the same address type as the parent. But children
// of the "next" member of LinkedListNode will become load addresses if
// we have a live process, or remain what a file address if it what a
// file address.
if (process_is_alive && is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeFile);
break;
case Value::eValueTypeHostAddress:
// Same as above for load addresses, except children of pointer or refs
// are always load addresses. Host addresses are used to store freeze
// dried variables. If this type is a struct, the entire struct
// contents will be copied into the heap of the
// LLDB process, but we do not currently follow any pointers.
if (is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeHost);
break;
case Value::eValueTypeLoadAddress:
case Value::eValueTypeScalar:
case Value::eValueTypeVector:
SetAddressTypeOfChildren(eAddressTypeLoad);
break;
}

// BEGIN Swift
if (variable->GetType() && variable->GetType()->IsSwiftFixedValueBuffer())
Expand Down