summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/ValueObjectMemory.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-04-27 22:04:39 +0000
committerGreg Clayton <gclayton@apple.com>2011-04-27 22:04:39 +0000
commit84c39663a929f4baae525604b0c0d4814eceb8cf (patch)
treeea07c9a31332e5cb97754bbc55238541d0a3f071 /lldb/source/Core/ValueObjectMemory.cpp
parent8513d4236c8d621dcaffe9e94059225f055ee196 (diff)
downloadbcm5719-llvm-84c39663a929f4baae525604b0c0d4814eceb8cf.tar.gz
bcm5719-llvm-84c39663a929f4baae525604b0c0d4814eceb8cf.zip
Added a new OptionValue subclass for lldb::Format: OptionValueFormat. Added
new OptionGroup subclasses for: - output file for use with options: long opts: --outfile <path> --append--output short opts: -o <path> -A - format for use with options: long opts: --format <format> - variable object display controls for depth, pointer depth, wether to show types, show summary, show location, flat output, use objc "po" style summary. Modified ValueObjectMemory to be able to be created either with a TypeSP or a ClangASTType. Switched "memory read" over to use OptionGroup subclasses: one for the outfile options, one for the command specific options, and one for the format. llvm-svn: 130334
Diffstat (limited to 'lldb/source/Core/ValueObjectMemory.cpp')
-rw-r--r--lldb/source/Core/ValueObjectMemory.cpp82
1 files changed, 75 insertions, 7 deletions
diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index aa9ff0ae263..ad8c8f011da 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -42,13 +42,23 @@ ValueObjectMemory::Create (ExecutionContextScope *exe_scope,
return (new ValueObjectMemory (exe_scope, name, address, type_sp))->GetSP();
}
+ValueObjectSP
+ValueObjectMemory::Create (ExecutionContextScope *exe_scope,
+ const char *name,
+ const Address &address,
+ const ClangASTType &ast_type)
+{
+ return (new ValueObjectMemory (exe_scope, name, address, ast_type))->GetSP();
+}
+
ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
lldb::TypeSP &type_sp) :
ValueObject(exe_scope),
m_address (address),
- m_type_sp(type_sp)
+ m_type_sp(type_sp),
+ m_clang_type()
{
// Do not attempt to construct one of these objects with no variable!
assert (m_type_sp.get() != NULL);
@@ -76,6 +86,43 @@ ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
}
}
+ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
+ const char *name,
+ const Address &address,
+ const ClangASTType &ast_type) :
+ ValueObject(exe_scope),
+ m_address (address),
+ m_type_sp(),
+ m_clang_type(ast_type)
+{
+ // Do not attempt to construct one of these objects with no variable!
+ assert (m_clang_type.GetASTContext());
+ assert (m_clang_type.GetOpaqueQualType());
+
+ SetName (name);
+ m_value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
+ lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget());
+ if (load_address != LLDB_INVALID_ADDRESS)
+ {
+ m_value.SetValueType(Value::eValueTypeLoadAddress);
+ m_value.GetScalar() = load_address;
+ }
+ else
+ {
+ lldb::addr_t file_address = m_address.GetFileAddress();
+ if (file_address != LLDB_INVALID_ADDRESS)
+ {
+ m_value.SetValueType(Value::eValueTypeFileAddress);
+ m_value.GetScalar() = file_address;
+ }
+ else
+ {
+ m_value.GetScalar() = m_address.GetOffset();
+ m_value.SetValueType (Value::eValueTypeScalar);
+ }
+ }
+}
+
ValueObjectMemory::~ValueObjectMemory()
{
}
@@ -83,31 +130,48 @@ ValueObjectMemory::~ValueObjectMemory()
lldb::clang_type_t
ValueObjectMemory::GetClangType ()
{
- return m_type_sp->GetClangForwardType();
+ if (m_type_sp)
+ return m_type_sp->GetClangForwardType();
+ return m_clang_type.GetOpaqueQualType();
}
ConstString
ValueObjectMemory::GetTypeName()
{
- return m_type_sp->GetName();
+ if (m_type_sp)
+ return m_type_sp->GetName();
+ ConstString name;
+ std::string type_name (ClangASTContext::GetTypeName (m_clang_type.GetOpaqueQualType()));
+ if (!type_name.empty())
+ name.SetCString (type_name.c_str());
+ return name;
}
uint32_t
ValueObjectMemory::CalculateNumChildren()
{
- return m_type_sp->GetNumChildren(true);
+ if (m_type_sp)
+ return m_type_sp->GetNumChildren(true);
+ const bool omit_empty_base_classes = true;
+ return ClangASTContext::GetNumChildren (m_clang_type.GetASTContext(),
+ m_clang_type.GetOpaqueQualType(),
+ omit_empty_base_classes);
}
clang::ASTContext *
ValueObjectMemory::GetClangAST ()
{
- return m_type_sp->GetClangAST();
+ if (m_type_sp)
+ return m_type_sp->GetClangAST();
+ return m_clang_type.GetASTContext();
}
size_t
ValueObjectMemory::GetByteSize()
{
- return m_type_sp->GetByteSize();
+ if (m_type_sp)
+ return m_type_sp->GetByteSize();
+ return (m_clang_type.GetClangTypeBitWidth () + 7) / 8;
}
lldb::ValueType
@@ -182,7 +246,11 @@ ValueObjectMemory::UpdateValue ()
// Copy the Value and set the context to use our Variable
// so it can extract read its value into m_data appropriately
Value value(m_value);
- value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get());
+ if (m_type_sp)
+ value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get());
+ else
+ value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
+
m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0);
}
break;
OpenPOWER on IntegriCloud