Skip to content

Fix Pavel's patch for ValueObjectVariables with complex DWARF express… #1437

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
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
7 changes: 7 additions & 0 deletions lldb/include/lldb/Core/ValueObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,13 @@ class ValueObject : public UserID {

void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);

void UpdateChildrenAddressType() {
GetRoot()->DoUpdateChildrenAddressType(*this);
}

protected:
virtual void DoUpdateChildrenAddressType(ValueObject &valobj) { return; };

private:
virtual CompilerType MaybeCalculateCompleteType();

Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Core/ValueObjectVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class ValueObjectVariable : public ValueObject {

protected:
bool UpdateValue() override;

void DoUpdateChildrenAddressType(ValueObject &valobj) override;

CompilerType GetCompilerTypeImpl() override;

Expand Down
55 changes: 55 additions & 0 deletions lldb/source/Core/ValueObjectVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,64 @@ bool ValueObjectVariable::UpdateValue() {
m_resolved_value.SetContext(Value::eContextTypeInvalid, nullptr);
}
}

return m_error.Success();
}

void ValueObjectVariable::DoUpdateChildrenAddressType(ValueObject &valobj) {
Value::ValueType value_type = valobj.GetValue().GetValueType();
ExecutionContext exe_ctx(GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
const uint32_t type_info = valobj.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)
valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
else
valobj.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)
valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
else
valobj.SetAddressTypeOfChildren(eAddressTypeHost);
break;
case Value::eValueTypeLoadAddress:
case Value::eValueTypeScalar:
case Value::eValueTypeVector:
valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
break;
}
}



bool ValueObjectVariable::IsInScope() {
const ExecutionContextRef &exe_ctx_ref = GetExecutionContextRef();
if (exe_ctx_ref.HasFrameRef()) {
Expand Down