Added a new "lldb" log channel named "os" for the OperatingSystem plug-ins to use.
Added logging for the OS plug-in python objects in OperatingSystemPython so we can see the python dictionary returned from the plug-in when logging is enabled. llvm-svn: 182530
This commit is contained in:
@@ -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
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user