forked from OSchip/llvm-project
Use the Error parameter in ValueObject::ReadPointedString to actually report common errors
llvm-svn: 176302
This commit is contained in:
parent
8a0e0841f3
commit
7e0db2a24b
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue