Skip to content

Commit 31c4cc7

Browse files
committed
Revert "ValueObject: Fix a crash related to children address type computation"
This reverts commit 3116987.
1 parent cfc1c45 commit 31c4cc7

File tree

4 files changed

+45
-167
lines changed

4 files changed

+45
-167
lines changed

lldb/include/lldb/Core/ValueObject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ class ValueObject : public UserID {
973973

974974
private:
975975
virtual CompilerType MaybeCalculateCompleteType();
976-
void UpdateChildrenAddressType();
977976

978977
lldb::ValueObjectSP GetValueForExpressionPath_Impl(
979978
llvm::StringRef expression_cstr,

lldb/source/Core/ValueObject.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -155,58 +155,6 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
155155
// Destructor
156156
ValueObject::~ValueObject() {}
157157

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

212160
bool did_change_formats = false;
@@ -280,7 +228,6 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {
280228
SetValueIsValid(success);
281229

282230
if (success) {
283-
UpdateChildrenAddressType();
284231
const uint64_t max_checksum_size = 128;
285232
m_data.Checksum(m_value_checksum, max_checksum_size);
286233
} else {

lldb/source/Core/ValueObjectVariable.cpp

Lines changed: 45 additions & 0 deletions
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())

lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-struct.s

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)