Skip to content

Commit 0b66ff3

Browse files
authored
Merge pull request #48 from JDevlieghere/revert-valueobject
Revert "ValueObject: Fix a crash related to children address type com…
2 parents ea51a1a + 57cd1f6 commit 0b66ff3

File tree

4 files changed

+45
-167
lines changed

4 files changed

+45
-167
lines changed

lldb/include/lldb/Core/ValueObject.h

-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ class ValueObject : public UserID {
990990

991991
private:
992992
virtual CompilerType MaybeCalculateCompleteType();
993-
void UpdateChildrenAddressType();
994993

995994
lldb::ValueObjectSP GetValueForExpressionPath_Impl(
996995
llvm::StringRef expression_cstr,

lldb/lit/SymbolFile/DWARF/DW_OP_piece-struct.s

-113
This file was deleted.

lldb/source/Core/ValueObject.cpp

-53
Original file line numberDiff line numberDiff line change
@@ -152,58 +152,6 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
152152
// Destructor
153153
ValueObject::~ValueObject() {}
154154

155-
void ValueObject::UpdateChildrenAddressType() {
156-
Value::ValueType value_type = m_value.GetValueType();
157-
ExecutionContext exe_ctx(GetExecutionContextRef());
158-
Process *process = exe_ctx.GetProcessPtr();
159-
const bool process_is_alive = process && process->IsAlive();
160-
const uint32_t type_info = GetCompilerType().GetTypeInfo();
161-
const bool is_pointer_or_ref =
162-
(type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
163-
164-
switch (value_type) {
165-
case Value::eValueTypeFileAddress:
166-
// If this type is a pointer, then its children will be considered load
167-
// addresses if the pointer or reference is dereferenced, but only if
168-
// the process is alive.
169-
//
170-
// There could be global variables like in the following code:
171-
// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
172-
// Foo g_foo1;
173-
// Foo g_foo2;
174-
// LinkedListNode g_second_node = { &g_foo2, NULL };
175-
// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
176-
//
177-
// When we aren't running, we should be able to look at these variables
178-
// using the "target variable" command. Children of the "g_first_node"
179-
// always will be of the same address type as the parent. But children
180-
// of the "next" member of LinkedListNode will become load addresses if
181-
// we have a live process, or remain a file address if it was a file
182-
// address.
183-
if (process_is_alive && is_pointer_or_ref)
184-
SetAddressTypeOfChildren(eAddressTypeLoad);
185-
else
186-
SetAddressTypeOfChildren(eAddressTypeFile);
187-
break;
188-
case Value::eValueTypeHostAddress:
189-
// Same as above for load addresses, except children of pointer or refs
190-
// are always load addresses. Host addresses are used to store freeze
191-
// dried variables. If this type is a struct, the entire struct
192-
// contents will be copied into the heap of the
193-
// LLDB process, but we do not currently follow any pointers.
194-
if (is_pointer_or_ref)
195-
SetAddressTypeOfChildren(eAddressTypeLoad);
196-
else
197-
SetAddressTypeOfChildren(eAddressTypeHost);
198-
break;
199-
case Value::eValueTypeLoadAddress:
200-
case Value::eValueTypeScalar:
201-
case Value::eValueTypeVector:
202-
SetAddressTypeOfChildren(eAddressTypeLoad);
203-
break;
204-
}
205-
}
206-
207155
bool ValueObject::UpdateValueIfNeeded(bool update_format) {
208156

209157
bool did_change_formats = false;
@@ -275,7 +223,6 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {
275223
SetValueIsValid(success);
276224

277225
if (success) {
278-
UpdateChildrenAddressType();
279226
const uint64_t max_checksum_size = 128;
280227
m_data.Checksum(m_value_checksum, max_checksum_size);
281228
} else {

lldb/source/Core/ValueObjectVariable.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,51 @@ bool ValueObjectVariable::UpdateValue() {
190190

191191
Process *process = exe_ctx.GetProcessPtr();
192192
const bool process_is_alive = process && process->IsAlive();
193+
const uint32_t type_info = compiler_type.GetTypeInfo();
194+
const bool is_pointer_or_ref =
195+
(type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
196+
197+
switch (value_type) {
198+
case Value::eValueTypeFileAddress:
199+
// If this type is a pointer, then its children will be considered load
200+
// addresses if the pointer or reference is dereferenced, but only if
201+
// the process is alive.
202+
//
203+
// There could be global variables like in the following code:
204+
// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
205+
// Foo g_foo1;
206+
// Foo g_foo2;
207+
// LinkedListNode g_second_node = { &g_foo2, NULL };
208+
// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
209+
//
210+
// When we aren't running, we should be able to look at these variables
211+
// using the "target variable" command. Children of the "g_first_node"
212+
// always will be of the same address type as the parent. But children
213+
// of the "next" member of LinkedListNode will become load addresses if
214+
// we have a live process, or remain what a file address if it what a
215+
// file address.
216+
if (process_is_alive && is_pointer_or_ref)
217+
SetAddressTypeOfChildren(eAddressTypeLoad);
218+
else
219+
SetAddressTypeOfChildren(eAddressTypeFile);
220+
break;
221+
case Value::eValueTypeHostAddress:
222+
// Same as above for load addresses, except children of pointer or refs
223+
// are always load addresses. Host addresses are used to store freeze
224+
// dried variables. If this type is a struct, the entire struct
225+
// contents will be copied into the heap of the
226+
// LLDB process, but we do not currently follow any pointers.
227+
if (is_pointer_or_ref)
228+
SetAddressTypeOfChildren(eAddressTypeLoad);
229+
else
230+
SetAddressTypeOfChildren(eAddressTypeHost);
231+
break;
232+
case Value::eValueTypeLoadAddress:
233+
case Value::eValueTypeScalar:
234+
case Value::eValueTypeVector:
235+
SetAddressTypeOfChildren(eAddressTypeLoad);
236+
break;
237+
}
193238

194239
// BEGIN Swift
195240
if (variable->GetType() && variable->GetType()->IsSwiftFixedValueBuffer())

0 commit comments

Comments
 (0)