diff options
Diffstat (limited to 'lldb/source/API/SBInstruction.cpp')
-rw-r--r-- | lldb/source/API/SBInstruction.cpp | 100 |
1 files changed, 61 insertions, 39 deletions
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 181b6b0c5e9..13d68a1cd34 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -9,58 +9,78 @@ #include "lldb/API/SBInstruction.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBStream.h" + #include "lldb/Core/Disassembler.h" +#include "lldb/Core/StreamFile.h" using namespace lldb; using namespace lldb_private; -//SBInstruction::SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn) : -// m_opaque_sp (lldb_insn); -//{ -//} - SBInstruction::SBInstruction () { } +SBInstruction::SBInstruction (const lldb::InstructionSP& inst_sp) : + m_opaque_sp (inst_sp) +{ +} + SBInstruction::~SBInstruction () { } -//bool -//SBInstruction::IsValid() -//{ -// return (m_opaque_sp.get() != NULL); -//} +bool +SBInstruction::IsValid() +{ + return (m_opaque_sp.get() != NULL); +} + +SBAddress +SBInstruction::GetAddress() +{ + SBAddress sb_addr; + if (m_opaque_sp && m_opaque_sp->GetAddress().IsValid()) + sb_addr.SetAddress(&m_opaque_sp->GetAddress()); + return sb_addr; +} + +size_t +SBInstruction::GetByteSize () +{ + if (m_opaque_sp) + return m_opaque_sp->GetByteSize(); + return 0; +} -//size_t -//SBInstruction::GetByteSize () -//{ -// if (IsValid()) -// { -// return m_opaque_sp->GetByteSize(); -// } -// return 0; -//} +bool +SBInstruction::DoesBranch () +{ + if (m_opaque_sp) + return m_opaque_sp->DoesBranch (); + return false; +} -//void -//SBInstruction::SetByteSize (size_T byte_size) -//{ -// if (IsValid ()) -// { -// m_opaque_sp->SetByteSize (byte_size); -// } -//} +void +SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp) +{ + m_opaque_sp = inst_sp; +} -//bool -//SBInstruction::DoesBranch () -//{ -// if (IsValid ()) -// { -// return m_opaque_sp->DoesBranch (); -// } -// return false; -//} +bool +SBInstruction::GetDescription (lldb::SBStream &s) +{ + if (m_opaque_sp) + { + // Use the "ref()" instead of the "get()" accessor in case the SBStream + // didn't have a stream already created, one will get created... + m_opaque_sp->Dump (&s.ref(), true, NULL, 0, NULL, false); + return true; + } + return false; +} void SBInstruction::Print (FILE *out) @@ -68,7 +88,9 @@ SBInstruction::Print (FILE *out) if (out == NULL) return; - //StreamFile out_strem (out); - - //m_opaque_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); + if (m_opaque_sp) + { + StreamFile out_stream (out); + m_opaque_sp->Dump (&out_stream, true, NULL, 0, NULL, false); + } } |