Add GetDescription() and __repr__ () methods to most API classes, to allow
"print" from inside Python to print out the objects in a more useful
manner.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114321 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp
index 961e8d8..5d6172b 100644
--- a/source/API/SBBlock.cpp
+++ b/source/API/SBBlock.cpp
@@ -9,8 +9,10 @@
 
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -132,4 +134,36 @@
 }
 
 
+bool
+SBBlock::GetDescription (SBStream &description)
+{
+    if (m_opaque_ptr)
+      {
+        lldb::user_id_t id = m_opaque_ptr->GetID();
+        description.Printf ("Block: {id: %d} ", id);
+        if (IsInlined())
+          {
+            description.Printf (" (inlined, '%s') ", GetInlinedName());
+          }
+        lldb_private::SymbolContext sc;
+        m_opaque_ptr->CalculateSymbolContext (&sc);
+        if (sc.function)
+          {
+            m_opaque_ptr->DumpAddressRanges (description.get(), 
+                                             sc.function->GetAddressRange().GetBaseAddress().GetFileAddress());
+          }
+      }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
 
+PyObject *
+SBBlock::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}