forked from OSchip/llvm-project
<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
This commit is contained in:
parent
3c593d63a1
commit
347c2aa3e3
|
@ -747,6 +747,9 @@ public:
|
|||
lldb::SBType
|
||||
GetBasicType(lldb::BasicType type);
|
||||
|
||||
lldb::SBValue
|
||||
CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
|
||||
|
||||
SBSourceManager
|
||||
GetSourceManager();
|
||||
|
||||
|
|
|
@ -461,6 +461,9 @@ public:
|
|||
|
||||
uint32_t
|
||||
GetAddressByteSize() const;
|
||||
|
||||
lldb::ByteOrder
|
||||
GetByteOrder() const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Returns a pointer to the target object.
|
||||
|
|
|
@ -723,6 +723,9 @@ public:
|
|||
|
||||
lldb::SBBroadcaster
|
||||
GetBroadcaster () const;
|
||||
|
||||
lldb::SBValue
|
||||
CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
|
||||
|
||||
lldb::SBInstructionList
|
||||
ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
|
||||
|
|
|
@ -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 ()
|
||||
{
|
||||
|
|
|
@ -761,17 +761,17 @@ SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType s
|
|||
lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
|
||||
if (value_sp && type_impl_sp)
|
||||
{
|
||||
ClangASTType pointee_ast_type(type_impl_sp->GetClangASTType().GetPointerType ());
|
||||
if (pointee_ast_type)
|
||||
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 (value_sp->GetExecutionContextRef());
|
||||
ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
|
||||
pointee_ast_type,
|
||||
pointer_ast_type,
|
||||
ConstString(name),
|
||||
buffer,
|
||||
lldb::endian::InlHostByteOrder(),
|
||||
exe_ctx.GetByteOrder(),
|
||||
exe_ctx.GetAddressByteSize()));
|
||||
|
||||
if (ptr_result_valobj_sp)
|
||||
|
|
|
@ -241,7 +241,15 @@ ExecutionContext::GetAddressByteSize() const
|
|||
return sizeof(void *);
|
||||
}
|
||||
|
||||
|
||||
lldb::ByteOrder
|
||||
ExecutionContext::GetByteOrder() const
|
||||
{
|
||||
if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
|
||||
m_target_sp->GetArchitecture().GetByteOrder();
|
||||
if (m_process_sp)
|
||||
m_process_sp->GetByteOrder();
|
||||
return lldb::endian::InlHostByteOrder();
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
ExecutionContext::GetRegisterContext () const
|
||||
|
|
Loading…
Reference in New Issue