summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2014-02-28 22:27:53 +0000
committerSean Callanan <scallanan@apple.com>2014-02-28 22:27:53 +0000
commit866e91c9d44428b41089932506ab985a571ca0e1 (patch)
tree2da4e9dda29ea1484cdd097df995f8675c8c98b2 /lldb/source
parent525a21237927b95f1afc8205c5e06388e145c696 (diff)
downloadbcm5719-llvm-866e91c9d44428b41089932506ab985a571ca0e1.tar.gz
bcm5719-llvm-866e91c9d44428b41089932506ab985a571ca0e1.zip
Better error reporting when a variable can't be
read during materialization. First of all, report if we can't read the data for some reason. Second, consult the ValueObject's error and report that if there's some problem. <rdar://problem/16074201> llvm-svn: 202552
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBValue.cpp5
-rw-r--r--lldb/source/Core/ValueObject.cpp9
-rw-r--r--lldb/source/DataFormatters/CXXFormatterFunctions.cpp28
-rw-r--r--lldb/source/DataFormatters/LibCxxList.cpp6
-rw-r--r--lldb/source/DataFormatters/LibCxxMap.cpp8
-rw-r--r--lldb/source/DataFormatters/LibCxxUnorderedMap.cpp5
-rw-r--r--lldb/source/DataFormatters/TypeFormat.cpp17
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp2
-rw-r--r--lldb/source/Expression/Materializer.cpp28
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp8
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp8
-rw-r--r--lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp18
12 files changed, 116 insertions, 26 deletions
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 4bd018352ff..c379508ab05 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -1569,8 +1569,9 @@ SBValue::GetData ()
if (value_sp)
{
DataExtractorSP data_sp(new DataExtractor());
- value_sp->GetData(*data_sp);
- if (data_sp->GetByteSize() > 0)
+ Error error;
+ value_sp->GetData(*data_sp, error);
+ if (error.Success())
*sb_data = data_sp;
}
if (log)
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 10e5ab452f0..f58271c0638 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -978,14 +978,15 @@ ValueObject::GetPointeeData (DataExtractor& data,
ValueObjectSP pointee_sp = Dereference(error);
if (error.Fail() || pointee_sp.get() == NULL)
return 0;
- return pointee_sp->GetData(data);
+ return pointee_sp->GetData(data, error);
}
else
{
ValueObjectSP child_sp = GetChildAtIndex(0, true);
if (child_sp.get() == NULL)
return 0;
- return child_sp->GetData(data);
+ Error error;
+ return child_sp->GetData(data, error);
}
return true;
}
@@ -1059,11 +1060,11 @@ ValueObject::GetPointeeData (DataExtractor& data,
}
uint64_t
-ValueObject::GetData (DataExtractor& data)
+ValueObject::GetData (DataExtractor& data, Error &error)
{
UpdateValueIfNeeded(false);
ExecutionContext exe_ctx (GetExecutionContextRef());
- Error error = m_value.GetValueAsData(&exe_ctx, data, 0, GetModule().get());
+ error = m_value.GetValueAsData(&exe_ctx, data, 0, GetModule().get());
if (error.Fail())
{
if (m_data.GetByteSize())
diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
index 136c8c51e66..04f090dd15b 100644
--- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
+++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
@@ -576,7 +576,11 @@ bool
lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream)
{
DataExtractor data;
- valobj.GetData(data);
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
std::string value;
valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
@@ -590,7 +594,11 @@ bool
lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream)
{
DataExtractor data;
- valobj.GetData(data);
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
std::string value;
valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
@@ -604,7 +612,11 @@ bool
lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream)
{
DataExtractor data;
- valobj.GetData(data);
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
clang::ASTContext* ast = valobj.GetClangType().GetASTContext();
@@ -1144,7 +1156,10 @@ lldb_private::formatters::NSAttributedStringSummaryProvider (ValueObject& valobj
if (!child_ptr_sp)
return false;
DataExtractor data;
- child_ptr_sp->GetData(data);
+ Error error;
+ child_ptr_sp->GetData(data, error);
+ if (error.Fail())
+ return false;
ValueObjectSP child_sp(child_ptr_sp->CreateValueObjectFromData("string_data", data, exe_ctx, type));
child_sp->GetValueAsUnsigned(0);
if (child_sp)
@@ -1218,7 +1233,10 @@ lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& s
else
{
DataExtractor data;
- valobj.GetData(data);
+ Error error;
+ valobj.GetData(data, error);
+ if (error.Fail())
+ return false;
valobj_sp = ValueObject::CreateValueObjectFromData("text", data, exe_ctx, charstar);
}
diff --git a/lldb/source/DataFormatters/LibCxxList.cpp b/lldb/source/DataFormatters/LibCxxList.cpp
index 9ec8a785598..e542a98103f 100644
--- a/lldb/source/DataFormatters/LibCxxList.cpp
+++ b/lldb/source/DataFormatters/LibCxxList.cpp
@@ -257,7 +257,11 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_
return lldb::ValueObjectSP();
// we need to copy current_sp into a new object otherwise we will end up with all items named __value_
DataExtractor data;
- current_sp->GetData(data);
+ Error error;
+ current_sp->GetData(data, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
StreamString name;
name.Printf("[%zu]",idx);
return (m_children[idx] = ValueObject::CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type));
diff --git a/lldb/source/DataFormatters/LibCxxMap.cpp b/lldb/source/DataFormatters/LibCxxMap.cpp
index 5daa40f15f3..7d5c94f38e8 100644
--- a/lldb/source/DataFormatters/LibCxxMap.cpp
+++ b/lldb/source/DataFormatters/LibCxxMap.cpp
@@ -366,7 +366,13 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t
// at this point we have a valid
// we need to copy current_sp into a new object otherwise we will end up with all items named __value_
DataExtractor data;
- iterated_sp->GetData(data);
+ Error error;
+ iterated_sp->GetData(data, error);
+ if (error.Fail())
+ {
+ m_tree = NULL;
+ return lldb::ValueObjectSP();
+ }
StreamString name;
name.Printf("[%zu]",idx);
return (m_children[idx] = ValueObject::CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type));
diff --git a/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp b/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp
index 05b41d0de0c..99cd08e346e 100644
--- a/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp
+++ b/lldb/source/DataFormatters/LibCxxUnorderedMap.cpp
@@ -83,7 +83,10 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtInde
StreamString stream;
stream.Printf("[%zu]",idx);
DataExtractor data;
- val_hash.first->GetData(data);
+ Error error;
+ val_hash.first->GetData(data, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
const bool thread_and_frame_only_if_stopped = true;
ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped);
return val_hash.first->CreateValueObjectFromData(stream.GetData(),
diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp
index a72f551c741..1648a16dd1b 100644
--- a/lldb/source/DataFormatters/TypeFormat.cpp
+++ b/lldb/source/DataFormatters/TypeFormat.cpp
@@ -64,7 +64,10 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj,
const RegisterInfo *reg_info = value.GetRegisterInfo();
if (reg_info)
{
- valobj->GetData(data);
+ Error error;
+ valobj->GetData(data, error);
+ if (error.Fail())
+ return false;
StreamString reg_sstr;
data.Dump (&reg_sstr,
@@ -105,7 +108,12 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj,
}
}
else
- valobj->GetData(data);
+ {
+ Error error;
+ valobj->GetData(data, error);
+ if (error.Fail())
+ return false;
+ }
StreamString sstr;
clang_type.DumpTypeValue (&sstr, // The stream to use for display
@@ -203,7 +211,10 @@ TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj,
if (valobj_enum_type.IsValid() == false)
return false;
DataExtractor data;
- valobj->GetData(data);
+ Error error;
+ valobj->GetData(data, error);
+ if (error.Fail())
+ return false;
ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
StreamString sstr;
valobj_enum_type.DumpTypeValue(&sstr,
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index 6b0eee8cf36..6586d10b187 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -709,7 +709,7 @@ ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream,
if (!materialize_error.Success())
{
- error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString());
+ error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());
return false;
}
}
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 90687c0739d..25ffd7b4b19 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -443,10 +443,26 @@ public:
return;
}
+ Error valobj_error = valobj_sp->GetError();
+
+ if (valobj_error.Fail())
+ {
+ err.SetErrorStringWithFormat("couldn't get the value of variable %s: %s", m_variable_sp->GetName().AsCString(), valobj_error.AsCString());
+ return;
+ }
+
if (m_is_reference)
{
DataExtractor valobj_extractor;
- valobj_sp->GetData(valobj_extractor);
+ Error extract_error;
+ valobj_sp->GetData(valobj_extractor, extract_error);
+
+ if (!extract_error.Success())
+ {
+ err.SetErrorStringWithFormat("couldn't read contents of reference variable %s: %s", m_variable_sp->GetName().AsCString(), extract_error.AsCString());
+ return;
+ }
+
lldb::offset_t offset = 0;
lldb::addr_t reference_addr = valobj_extractor.GetAddress(&offset);
@@ -478,8 +494,14 @@ public:
else
{
DataExtractor data;
- valobj_sp->GetData(data);
-
+ Error extract_error;
+ valobj_sp->GetData(data, extract_error);
+ if (!extract_error.Success())
+ {
+ err.SetErrorStringWithFormat("couldn't get the value of %s: %s", m_variable_sp->GetName().AsCString(), extract_error.AsCString());
+ return;
+ }
+
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
err.SetErrorStringWithFormat("trying to create a temporary region for %s but one exists", m_variable_sp->GetName().AsCString());
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index abf873ff3dd..c884b84e662 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -522,7 +522,13 @@ ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
{
DataExtractor data;
- size_t num_bytes = new_value_sp->GetData(data);
+ Error data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail())
+ {
+ error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString());
+ return error;
+ }
lldb::offset_t offset = 0;
if (num_bytes <= 8)
{
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 8596381b3cb..17834891983 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -600,7 +600,13 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
{
DataExtractor data;
- size_t num_bytes = new_value_sp->GetData(data);
+ Error data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail())
+ {
+ error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString());
+ return error;
+ }
lldb::offset_t offset = 0;
if (num_bytes <= 8)
{
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index a8ef6a51399..763a00aa9a7 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -562,7 +562,13 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0);
DataExtractor data;
- size_t num_bytes = new_value_sp->GetData(data);
+ Error data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail())
+ {
+ error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString());
+ return error;
+ }
lldb::offset_t offset = 0;
if (num_bytes <= 8)
{
@@ -589,8 +595,14 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
RegisterValue xmm0_value;
DataExtractor data;
- size_t num_bytes = new_value_sp->GetData(data);
-
+ Error data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail())
+ {
+ error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString());
+ return error;
+ }
+
unsigned char buffer[16];
ByteOrder byte_order = data.GetByteOrder();
OpenPOWER on IntegriCloud