Print better error messages when memory reads fail when displaying variable

values.

Always show the variable types for the top level items when dumping program
variables.

llvm-svn: 117999
This commit is contained in:
Greg Clayton 2010-11-02 01:50:16 +00:00
parent 07072664c4
commit 7c8a966442
3 changed files with 47 additions and 24 deletions

View File

@ -498,7 +498,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
switch (m_value_type)
{
default:
error.SetErrorStringWithFormat("Invalid value type %i.\n", m_value_type);
error.SetErrorStringWithFormat("invalid value type %i", m_value_type);
break;
case eValueTypeScalar:
@ -506,17 +506,17 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
data.SetAddressByteSize(sizeof(void *));
if (m_value.GetData (data))
return error; // Success;
error.SetErrorStringWithFormat("Extracting data from value failed.\n");
error.SetErrorStringWithFormat("extracting data from value failed");
break;
case eValueTypeLoadAddress:
if (exe_ctx == NULL)
{
error.SetErrorString ("Can't read memory (no execution context).");
error.SetErrorString ("can't read memory (no execution context)");
}
else if (exe_ctx->process == NULL)
{
error.SetErrorString ("Can't read memory (invalid process).");
error.SetErrorString ("can't read memory (invalid process)");
}
else
{
@ -564,7 +564,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
}
else
{
error.SetErrorStringWithFormat ("Unable to resolve the module for file address 0x%llx for variable '%s'.\n", file_addr, variable->GetName().AsCString(""));
error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s'", file_addr, variable->GetName().AsCString(""));
}
}
else
@ -576,7 +576,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
{
// Can't convert a file address to anything valid without more
// context (which Module it came from)
error.SetErrorString ("Can't read memory from file address without more context.");
error.SetErrorString ("can't read memory from file address without more context");
}
}
break;
@ -595,7 +595,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
if (address == LLDB_INVALID_ADDRESS)
{
error.SetErrorStringWithFormat ("Invalid %s address.\n", address_type == eAddressTypeHost ? "host" : "load");
error.SetErrorStringWithFormat ("invalid %s address", address_type == eAddressTypeHost ? "host" : "load");
return error;
}
@ -628,16 +628,18 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
{
if (error.Success())
error.SetErrorStringWithFormat("read %u bytes of memory from 0x%llx failed", (uint64_t)address, byte_size);
else
error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address);
}
}
else
{
error.SetErrorStringWithFormat ("Unsupported lldb::AddressType value (%i).\n", address_type);
error.SetErrorStringWithFormat ("unsupported lldb::AddressType value (%i)", address_type);
}
}
else
{
error.SetErrorStringWithFormat ("Out of memory.\n");
error.SetErrorStringWithFormat ("out of memory");
}
return error;

View File

@ -990,7 +990,8 @@ ValueObject::DumpValueObject
s.Indent();
if (show_types)
// Always show the type for the top level items.
if (show_types || curr_depth == 0)
s.Printf("(%s) ", valobj->GetTypeName().AsCString());
@ -1021,7 +1022,7 @@ ValueObject::DumpValueObject
if (err_cstr)
{
s.Printf (" %s\n", err_cstr);
s.Printf (" error: %s\n", err_cstr);
}
else
{

View File

@ -146,13 +146,27 @@ ValueObjectChild::UpdateValue (ExecutionContextScope *exe_scope)
{
uint32_t offset = 0;
m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset);
// For pointers, m_byte_offset should only ever be set if we
// ValueObject::GetSyntheticArrayMemberFromPointer() was called
if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset)
m_value.GetScalar() += m_byte_offset;
if (value_type == Value::eValueTypeScalar ||
value_type == Value::eValueTypeFileAddress)
m_value.SetValueType (Value::eValueTypeLoadAddress);
lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
if (addr == LLDB_INVALID_ADDRESS)
{
m_error.SetErrorString ("parent address is invalid.");
}
else if (addr == 0)
{
m_error.SetErrorString ("parent is NULL");
}
else
{
// For pointers, m_byte_offset should only ever be set if we
// ValueObject::GetSyntheticArrayMemberFromPointer() was called
if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset)
m_value.GetScalar() += m_byte_offset;
if (value_type == Value::eValueTypeScalar ||
value_type == Value::eValueTypeFileAddress)
m_value.SetValueType (Value::eValueTypeLoadAddress);
}
}
else
{
@ -163,14 +177,20 @@ ValueObjectChild::UpdateValue (ExecutionContextScope *exe_scope)
case Value::eValueTypeHostAddress:
{
lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
if (addr == LLDB_INVALID_ADDRESS || addr == 0)
if (addr == LLDB_INVALID_ADDRESS)
{
m_error.SetErrorStringWithFormat("Parent address is invalid: 0x%llx.\n", addr);
break;
m_error.SetErrorString ("parent address is invalid.");
}
else if (addr == 0)
{
m_error.SetErrorString ("parent is NULL");
}
else
{
// Set this object's scalar value to the address of its
// value be adding its byte offset to the parent address
m_value.GetScalar() += GetByteOffset();
}
// Set this object's scalar value to the address of its
// value be adding its byte offset to the parent address
m_value.GetScalar() += GetByteOffset();
}
break;