forked from OSchip/llvm-project
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
This commit is contained in:
parent
525a212379
commit
866e91c9d4
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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 (®_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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue