Skip to content

Commit 674bc6f

Browse files
committed
[lldb] Make ValueObjectDynamicValue::UpdateValue() point to a host b… (llvm#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 (cherry picked from commit 0cbc498)
1 parent 9fbb19c commit 674bc6f

File tree

17 files changed

+341
-40
lines changed

17 files changed

+341
-40
lines changed

lldb/include/lldb/Target/LanguageRuntime.h

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

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

116120
// This call should return a CompilerType given a generic type name and an
117121
// 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
@@ -869,6 +869,18 @@ class ValueObject {
869869

870870
virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
871871

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ llvm::Expected<LanguageRuntime::VTableInfo>
288288
bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
289289
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
290290
TypeAndOrName &class_type_or_name, Address &dynamic_address,
291-
Value::ValueType &value_type) {
291+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
292292
// For Itanium, if the type has a vtable pointer in the object, it will be at
293293
// offset 0 in the object. That will point to the "address point" within the
294294
// 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
@@ -775,7 +775,7 @@ AppleObjCRuntimeV2::GetPreferredLanguageRuntime(ValueObject &in_value) {
775775
bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
776776
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
777777
TypeAndOrName &class_type_or_name, Address &address,
778-
Value::ValueType &value_type) {
778+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
779779
// We should never get here with a null process...
780780
assert(m_process != nullptr);
781781

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)