summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBBreakpointLocation.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
committerCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
commitdde9cff32aee03e98a5ed91fc8425f241058c771 (patch)
treed207dc97f063865b8addf9c4b01d6cbed2386f9e /lldb/source/API/SBBreakpointLocation.cpp
parentfd02aa84dc5e5b96e44e1f93b4f57b206e6180b2 (diff)
downloadbcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.tar.gz
bcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.zip
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
Diffstat (limited to 'lldb/source/API/SBBreakpointLocation.cpp')
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index 948b78f0c29..f7e059ba967 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -7,9 +7,15 @@
//
//===----------------------------------------------------------------------===//
+// In order to guarantee correct working with Python, Python.h *MUST* be
+// the *FIRST* header file included:
+
+#include <Python.h>
+
#include "lldb/API/SBBreakpointLocation.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBStream.h"
#include "lldb/lldb-types.h"
#include "lldb/lldb-defines.h"
@@ -191,12 +197,9 @@ SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_s
m_opaque_sp = break_loc_sp;
}
-void
-SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
+bool
+SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
{
- if (f == NULL)
- return;
-
if (m_opaque_sp)
{
DescriptionLevel level;
@@ -209,11 +212,22 @@ SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
else
level = eDescriptionLevelBrief;
- StreamFile str (f);
-
- m_opaque_sp->GetDescription (&str, level);
- str.EOL();
+ m_opaque_sp->GetDescription (description.get(), level);
+ description.get()->EOL();
}
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBBreakpointLocation::__repr__ ()
+{
+ SBStream description;
+ description.ref();
+ GetDescription ("full", description);
+ return PyString_FromString (description.GetData());
}
SBBreakpoint
OpenPOWER on IntegriCloud