summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-08-24 00:51:29 +0000
committerEnrico Granata <egranata@apple.com>2012-08-24 00:51:29 +0000
commit6167ab281965d4ebbcff77c1f392050bcd1c5e79 (patch)
treeff835b7dc2c33abb2c6cea083efb943020c7384d
parent4bcd58b87db2ce661759fb9efdb055d964628d23 (diff)
downloadbcm5719-llvm-6167ab281965d4ebbcff77c1f392050bcd1c5e79.tar.gz
bcm5719-llvm-6167ab281965d4ebbcff77c1f392050bcd1c5e79.zip
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
llvm-svn: 162522
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreter.h13
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreterPython.h7
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp116
-rw-r--r--lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp28
4 files changed, 160 insertions, 4 deletions
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index a5ba88124d4..cbea9eb22ba 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -212,6 +212,19 @@ public:
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)
{
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
index 7b66c0825ea..f7e3c63fb89 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
@@ -83,6 +83,13 @@ public:
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);
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 94b27bb8297..faf362b5005 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -1784,6 +1784,122 @@ ScriptInterpreterPython::OSPlugin_QueryForRegisterInfo (lldb::ScriptInterpreterO
}
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)
{
diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index fd84eb85d4a..ba57c731eb9 100644
--- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -199,8 +199,19 @@ OperatingSystemPython::GetPluginVersion()
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 @@ OperatingSystemPython::ThreadWasSelected (Thread *thread)
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)
OpenPOWER on IntegriCloud