[Lldb-commits] [lldb] r268591 - Allow LanguageRuntimes to return an error if they fail in the course of dynamic type discovery
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Wed May 4 18:47:45 PDT 2016
Author: enrico
Date: Wed May 4 20:47:44 2016
New Revision: 268591
URL: http://llvm.org/viewvc/llvm-project?rev=268591&view=rev
Log:
Allow LanguageRuntimes to return an error if they fail in the course of dynamic type discovery
This is not meant to report that a value doesn't have a dynamic type - it is only meant as a mechanism to propagate actual type discovery issues (e.g. malformed type metadata for languages that have such a notion)
This information is used by ValueObjectDynamic to set its own m_error, which is a fairly sharp and heavyweight tool to begin with
For the time being, this is an architectural improvement but a practical no-op as no existing runtimes are actually setting errors
Modified:
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Wed May 4 20:47:44 2016
@@ -54,7 +54,8 @@ public:
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type) = 0;
+ Value::ValueType &value_type,
+ Error &error) = 0;
// This call should return a CompilerType given a generic type name
// and an ExecutionContextScope in which one can actually fetch
Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Wed May 4 20:47:44 2016
@@ -187,23 +187,41 @@ ValueObjectDynamicValue::UpdateValue ()
LanguageRuntime *runtime = nullptr;
lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage();
+
+ Error dynamic_type_discovery_error;
+
if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC)
{
runtime = process->GetLanguageRuntime (known_type);
if (runtime)
- found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent,
+ m_use_dynamic,
+ class_type_or_name,
+ dynamic_address,
+ value_type,
+ dynamic_type_discovery_error);
}
else
{
runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus);
if (runtime)
- found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent,
+ m_use_dynamic,
+ class_type_or_name,
+ dynamic_address,
+ value_type,
+ dynamic_type_discovery_error);
if (!found_dynamic_type)
{
runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC);
if (runtime)
- found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent,
+ m_use_dynamic,
+ class_type_or_name,
+ dynamic_address,
+ value_type,
+ dynamic_type_discovery_error);
}
}
@@ -229,16 +247,24 @@ ValueObjectDynamicValue::UpdateValue ()
m_type_impl.Clear();
}
- // If we don't have a dynamic type, then make ourselves just a echo of our parent.
- // Or we could return false, and make ourselves an echo of our parent?
+ // If we don't have a dynamic type...
if (!found_dynamic_type)
{
- if (m_dynamic_type_info)
- SetValueDidChange(true);
- ClearDynamicTypeInformation();
- m_dynamic_type_info.Clear();
- m_value = m_parent->GetValue();
- m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ // ...and it's not because of an error, let's make ourselves an echo of our parent
+ if (dynamic_type_discovery_error.Success())
+ {
+ if (m_dynamic_type_info)
+ SetValueDidChange(true);
+ ClearDynamicTypeInformation();
+ m_dynamic_type_info.Clear();
+ m_value = m_parent->GetValue();
+ m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ }
+ else
+ {
+ // ...but if it is because of an error, let's report that to the user
+ m_error = dynamic_type_discovery_error;
+ }
return m_error.Success();
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Wed May 4 20:47:44 2016
@@ -53,7 +53,8 @@ ItaniumABILanguageRuntime::GetDynamicTyp
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &dynamic_address,
- Value::ValueType &value_type)
+ Value::ValueType &value_type,
+ Error &error)
{
// 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
@@ -63,6 +64,7 @@ ItaniumABILanguageRuntime::GetDynamicTyp
// start of the value object which holds the dynamic type.
//
+ error.Clear();
class_type_or_name.Clear();
value_type = Value::ValueType::eValueTypeScalar;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Wed May 4 20:47:44 2016
@@ -53,7 +53,8 @@ namespace lldb_private {
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type) override;
+ Value::ValueType &value_type,
+ Error &error) override;
TypeAndOrName
FixUpDynamicType(const TypeAndOrName& type_and_or_name,
Modified: lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp Wed May 4 20:47:44 2016
@@ -140,11 +140,15 @@ GoLanguageRuntime::CouldHaveDynamicValue
}
bool
-GoLanguageRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &dynamic_address,
- Value::ValueType &value_type)
+GoLanguageRuntime::GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &dynamic_address,
+ Value::ValueType &value_type,
+ Error &error)
{
value_type = Value::eValueTypeScalar;
+ error.Clear();
class_type_or_name.Clear();
if (CouldHaveDynamicValue (in_value))
{
Modified: lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h Wed May 4 20:47:44 2016
@@ -61,9 +61,12 @@ namespace lldb_private {
return false;
}
- bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address,
- Value::ValueType &value_type) override;
+ bool GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type,
+ Error &error) override;
bool CouldHaveDynamicValue(ValueObject &in_value) override;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp Wed May 4 20:47:44 2016
@@ -105,10 +105,14 @@ GetDynamicTypeId(ExecutionContext *exe_c
}
bool
-JavaLanguageRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &dynamic_address,
- Value::ValueType &value_type)
+JavaLanguageRuntime::GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &dynamic_address,
+ Value::ValueType &value_type,
+ Error &error)
{
+ error.Clear();
class_type_or_name.Clear();
// null references don't have a dynamic type
Modified: lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h Wed May 4 20:47:44 2016
@@ -74,9 +74,12 @@ public:
CouldHaveDynamicValue(ValueObject &in_value) override;
bool
- GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address,
- Value::ValueType &value_type) override;
+ GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type,
+ Error &error) override;
protected:
JavaLanguageRuntime(Process *process);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Wed May 4 20:47:44 2016
@@ -270,8 +270,10 @@ AppleObjCRuntime::GetDynamicTypeAndAddre
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type)
+ Value::ValueType &value_type,
+ Error &error)
{
+ error.Clear();
return false;
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h Wed May 4 20:47:44 2016
@@ -63,7 +63,8 @@ public:
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type) override;
+ Value::ValueType &value_type,
+ Error &error) override;
TypeAndOrName
FixUpDynamicType (const TypeAndOrName& type_and_or_name,
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Wed May 4 20:47:44 2016
@@ -50,8 +50,10 @@ AppleObjCRuntimeV1::GetDynamicTypeAndAdd
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type)
+ Value::ValueType &value_type,
+ Error &error)
{
+ error.Clear();
class_type_or_name.Clear();
value_type = Value::ValueType::eValueTypeScalar;
if (CouldHaveDynamicValue(in_value))
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Wed May 4 20:47:44 2016
@@ -125,7 +125,8 @@ public:
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type) override;
+ Value::ValueType &value_type,
+ Error &error) override;
UtilityFunction *
CreateObjectChecker(const char *) override;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed May 4 20:47:44 2016
@@ -407,7 +407,8 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAdd
DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type)
+ Value::ValueType &value_type,
+ Error &error)
{
// We should never get here with a null process...
assert (m_process != NULL);
@@ -422,6 +423,7 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAdd
else
assert (in_value.GetTargetSP().get() == m_process->CalculateTarget().get());
+ error.Clear();
class_type_or_name.Clear();
value_type = Value::ValueType::eValueTypeScalar;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Wed May 4 20:47:44 2016
@@ -63,7 +63,8 @@ public:
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address,
- Value::ValueType &value_type) override;
+ Value::ValueType &value_type,
+ Error &error) override;
UtilityFunction *
CreateObjectChecker(const char *) override;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Wed May 4 20:47:44 2016
@@ -906,10 +906,14 @@ RenderScriptRuntime::IsVTableName(const
}
bool
-RenderScriptRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address,
- Value::ValueType &value_type)
+RenderScriptRuntime::GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type,
+ Error &error)
{
+ error.Clear();
return false;
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=268591&r1=268590&r2=268591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h Wed May 4 20:47:44 2016
@@ -178,9 +178,12 @@ public:
IsVTableName(const char *name) override;
bool
- GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address,
- Value::ValueType &value_type) override;
+ GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type,
+ Error &error) override;
TypeAndOrName
FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override;
More information about the lldb-commits
mailing list