forked from OSchip/llvm-project
Make LanguageRuntime::GetDynamicTypeAndAddress return a ValueType
For C++ and ObjC, dynamic values are always (at least somewhat) pointer-like in nature, so a ValueType of scalar is actually good enough that it could originally be hardcoded as the right choice Other languages, might have broader notions of things that are dynamic (e.g. a language where a value type can be dynamic). In those cases, it might actually be the case that a dynamic value is a pointer-to the data, or even a host address if dynamic expression results entirely in host space are being talked about This patch enables the language runtime to make that decision, and makes ValueObjectDynamicValue comply with it llvm-svn: 247957
This commit is contained in:
parent
4151972c22
commit
0b6003f3e6
|
@ -52,7 +52,8 @@ public:
|
|||
GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address) = 0;
|
||||
Address &address,
|
||||
Value::ValueType &value_type) = 0;
|
||||
|
||||
// This should be a fast test to determine whether it is likely that this value would
|
||||
// have a dynamic type.
|
||||
|
|
|
@ -210,25 +210,26 @@ ValueObjectDynamicValue::UpdateValue ()
|
|||
TypeAndOrName class_type_or_name;
|
||||
Address dynamic_address;
|
||||
bool found_dynamic_type = false;
|
||||
Value::ValueType value_type;
|
||||
|
||||
lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage();
|
||||
if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC)
|
||||
{
|
||||
LanguageRuntime *runtime = process->GetLanguageRuntime (known_type);
|
||||
if (runtime)
|
||||
found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
|
||||
found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus);
|
||||
if (cpp_runtime)
|
||||
found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
|
||||
found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
|
||||
|
||||
if (!found_dynamic_type)
|
||||
{
|
||||
LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC);
|
||||
if (objc_runtime)
|
||||
found_dynamic_type = objc_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
|
||||
found_dynamic_type = objc_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,9 +306,7 @@ ValueObjectDynamicValue::UpdateValue ()
|
|||
//m_value.SetContext (Value::eContextTypeClangType, corrected_type);
|
||||
m_value.SetCompilerType (m_dynamic_type_info.GetCompilerType());
|
||||
|
||||
// Our address is the location of the dynamic type stored in memory. It isn't a load address,
|
||||
// because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us...
|
||||
m_value.SetValueType(Value::eValueTypeScalar);
|
||||
m_value.SetValueType(value_type);
|
||||
|
||||
if (has_changed_type && log)
|
||||
log->Printf("[%s %p] has a new dynamic type %s", GetName().GetCString(),
|
||||
|
|
|
@ -47,7 +47,8 @@ bool
|
|||
ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &dynamic_address)
|
||||
Address &dynamic_address,
|
||||
Value::ValueType &value_type)
|
||||
{
|
||||
// For Itanium, if the type has a vtable pointer in the object, it will be at offset 0
|
||||
// in the object. That will point to the "address point" within the vtable (not the beginning of the
|
||||
|
@ -58,6 +59,7 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
|
|||
//
|
||||
|
||||
class_type_or_name.Clear();
|
||||
value_type = Value::ValueType::eValueTypeScalar;
|
||||
|
||||
// Only a pointer or reference type can have a different dynamic and static type:
|
||||
if (CouldHaveDynamicValue (in_value))
|
||||
|
|
|
@ -38,7 +38,8 @@ namespace lldb_private {
|
|||
GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address);
|
||||
Address &address,
|
||||
Value::ValueType &value_type);
|
||||
|
||||
virtual bool
|
||||
CouldHaveDynamicValue (ValueObject &in_value);
|
||||
|
|
|
@ -263,7 +263,8 @@ bool
|
|||
AppleObjCRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address)
|
||||
Address &address,
|
||||
Value::ValueType &value_type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ public:
|
|||
GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address) override;
|
||||
Address &address,
|
||||
Value::ValueType &value_type) override;
|
||||
|
||||
// These are the ObjC specific functions.
|
||||
|
||||
|
|
|
@ -47,11 +47,13 @@ AppleObjCRuntimeV1::AppleObjCRuntimeV1(Process *process) :
|
|||
// required for the data formatters to work
|
||||
bool
|
||||
AppleObjCRuntimeV1::GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address)
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address,
|
||||
Value::ValueType &value_type)
|
||||
{
|
||||
class_type_or_name.Clear();
|
||||
value_type = Value::ValueType::eValueTypeScalar;
|
||||
if (CouldHaveDynamicValue(in_value))
|
||||
{
|
||||
auto class_descriptor(GetClassDescriptor(in_value));
|
||||
|
|
|
@ -100,7 +100,8 @@ public:
|
|||
GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address);
|
||||
Address &address,
|
||||
Value::ValueType &value_type);
|
||||
|
||||
virtual UtilityFunction *
|
||||
CreateObjectChecker (const char *);
|
||||
|
|
|
@ -376,13 +376,15 @@ bool
|
|||
AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address)
|
||||
Address &address,
|
||||
Value::ValueType &value_type)
|
||||
{
|
||||
// The Runtime is attached to a particular process, you shouldn't pass in a value from another process.
|
||||
assert (in_value.GetProcessSP().get() == m_process);
|
||||
assert (m_process != NULL);
|
||||
|
||||
class_type_or_name.Clear();
|
||||
value_type = Value::ValueType::eValueTypeScalar;
|
||||
|
||||
// Make sure we can have a dynamic value before starting...
|
||||
if (CouldHaveDynamicValue (in_value))
|
||||
|
|
|
@ -37,7 +37,8 @@ public:
|
|||
GetDynamicTypeAndAddress (ValueObject &in_value,
|
||||
lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name,
|
||||
Address &address);
|
||||
Address &address,
|
||||
Value::ValueType &value_type);
|
||||
|
||||
virtual UtilityFunction *
|
||||
CreateObjectChecker (const char *);
|
||||
|
|
|
@ -187,7 +187,8 @@ RenderScriptRuntime::IsVTableName(const char *name)
|
|||
|
||||
bool
|
||||
RenderScriptRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name, Address &address)
|
||||
TypeAndOrName &class_type_or_name, Address &address,
|
||||
Value::ValueType &value_type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,8 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
|
|||
virtual bool IsVTableName(const char *name);
|
||||
|
||||
virtual bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
|
||||
TypeAndOrName &class_type_or_name, Address &address);
|
||||
TypeAndOrName &class_type_or_name, Address &address,
|
||||
Value::ValueType &value_type);
|
||||
|
||||
virtual bool CouldHaveDynamicValue(ValueObject &in_value);
|
||||
|
||||
|
|
Loading…
Reference in New Issue