summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBTarget.cpp
diff options
context:
space:
mode:
authorMatthew Gardiner <mg11@csr.com>2014-10-22 07:22:56 +0000
committerMatthew Gardiner <mg11@csr.com>2014-10-22 07:22:56 +0000
commitc928de3e8e95ab02418720b765b2342123ade5b8 (patch)
treebe7a7544734d5488eb64d096f0558f61a84a7e03 /lldb/source/API/SBTarget.cpp
parent0cf39569bf9e58db2d975fb06d1f94fcd2c648ee (diff)
downloadbcm5719-llvm-c928de3e8e95ab02418720b765b2342123ade5b8.tar.gz
bcm5719-llvm-c928de3e8e95ab02418720b765b2342123ade5b8.zip
Added functions to the C++ API, for the benefit of non-8-bit byte architectures.
New functions to give client applications to tools to discover target byte sizes for addresses prior to ReadMemory. Also added GetPlatform and ReadMemory to the SBTarget class, since they seemed to be useful utilities to have. Each new API has had a test case added. http://reviews.llvm.org/D5867 llvm-svn: 220372
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r--lldb/source/API/SBTarget.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index fb88036dd6e..dbf4a478413 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -587,6 +587,19 @@ SBTarget::GetProcess ()
return sb_process;
}
+SBPlatform
+SBTarget::GetPlatform ()
+{
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return SBPlatform();
+
+ SBPlatform platform;
+ platform.m_opaque_sp = target_sp->GetPlatform();
+
+ return platform;
+}
+
SBDebugger
SBTarget::GetDebugger () const
{
@@ -1231,6 +1244,22 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
return sb_addr;
}
+lldb::SBAddress
+SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
+{
+ lldb::SBAddress sb_addr;
+ Address &addr = sb_addr.ref();
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ if (target_sp->ResolveFileAddress (file_addr, addr))
+ return sb_addr;
+ }
+
+ addr.SetRawAddress(file_addr);
+ return sb_addr;
+}
lldb::SBAddress
SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
@@ -1265,6 +1294,29 @@ SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
return sc;
}
+size_t
+SBTarget::ReadMemory (const SBAddress addr,
+ void *buf,
+ size_t size,
+ lldb::SBError &error)
+{
+ SBError sb_error;
+ size_t bytes_read = 0;
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ lldb_private::Address addr_priv(addr.GetFileAddress(), NULL);
+ lldb_private::Error err_priv;
+ bytes_read = target_sp->ReadMemory(addr_priv, false, buf, size, err_priv);
+ if(err_priv.Fail())
+ {
+ sb_error.SetError(err_priv.GetError(), err_priv.GetType());
+ }
+ }
+
+ return bytes_read;
+}
SBBreakpoint
SBTarget::BreakpointCreateByLocation (const char *file,
@@ -2061,6 +2113,28 @@ SBTarget::GetTriple ()
}
uint32_t
+SBTarget::GetDataByteSize ()
+{
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ return target_sp->GetArchitecture().GetDataByteSize() ;
+ }
+ return 0;
+}
+
+uint32_t
+SBTarget::GetCodeByteSize ()
+{
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ return target_sp->GetArchitecture().GetCodeByteSize() ;
+ }
+ return 0;
+}
+
+uint32_t
SBTarget::GetAddressByteSize()
{
TargetSP target_sp(GetSP());
OpenPOWER on IntegriCloud