Skip to content

Commit 0cbc498

Browse files
authored
[lldb] Make ValueObjectDynamicValue::UpdateValue() point to a host b… (#125143)
…uffer ValueObjectDynamicValue::UpdateValue() assumes that the dynamic type found by GetDynamicTypeAndAddress() would return an address in the inferior. This commit makes it so it can deal with being passed a host address instead. This is needed downstream by the Swift fork. rdar://143357274
1 parent 6f50849 commit 0cbc498

File tree

17 files changed

+342
-41
lines changed

17 files changed

+342
-41
lines changed

lldb/include/lldb/Target/LanguageRuntime.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ class LanguageRuntime : public Runtime, public PluginInterface {
105105
"language doesn't support getting vtable information");
106106
}
107107

108-
// this call should return true if it could set the name and/or the type
109-
virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
110-
lldb::DynamicValueType use_dynamic,
111-
TypeAndOrName &class_type_or_name,
112-
Address &address,
113-
Value::ValueType &value_type) = 0;
108+
/// This call should return true if it could set the name and/or the type
109+
/// Sets address to the address of the dynamic type if value_type is set to
110+
/// a file or load address. Sets local_buffer to a buffer containing the data
111+
/// of the dynamic type if value_type is set to a host address. Callers should
112+
/// copy local_buffer over into their own buffer if they want to keep the data
113+
/// alive.
114+
virtual bool GetDynamicTypeAndAddress(
115+
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
116+
TypeAndOrName &class_type_or_name, Address &address,
117+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) = 0;
114118

115119
// This call should return a CompilerType given a generic type name and an
116120
// ExecutionContextScope in which one can actually fetch any specialization

lldb/include/lldb/ValueObject/ValueObject.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,18 @@ class ValueObject {
865865

866866
virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
867867

868+
/// Returns the size of the local buffer if it's available.
869+
/// \return
870+
/// The size of the local buffer if this value object's value points to a
871+
/// host address, and if that size can be determined. Otherwise, returns
872+
/// LLDB_INVALID_ADDRESS.
873+
///
874+
/// TODO: Because a ValueObject's Value can point to any arbitrary memory
875+
/// location, it is possible that the size of the local buffer can't be
876+
/// determined at all. See the comment in Value::m_value for a more thorough
877+
/// explanation of why that is.
878+
uint64_t GetLocalBufferSize();
879+
868880
protected:
869881
typedef ClusterManager<ValueObject> ValueObjectManager;
870882

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ llvm::Expected<LanguageRuntime::VTableInfo>
289289
bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
290290
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
291291
TypeAndOrName &class_type_or_name, Address &dynamic_address,
292-
Value::ValueType &value_type) {
292+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
293293
// For Itanium, if the type has a vtable pointer in the object, it will be at
294294
// offset 0 in the object. That will point to the "address point" within the
295295
// vtable (not the beginning of the vtable.) We can then look up the symbol

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime {
5454
bool GetDynamicTypeAndAddress(ValueObject &in_value,
5555
lldb::DynamicValueType use_dynamic,
5656
TypeAndOrName &class_type_or_name,
57-
Address &address,
58-
Value::ValueType &value_type) override;
57+
Address &address, Value::ValueType &value_type,
58+
llvm::ArrayRef<uint8_t> &local_buffer) override;
5959

6060
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
6161
ValueObject &static_value) override;

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ bool AppleObjCRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
276276
bool AppleObjCRuntime::GetDynamicTypeAndAddress(
277277
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
278278
TypeAndOrName &class_type_or_name, Address &address,
279-
Value::ValueType &value_type) {
279+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
280280
return false;
281281
}
282282

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime {
5454
bool GetDynamicTypeAndAddress(ValueObject &in_value,
5555
lldb::DynamicValueType use_dynamic,
5656
TypeAndOrName &class_type_or_name,
57-
Address &address,
58-
Value::ValueType &value_type) override;
57+
Address &address, Value::ValueType &value_type,
58+
llvm::ArrayRef<uint8_t> &local_buffer) override;
5959

6060
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
6161
ValueObject &static_value) override;

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ AppleObjCRuntimeV1::AppleObjCRuntimeV1(Process *process)
4848
bool AppleObjCRuntimeV1::GetDynamicTypeAndAddress(
4949
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
5050
TypeAndOrName &class_type_or_name, Address &address,
51-
Value::ValueType &value_type) {
51+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
5252
class_type_or_name.Clear();
5353
value_type = Value::ValueType::Scalar;
5454
if (CouldHaveDynamicValue(in_value)) {

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class AppleObjCRuntimeV1 : public AppleObjCRuntime {
100100
bool GetDynamicTypeAndAddress(ValueObject &in_value,
101101
lldb::DynamicValueType use_dynamic,
102102
TypeAndOrName &class_type_or_name,
103-
Address &address,
104-
Value::ValueType &value_type) override;
103+
Address &address, Value::ValueType &value_type,
104+
llvm::ArrayRef<uint8_t> &local_buffer) override;
105105

106106
llvm::Expected<std::unique_ptr<UtilityFunction>>
107107
CreateObjectChecker(std::string, ExecutionContext &exe_ctx) override;

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ AppleObjCRuntimeV2::GetPreferredLanguageRuntime(ValueObject &in_value) {
770770
bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
771771
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
772772
TypeAndOrName &class_type_or_name, Address &address,
773-
Value::ValueType &value_type) {
773+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
774774
// We should never get here with a null process...
775775
assert(m_process != nullptr);
776776

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
5353
bool GetDynamicTypeAndAddress(ValueObject &in_value,
5454
lldb::DynamicValueType use_dynamic,
5555
TypeAndOrName &class_type_or_name,
56-
Address &address,
57-
Value::ValueType &value_type) override;
56+
Address &address, Value::ValueType &value_type,
57+
llvm::ArrayRef<uint8_t> &local_buffer) override;
5858

5959
llvm::Expected<std::unique_ptr<UtilityFunction>>
6060
CreateObjectChecker(std::string name, ExecutionContext &exe_ctx) override;

0 commit comments

Comments
 (0)