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.

llvm-svn: 114321
This commit is contained in:
Caroline Tice
2010-09-20 05:20:02 +00:00
parent fd02aa84dc
commit dde9cff32a
49 changed files with 822 additions and 28 deletions

View File

@@ -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 @@ SBThread::operator*()
{
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());
}