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/SBThread.cpp b/source/API/SBThread.cpp
index 3c75e4d..aa621fb 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -11,6 +11,7 @@
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
@@ -412,3 +413,26 @@
{
return *m_opaque_sp;
}
+
+bool
+SBThread::GetDescription (SBStream &description)
+{
+ if (m_opaque_sp)
+ {
+ m_opaque_sp->DumpInfo (description.ref(), true, true, true, LLDB_INVALID_INDEX32);
+ description.Printf (" %d frames, (instance name: %s)", GetNumFrames(),
+ m_opaque_sp->GetInstanceName().AsCString());
+ }
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBThread::__repr__ ()
+{
+ SBStream description;
+ GetDescription (description);
+ return PyString_FromString (description.GetData());
+}