[Lldb-commits] [lldb] r182530 - Added a new "lldb" log channel named "os" for the OperatingSystem plug-ins to use.
Greg Clayton
gclayton at apple.com
Wed May 22 16:04:27 PDT 2013
Author: gclayton
Date: Wed May 22 18:04:27 2013
New Revision: 182530
URL: http://llvm.org/viewvc/llvm-project?rev=182530&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h
lldb/trunk/include/lldb/lldb-private-log.h
lldb/trunk/source/Interpreter/PythonDataObjects.cpp
lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/trunk/source/lldb-log.cpp
Modified: lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h?rev=182530&r1=182529&r2=182530&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h (original)
+++ lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h Wed May 22 18:04:27 2013
@@ -82,13 +82,16 @@ namespace lldb_private {
}
void
- Dump () const
+ Dump () const
{
if (m_py_obj)
_PyObject_Dump (m_py_obj);
else
puts ("NULL");
}
+
+ void
+ Dump (Stream &strm) const;
PyObject*
GetPythonObject () const
Modified: lldb/trunk/include/lldb/lldb-private-log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-log.h?rev=182530&r1=182529&r2=182530&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-log.h (original)
+++ lldb/trunk/include/lldb/lldb-private-log.h Wed May 22 18:04:27 2013
@@ -43,6 +43,7 @@
#define LIBLLDB_LOG_MODULES (1u << 21)
#define LIBLLDB_LOG_TARGET (1u << 22)
#define LIBLLDB_LOG_MMAP (1u << 23)
+#define LIBLLDB_LOG_OS (1u << 24)
#define LIBLLDB_LOG_ALL (UINT32_MAX)
#define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\
LIBLLDB_LOG_THREAD |\
Modified: lldb/trunk/source/Interpreter/PythonDataObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/PythonDataObjects.cpp?rev=182530&r1=182529&r2=182530&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/PythonDataObjects.cpp (original)
+++ lldb/trunk/source/Interpreter/PythonDataObjects.cpp Wed May 22 18:04:27 2013
@@ -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::
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
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=182530&r1=182529&r2=182530&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Wed May 22 18:04:27 2013
@@ -21,6 +21,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/PythonDataObjects.h"
@@ -134,7 +135,7 @@ OperatingSystemPython::GetDynamicRegiste
{
if (!m_interpreter || !m_python_object_sp)
return NULL;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OS));
if (log)
log->Printf ("OperatingSystemPython::GetDynamicRegisterInfo() fetching thread register definitions from python for pid %" PRIu64, m_process->GetID());
@@ -173,7 +174,7 @@ OperatingSystemPython::UpdateThreadList
if (!m_interpreter || !m_python_object_sp)
return false;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OS));
// First thing we have to do is get the API lock, and the run lock. We're going to change the thread
// content of the process, and we're going to use python, which requires the API lock to do it.
@@ -191,6 +192,12 @@ OperatingSystemPython::UpdateThreadList
PythonList threads_list(m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp));
if (threads_list)
{
+ if (log)
+ {
+ StreamString strm;
+ threads_list.Dump(strm);
+ log->Printf("threads_list = %s", strm.GetString().c_str());
+ }
uint32_t i;
const uint32_t num_threads = threads_list.GetSize();
if (num_threads > 0)
Modified: lldb/trunk/source/lldb-log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=182530&r1=182529&r2=182530&view=diff
==============================================================================
--- lldb/trunk/source/lldb-log.cpp (original)
+++ lldb/trunk/source/lldb-log.cpp Wed May 22 18:04:27 2013
@@ -142,6 +142,7 @@ lldb_private::DisableLog (const char **c
else if (0 == ::strncasecmp(arg, "symbol", 6)) flag_bits &= ~LIBLLDB_LOG_SYMBOLS;
else if (0 == ::strncasecmp(arg, "module", 6)) flag_bits &= ~LIBLLDB_LOG_MODULES;
else if (0 == ::strncasecmp(arg, "mmap", 4)) flag_bits &= ~LIBLLDB_LOG_MMAP;
+ else if (0 == ::strncasecmp(arg, "os", 4)) flag_bits &= ~LIBLLDB_LOG_OS;
else
{
feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg);
@@ -211,6 +212,7 @@ lldb_private::EnableLog (StreamSP &log_s
else if (0 == ::strncasecmp(arg, "symbol", 6)) flag_bits |= LIBLLDB_LOG_SYMBOLS;
else if (0 == ::strncasecmp(arg, "module", 6)) flag_bits |= LIBLLDB_LOG_MODULES;
else if (0 == ::strncasecmp(arg, "mmap", 4)) flag_bits |= LIBLLDB_LOG_MMAP;
+ else if (0 == ::strncasecmp(arg, "os", 4)) flag_bits |= LIBLLDB_LOG_OS;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
More information about the lldb-commits
mailing list