summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/PythonDataObjects.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter/PythonDataObjects.cpp')
-rw-r--r--lldb/source/Interpreter/PythonDataObjects.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/PythonDataObjects.cpp b/lldb/source/Interpreter/PythonDataObjects.cpp
index 8cd4db999a7..d8720568803 100644
--- a/lldb/source/Interpreter/PythonDataObjects.cpp
+++ b/lldb/source/Interpreter/PythonDataObjects.cpp
@@ -20,7 +20,8 @@
#else
#include <Python.h>
#endif
-
+#include "lldb/Core/Stream.h"
+#include "lldb/Host/File.h"
#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -37,6 +38,30 @@ PythonObject::PythonObject (const lldb::ScriptInterpreterObjectSP &script_object
Reset ((PyObject *)script_object_sp->GetObject());
}
+void
+PythonObject::Dump (Stream &strm) const
+{
+ if (m_py_obj)
+ {
+ FILE *file = tmpfile();
+ if (file)
+ {
+ PyObject_Print (m_py_obj, file, 0);
+ const long length = ftell (file);
+ if (length)
+ {
+ rewind(file);
+ std::vector<char> file_contents (length,'\0');
+ const size_t length_read = fread(file_contents.data(), 1, file_contents.size(), file);
+ if (length_read > 0)
+ strm.Write(file_contents.data(), length_read);
+ }
+ }
+ }
+ else
+ strm.PutCString ("NULL");
+}
+
//----------------------------------------------------------------------
// PythonString
//----------------------------------------------------------------------
OpenPOWER on IntegriCloud