diff options
author | Enrico Granata <egranata@apple.com> | 2013-10-08 21:49:02 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-10-08 21:49:02 +0000 |
commit | 347c2aa3e3b29440a0f3ae389ca9f2dbe9a99c6a (patch) | |
tree | 60c6e2a41e5af1569be84602b4d11de690b5c05b /lldb/source/API/SBTarget.cpp | |
parent | 3c593d63a1d0d750ddbec841ff96fcbd2906b18a (diff) | |
download | bcm5719-llvm-347c2aa3e3b29440a0f3ae389ca9f2dbe9a99c6a.tar.gz bcm5719-llvm-347c2aa3e3b29440a0f3ae389ca9f2dbe9a99c6a.zip |
<rdar://problem/14028923>
Implement SBTarget::CreateValueFromAddress() with a behavior equivalent to SBValue::CreateValueFromAddress()
(but without the need to grab an SBValue first just as a starting point to make up another SBValue out of whole cloth)
llvm-svn: 192239
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index d3cd85c3dd7..b9947d985a9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -41,6 +41,7 @@ #include "lldb/Core/SearchFilter.h" #include "lldb/Core/Section.h" #include "lldb/Core/STLUtils.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Host/FileSpec.h" @@ -1862,6 +1863,50 @@ SBTarget::DisableAllWatchpoints () return false; } +SBValue +SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type) +{ + SBValue sb_value; + 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().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)); + } + } + } + sb_value.SetSP(new_value_sp); + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (new_value_sp) + log->Printf ("SBTarget(%p)::CreateValueFromAddress => \"%s\"", m_opaque_sp.get(), new_value_sp->GetName().AsCString()); + else + log->Printf ("SBTarget(%p)::CreateValueFromAddress => NULL", m_opaque_sp.get()); + } + return sb_value; +} + bool SBTarget::DeleteAllWatchpoints () { |