[Lldb-commits] [lldb] r162522 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Interpreter/ScriptInterpreterPython.cpp source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
Enrico Granata
egranata at apple.com
Thu Aug 23 17:51:30 PDT 2012
Author: enrico
Date: Thu Aug 23 19:51:29 2012
New Revision: 162522
URL: http://llvm.org/viewvc/llvm-project?rev=162522&view=rev
Log:
Hooking up two more calls for the PythonOSPlugin stuff. The part of code to fetch the data and convert it to C++ objects is still missing, but will come
Modified:
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=162522&r1=162521&r2=162522&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Thu Aug 23 19:51:29 2012
@@ -212,6 +212,19 @@
return lldb::ScriptInterpreterObjectSP();
}
+ virtual lldb::ScriptInterpreterObjectSP
+ OSPlugin_QueryForThreadsInfo (lldb::ScriptInterpreterObjectSP object)
+ {
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
+ virtual lldb::ScriptInterpreterObjectSP
+ OSPlugin_QueryForThreadInfo (lldb::ScriptInterpreterObjectSP object,
+ lldb::tid_t thread_id)
+ {
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
virtual bool
GenerateFunction(const char *signature, const StringList &input)
{
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=162522&r1=162521&r2=162522&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Thu Aug 23 19:51:29 2012
@@ -83,6 +83,13 @@
virtual lldb::ScriptInterpreterObjectSP
OSPlugin_QueryForRegisterInfo (lldb::ScriptInterpreterObjectSP object);
+ virtual lldb::ScriptInterpreterObjectSP
+ OSPlugin_QueryForThreadsInfo (lldb::ScriptInterpreterObjectSP object);
+
+ virtual lldb::ScriptInterpreterObjectSP
+ OSPlugin_QueryForThreadInfo (lldb::ScriptInterpreterObjectSP object,
+ lldb::tid_t thread_id);
+
virtual uint32_t
CalculateNumChildren (const lldb::ScriptInterpreterObjectSP& implementor);
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=162522&r1=162521&r2=162522&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Aug 23 19:51:29 2012
@@ -1784,6 +1784,122 @@
}
lldb::ScriptInterpreterObjectSP
+ScriptInterpreterPython::OSPlugin_QueryForThreadsInfo (lldb::ScriptInterpreterObjectSP object)
+{
+ static char callee_name[] = "get_thread_info";
+
+ if (!object)
+ return lldb::ScriptInterpreterObjectSP();
+
+ PyObject* implementor = (PyObject*)object->GetObject();
+
+ if (implementor == NULL || implementor == Py_None)
+ return lldb::ScriptInterpreterObjectSP();
+
+ PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ if (pmeth == NULL || pmeth == Py_None)
+ {
+ Py_XDECREF(pmeth);
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
+ if (PyCallable_Check(pmeth) == 0)
+ {
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ Py_XDECREF(pmeth);
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ Py_XDECREF(pmeth);
+
+ // right now we know this function exists and is callable..
+ PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
+
+ // if it fails, print the error but otherwise go on
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+
+ return MakeScriptObject(py_return);
+}
+
+lldb::ScriptInterpreterObjectSP
+ScriptInterpreterPython::OSPlugin_QueryForThreadInfo (lldb::ScriptInterpreterObjectSP object,
+ lldb::tid_t thread_id)
+{
+ static char callee_name[] = "get_register_data";
+ static char param_format[] = "l";
+
+ if (!object)
+ return lldb::ScriptInterpreterObjectSP();
+
+ PyObject* implementor = (PyObject*)object->GetObject();
+
+ if (implementor == NULL || implementor == Py_None)
+ return lldb::ScriptInterpreterObjectSP();
+
+ PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ if (pmeth == NULL || pmeth == Py_None)
+ {
+ Py_XDECREF(pmeth);
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
+ if (PyCallable_Check(pmeth) == 0)
+ {
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ Py_XDECREF(pmeth);
+ return lldb::ScriptInterpreterObjectSP();
+ }
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+
+ Py_XDECREF(pmeth);
+
+ // right now we know this function exists and is callable..
+ PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, thread_id);
+
+ // if it fails, print the error but otherwise go on
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+
+ return MakeScriptObject(py_return);
+}
+
+lldb::ScriptInterpreterObjectSP
ScriptInterpreterPython::CreateSyntheticScriptedProvider (std::string class_name,
lldb::ValueObjectSP valobj)
{
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=162522&r1=162521&r2=162522&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Thu Aug 23 19:51:29 2012
@@ -199,8 +199,19 @@
bool
OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
{
- // TODO: python: call "dict get_thread_info()" on the
- // python object that represents our instance of the OperatingSystem plug-in
+
+ if (!m_interpreter || !m_python_object)
+ return NULL;
+ auto object_sp = m_interpreter->OSPlugin_QueryForThreadsInfo(m_interpreter->MakeScriptObject(m_python_object));
+ if (!object_sp)
+ return NULL;
+ PythonDataObject dictionary_data_obj((PyObject*)object_sp->GetObject());
+ PythonDataDictionary dictionary = dictionary_data_obj.GetDictionaryObject();
+ if(!dictionary)
+ return NULL;
+
+ // TODO: read from the dict
+
// and parse the returned dictionary. We need to pass in the a Dictionary
// with the same kind of info we want back so we can reuse old threads, but
// only create new ones.
@@ -227,8 +238,17 @@
RegisterContextSP
OperatingSystemPython::CreateRegisterContextForThread (Thread *thread)
{
- // TODO: python: call "bytes get_register_context_data(SBThread thread)"
- // and populate resulting data into thread
+
+ if (!m_interpreter || !m_python_object || !thread)
+ return NULL;
+ auto object_sp = m_interpreter->OSPlugin_QueryForThreadInfo(m_interpreter->MakeScriptObject(m_python_object),
+ thread->GetID());
+ if (!object_sp)
+ return NULL;
+ PythonDataObject pack_info_data_obj((PyObject*)object_sp->GetObject());
+ if(!pack_info_data_obj)
+ return NULL;
+
RegisterContextSP reg_ctx_sp;
// bytes b = get_register_context_data(thread)
// if (b)
More information about the lldb-commits
mailing list