Added the ability to get the disassembly instructions from the function and
symbol.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115734 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 181b6b0..13d68a1 100644
--- a/source/API/SBInstruction.cpp
+++ b/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);
+}
 
-//size_t
-//SBInstruction::GetByteSize ()
-//{
-//    if (IsValid())
-//    {
-//        return m_opaque_sp->GetByteSize();
-//    }
-//    return 0;
-//}
+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;
+}
 
-//void
-//SBInstruction::SetByteSize (size_T byte_size)
-//{
-//    if (IsValid ())
-//    {
-//        m_opaque_sp->SetByteSize (byte_size);
-//    }
-//}
+size_t
+SBInstruction::GetByteSize ()
+{
+    if (m_opaque_sp)
+        return m_opaque_sp->GetByteSize();
+    return 0;
+}
 
-//bool
-//SBInstruction::DoesBranch ()
-//{
-//    if (IsValid ())
-//    {
-//        return m_opaque_sp->DoesBranch ();
-//    }
-//    return false;
-//}
+bool
+SBInstruction::DoesBranch ()
+{
+    if (m_opaque_sp)
+        return m_opaque_sp->DoesBranch ();
+    return false;
+}
+
+void
+SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp)
+{
+    m_opaque_sp = inst_sp;
+}
+
+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 @@
     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);
+    }
 }