Use the Error parameter in ValueObject::ReadPointedString to actually report common errors

llvm-svn: 176302
This commit is contained in:
Enrico Granata 2013-02-28 22:01:33 +00:00
parent 8a0e0841f3
commit 7e0db2a24b
1 changed files with 114 additions and 109 deletions

View File

@ -1048,7 +1048,14 @@ ValueObject::ReadPointedString (Stream& s,
ExecutionContext exe_ctx (GetExecutionContextRef());
Target* target = exe_ctx.GetTargetPtr();
if (target && max_length == 0)
if (!target)
{
s << "<no target to read from>";
error.SetErrorString("no target to read from");
return 0;
}
if (max_length == 0)
max_length = target->GetMaximumSizeOfStringSummary();
size_t bytes_read = 0;
@ -1059,12 +1066,6 @@ ValueObject::ReadPointedString (Stream& s,
const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
ClangASTContext::IsCharType (elem_or_pointee_clang_type))
{
if (target == NULL)
{
s << "<no target to read from>";
}
else
{
addr_t cstr_address = LLDB_INVALID_ADDRESS;
AddressType cstr_address_type = eAddressTypeInvalid;
@ -1087,8 +1088,14 @@ ValueObject::ReadPointedString (Stream& s,
// We have a pointer
cstr_address = GetPointerValue (&cstr_address_type);
}
if (cstr_address != 0 && cstr_address != LLDB_INVALID_ADDRESS)
if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS)
{
s << "<invalid address>";
error.SetErrorString("invalid address");
return 0;
}
Address cstr_so_addr (cstr_address);
DataExtractor data;
if (cstr_len > 0 && honor_array)
@ -1178,11 +1185,9 @@ ValueObject::ReadPointedString (Stream& s,
}
}
}
}
}
else
{
error.SetErrorString("impossible to read a string from this object");
error.SetErrorString("not a string object");
s << "<not a string object>";
}
return total_bytes_read;