Author: spyffe
Date: Fri Feb 28 16:27:53 2014
New Revision: 202552
URL: http://llvm.org/viewvc/llvm-project?rev=202552&view=rev
Log:
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>
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
lldb/trunk/source/DataFormatters/LibCxxList.cpp
lldb/trunk/source/DataFormatters/LibCxxMap.cpp
lldb/trunk/source/DataFormatters/LibCxxUnorderedMap.cpp
lldb/trunk/source/DataFormatters/TypeFormat.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Expression/Materializer.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Feb 28 16:27:53 2014
@@ -793,7 +793,7 @@ public:
uint32_t item_count = 1);
virtual uint64_t
- GetData (DataExtractor& data);
+ GetData (DataExtractor& data, Error &error);
virtual bool
SetData (DataExtractor &data, Error &error);
Modified: lldb/trunk/source/API/SBValue.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Fri Feb 28 16:27:53 2014
@@ -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)
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Feb 28 16:27:53 2014
@@ -978,14 +978,15 @@ ValueObject::GetPointeeData (DataExtract
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 (DataExtract
}
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())
Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Fri Feb 28
16:27:53 2014
@@ -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::NSAttributedSt
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::ObjCSELSummary
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);
}
Modified: lldb/trunk/source/DataFormatters/LibCxxList.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxList.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxList.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxList.cpp Fri Feb 28 16:27:53 2014
@@ -257,7 +257,11 @@ lldb_private::formatters::LibcxxStdListS
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));
Modified: lldb/trunk/source/DataFormatters/LibCxxMap.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxMap.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxMap.cpp Fri Feb 28 16:27:53 2014
@@ -366,7 +366,13 @@ lldb_private::formatters::LibcxxStdMapSy
// 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));
Modified: lldb/trunk/source/DataFormatters/LibCxxUnorderedMap.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxUnorderedMap.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxUnorderedMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxUnorderedMap.cpp Fri Feb 28 16:27:53
2014
@@ -83,7 +83,10 @@ lldb_private::formatters::LibcxxStdUnord
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(),
Modified: lldb/trunk/source/DataFormatters/TypeFormat.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeFormat.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeFormat.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeFormat.cpp Fri Feb 28 16:27:53 2014
@@ -64,7 +64,10 @@ TypeFormatImpl_Format::FormatObject (Val
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 (®_sstr,
@@ -105,7 +108,12 @@ TypeFormatImpl_Format::FormatObject (Val
}
}
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 (V
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,
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Feb 28 16:27:53
2014
@@ -709,7 +709,7 @@ ClangUserExpression::PrepareToExecuteJIT
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;
}
}
Modified: lldb/trunk/source/Expression/Materializer.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Fri Feb 28 16:27:53 2014
@@ -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());
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri Feb 28
16:27:53 2014
@@ -522,7 +522,13 @@ ABIMacOSX_arm::SetReturnValueObject(lldb
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)
{
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Feb 28
16:27:53 2014
@@ -600,7 +600,13 @@ ABIMacOSX_i386::SetReturnValueObject(lld
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)
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=202552&r1=202551&r2=202552&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri Feb 28
16:27:53 2014
@@ -562,7 +562,13 @@ ABISysV_x86_64::SetReturnValueObject(lld
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(lld
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();
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits