summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBTarget.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-12-17 21:18:43 +0000
committerEnrico Granata <egranata@apple.com>2014-12-17 21:18:43 +0000
commit972be53f029f9181f13756685b6614a9687ed721 (patch)
tree2c920d0b66bf400d670fc3076b578ea44001bd74 /lldb/source/API/SBTarget.cpp
parent11e3873516fa5dbb63bbe7c2d2614ec2bf5bc851 (diff)
downloadbcm5719-llvm-972be53f029f9181f13756685b6614a9687ed721.tar.gz
bcm5719-llvm-972be53f029f9181f13756685b6614a9687ed721.zip
Provide CreateValueFromData,Expression at the SBTarget level as well as the SBValue level; and also make all the implenentations agree on using the matching ValueObject::Create instead of doing code copypastas
llvm-svn: 224460
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r--lldb/source/API/SBTarget.cpp80
1 files changed, 56 insertions, 24 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8b3f6156e20..b87b1acf45d 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1945,30 +1945,10 @@ SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
lldb::ValueObjectSP new_value_sp;
if (IsValid() && name && *name && addr.IsValid() && type.IsValid())
{
- lldb::addr_t address(addr.GetLoadAddress(*this));
- lldb::TypeImplSP type_impl_sp (type.GetSP());
- ClangASTType pointer_ast_type(type_impl_sp->GetClangASTType(true).GetPointerType ());
- if (pointer_ast_type)
- {
- lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
-
- ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- pointer_ast_type,
- ConstString(name),
- buffer,
- exe_ctx.GetByteOrder(),
- exe_ctx.GetAddressByteSize()));
-
- if (ptr_result_valobj_sp)
- {
- ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
- Error err;
- new_value_sp = ptr_result_valobj_sp->Dereference(err);
- if (new_value_sp)
- new_value_sp->SetName(ConstString(name));
- }
- }
+ lldb::addr_t load_addr(addr.GetLoadAddress(*this));
+ ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
+ ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
+ new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -1985,6 +1965,58 @@ SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
return sb_value;
}
+lldb::SBValue
+SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type)
+{
+ SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ if (IsValid() && name && *name && data.IsValid() && type.IsValid())
+ {
+ DataExtractorSP extractor(*data);
+ ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
+ ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
+ new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (new_value_sp)
+ log->Printf ("SBTarget(%p)::CreateValueFromData => \"%s\"",
+ static_cast<void*>(m_opaque_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf ("SBTarget(%p)::CreateValueFromData => NULL",
+ static_cast<void*>(m_opaque_sp.get()));
+ }
+ return sb_value;
+}
+
+lldb::SBValue
+SBTarget::CreateValueFromExpression (const char *name, const char* expr)
+{
+ SBValue sb_value;
+ lldb::ValueObjectSP new_value_sp;
+ if (IsValid() && name && *name && expr && *expr)
+ {
+ ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
+ new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
+ }
+ sb_value.SetSP(new_value_sp);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (new_value_sp)
+ log->Printf ("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
+ static_cast<void*>(m_opaque_sp.get()),
+ new_value_sp->GetName().AsCString());
+ else
+ log->Printf ("SBTarget(%p)::CreateValueFromExpression => NULL",
+ static_cast<void*>(m_opaque_sp.get()));
+ }
+ return sb_value;
+}
+
bool
SBTarget::DeleteAllWatchpoints ()
{
OpenPOWER on IntegriCloud