2012-08-23 21:17:11 +00:00
|
|
|
//===-- OperatingSystemPython.cpp --------------------------------*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-12-05 00:20:57 +00:00
|
|
|
|
|
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
|
|
|
|
|
|
|
|
|
#include "OperatingSystemPython.h"
|
|
|
|
|
// C Includes
|
|
|
|
|
// C++ Includes
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
#include "lldb/Core/ArchSpec.h"
|
|
|
|
|
#include "lldb/Core/DataBufferHeap.h"
|
2012-08-24 00:30:47 +00:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
|
#include "lldb/Core/RegisterValue.h"
|
2013-05-22 23:04:27 +00:00
|
|
|
#include "lldb/Core/StreamString.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
2012-08-24 00:30:47 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
|
#include "lldb/Interpreter/PythonDataObjects.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
#include "lldb/Symbol/ClangNamespaceDecl.h"
|
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
|
#include "lldb/Target/StopInfo.h"
|
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
#include "lldb/Target/ThreadList.h"
|
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
|
2013-04-22 18:26:52 +00:00
|
|
|
#include "Plugins/Process/Utility/RegisterContextDummy.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
#include "Plugins/Process/Utility/RegisterContextMemory.h"
|
|
|
|
|
#include "Plugins/Process/Utility/ThreadMemory.h"
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OperatingSystemPython::Initialize()
|
|
|
|
|
{
|
|
|
|
|
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
|
|
|
|
GetPluginDescriptionStatic(),
|
|
|
|
|
CreateInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OperatingSystemPython::Terminate()
|
|
|
|
|
{
|
|
|
|
|
PluginManager::UnregisterPlugin (CreateInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OperatingSystem *
|
|
|
|
|
OperatingSystemPython::CreateInstance (Process *process, bool force)
|
|
|
|
|
{
|
|
|
|
|
// Python OperatingSystem plug-ins must be requested by name, so force must be true
|
2012-10-18 22:40:37 +00:00
|
|
|
FileSpec python_os_plugin_spec (process->GetPythonOSPluginPath());
|
|
|
|
|
if (python_os_plugin_spec && python_os_plugin_spec.Exists())
|
|
|
|
|
{
|
2013-04-18 22:45:39 +00:00
|
|
|
std::unique_ptr<OperatingSystemPython> os_ap (new OperatingSystemPython (process, python_os_plugin_spec));
|
2012-10-18 22:40:37 +00:00
|
|
|
if (os_ap.get() && os_ap->IsValid())
|
|
|
|
|
return os_ap.release();
|
|
|
|
|
}
|
2012-08-23 21:17:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-05-10 21:47:16 +00:00
|
|
|
ConstString
|
2012-08-23 21:17:11 +00:00
|
|
|
OperatingSystemPython::GetPluginNameStatic()
|
|
|
|
|
{
|
2013-05-10 21:47:16 +00:00
|
|
|
static ConstString g_name("python");
|
|
|
|
|
return g_name;
|
2012-08-23 21:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
OperatingSystemPython::GetPluginDescriptionStatic()
|
|
|
|
|
{
|
|
|
|
|
return "Operating system plug-in that gathers OS information from a python class that implements the necessary OperatingSystem functionality.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-10-18 22:40:37 +00:00
|
|
|
OperatingSystemPython::OperatingSystemPython (lldb_private::Process *process, const FileSpec &python_module_path) :
|
2012-08-23 21:17:11 +00:00
|
|
|
OperatingSystem (process),
|
|
|
|
|
m_thread_list_valobj_sp (),
|
2012-08-24 00:30:47 +00:00
|
|
|
m_register_info_ap (),
|
2012-10-18 22:40:37 +00:00
|
|
|
m_interpreter (NULL),
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
m_python_object_sp ()
|
2012-08-23 21:17:11 +00:00
|
|
|
{
|
2012-08-24 00:30:47 +00:00
|
|
|
if (!process)
|
|
|
|
|
return;
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
TargetSP target_sp = process->CalculateTarget();
|
2012-08-24 00:30:47 +00:00
|
|
|
if (!target_sp)
|
|
|
|
|
return;
|
|
|
|
|
m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
|
|
|
|
|
if (m_interpreter)
|
|
|
|
|
{
|
2012-10-18 22:40:37 +00:00
|
|
|
|
|
|
|
|
std::string os_plugin_class_name (python_module_path.GetFilename().AsCString(""));
|
|
|
|
|
if (!os_plugin_class_name.empty())
|
2012-08-24 01:42:50 +00:00
|
|
|
{
|
2012-10-18 22:40:37 +00:00
|
|
|
const bool init_session = false;
|
|
|
|
|
const bool allow_reload = true;
|
|
|
|
|
char python_module_path_cstr[PATH_MAX];
|
|
|
|
|
python_module_path.GetPath(python_module_path_cstr, sizeof(python_module_path_cstr));
|
|
|
|
|
Error error;
|
|
|
|
|
if (m_interpreter->LoadScriptingModule (python_module_path_cstr, allow_reload, init_session, error))
|
|
|
|
|
{
|
|
|
|
|
// Strip the ".py" extension if there is one
|
|
|
|
|
size_t py_extension_pos = os_plugin_class_name.rfind(".py");
|
|
|
|
|
if (py_extension_pos != std::string::npos)
|
|
|
|
|
os_plugin_class_name.erase (py_extension_pos);
|
|
|
|
|
// Add ".OperatingSystemPlugIn" to the module name to get a string like "modulename.OperatingSystemPlugIn"
|
|
|
|
|
os_plugin_class_name += ".OperatingSystemPlugIn";
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
ScriptInterpreterObjectSP object_sp = m_interpreter->OSPlugin_CreatePluginObject(os_plugin_class_name.c_str(), process->CalculateProcess());
|
|
|
|
|
if (object_sp && object_sp->GetObject())
|
|
|
|
|
m_python_object_sp = object_sp;
|
2012-10-18 22:40:37 +00:00
|
|
|
}
|
2012-08-24 01:42:50 +00:00
|
|
|
}
|
2012-08-24 00:30:47 +00:00
|
|
|
}
|
2012-08-23 21:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OperatingSystemPython::~OperatingSystemPython ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DynamicRegisterInfo *
|
|
|
|
|
OperatingSystemPython::GetDynamicRegisterInfo ()
|
|
|
|
|
{
|
2012-08-24 01:42:50 +00:00
|
|
|
if (m_register_info_ap.get() == NULL)
|
2012-08-23 21:17:11 +00:00
|
|
|
{
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
if (!m_interpreter || !m_python_object_sp)
|
2012-08-24 01:42:50 +00:00
|
|
|
return NULL;
|
2013-05-22 23:04:27 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OS));
|
2012-10-24 18:39:14 +00:00
|
|
|
|
|
|
|
|
if (log)
|
2012-11-29 21:49:15 +00:00
|
|
|
log->Printf ("OperatingSystemPython::GetDynamicRegisterInfo() fetching thread register definitions from python for pid %" PRIu64, m_process->GetID());
|
2012-10-24 18:39:14 +00:00
|
|
|
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
PythonDictionary dictionary(m_interpreter->OSPlugin_RegisterInfo(m_python_object_sp));
|
2012-08-24 01:42:50 +00:00
|
|
|
if (!dictionary)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
<rdar://problem/14972424>
- Made the dynamic register context for the GDB remote plug-in inherit from the generic DynamicRegisterInfo to avoid code duplication
- Finished up the target definition python setting stuff.
- Added a new "slice" key/value pair that can specify that a register is part of another register:
{ 'name':'eax', 'set':0, 'bitsize':32, 'encoding':eEncodingUint, 'format':eFormatHex, 'slice': 'rax[31:0]' },
- Added a new "composite" key/value pair that can specify that a register is made up of two or more registers:
{ 'name':'d0', 'set':0, 'bitsize':64 , 'encoding':eEncodingIEEE754, 'format':eFormatFloat, 'composite': ['s1', 's0'] },
- Added a new "invalidate-regs" key/value pair for when a register is modified, it can invalidate other registers:
{ 'name':'cpsr', 'set':0, 'bitsize':32 , 'encoding':eEncodingUint, 'format':eFormatHex, 'invalidate-regs': ['r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']},
This now completes the feature that allows a GDB remote target to completely describe itself.
llvm-svn: 192858
2013-10-17 01:10:23 +00:00
|
|
|
m_register_info_ap.reset (new DynamicRegisterInfo (dictionary, m_process->GetTarget().GetArchitecture().GetByteOrder()));
|
2012-08-24 01:42:50 +00:00
|
|
|
assert (m_register_info_ap->GetNumRegisters() > 0);
|
|
|
|
|
assert (m_register_info_ap->GetNumRegisterSets() > 0);
|
2012-08-23 21:17:11 +00:00
|
|
|
}
|
|
|
|
|
return m_register_info_ap.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
// PluginInterface protocol
|
|
|
|
|
//------------------------------------------------------------------
|
2013-05-10 21:47:16 +00:00
|
|
|
ConstString
|
2012-08-23 21:17:11 +00:00
|
|
|
OperatingSystemPython::GetPluginName()
|
|
|
|
|
{
|
|
|
|
|
return GetPluginNameStatic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
|
OperatingSystemPython::GetPluginVersion()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
2013-05-07 18:35:34 +00:00
|
|
|
OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list,
|
|
|
|
|
ThreadList &core_thread_list,
|
|
|
|
|
ThreadList &new_thread_list)
|
2012-08-23 21:17:11 +00:00
|
|
|
{
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
if (!m_interpreter || !m_python_object_sp)
|
2012-12-07 22:21:08 +00:00
|
|
|
return false;
|
2012-10-24 18:39:14 +00:00
|
|
|
|
2013-05-22 23:04:27 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OS));
|
2012-10-24 18:39:14 +00:00
|
|
|
|
2012-12-07 17:42:15 +00:00
|
|
|
// 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.
|
|
|
|
|
// So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
|
|
|
|
|
Target &target = m_process->GetTarget();
|
|
|
|
|
Mutex::Locker api_locker (target.GetAPIMutex());
|
|
|
|
|
|
2012-10-24 18:39:14 +00:00
|
|
|
if (log)
|
2012-11-29 21:49:15 +00:00
|
|
|
log->Printf ("OperatingSystemPython::UpdateThreadList() fetching thread data from python for pid %" PRIu64, m_process->GetID());
|
2012-10-24 18:39:14 +00:00
|
|
|
|
2013-04-12 20:07:46 +00:00
|
|
|
// The threads that are in "new_thread_list" upon entry are the threads from the
|
|
|
|
|
// lldb_private::Process subclass, no memory threads will be in this list.
|
|
|
|
|
|
2013-03-28 00:27:30 +00:00
|
|
|
auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
PythonList threads_list(m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp));
|
|
|
|
|
if (threads_list)
|
2012-08-24 05:45:15 +00:00
|
|
|
{
|
2013-05-22 23:04:27 +00:00
|
|
|
if (log)
|
|
|
|
|
{
|
|
|
|
|
StreamString strm;
|
|
|
|
|
threads_list.Dump(strm);
|
|
|
|
|
log->Printf("threads_list = %s", strm.GetString().c_str());
|
|
|
|
|
}
|
2013-04-12 20:07:46 +00:00
|
|
|
uint32_t i;
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
const uint32_t num_threads = threads_list.GetSize();
|
2013-05-09 01:55:29 +00:00
|
|
|
if (num_threads > 0)
|
2013-04-12 20:07:46 +00:00
|
|
|
{
|
2013-05-09 01:55:29 +00:00
|
|
|
for (i=0; i<num_threads; ++i)
|
2012-08-24 05:45:15 +00:00
|
|
|
{
|
2013-05-09 01:55:29 +00:00
|
|
|
PythonDictionary thread_dict(threads_list.GetItemAtIndex(i));
|
|
|
|
|
if (thread_dict)
|
|
|
|
|
{
|
|
|
|
|
ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_dict, core_thread_list, old_thread_list, NULL));
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
new_thread_list.AddThread(thread_sp);
|
|
|
|
|
}
|
2012-08-24 05:45:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-09 01:55:29 +00:00
|
|
|
|
2013-05-29 23:31:14 +00:00
|
|
|
// No new threads added from the thread info array gotten from python, just
|
|
|
|
|
// display the core threads.
|
2013-05-09 01:55:29 +00:00
|
|
|
if (new_thread_list.GetSize(false) == 0)
|
2013-05-29 23:31:14 +00:00
|
|
|
new_thread_list = core_thread_list;
|
2013-05-09 01:55:29 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
return new_thread_list.GetSize(false) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
ThreadSP
|
2013-04-12 20:07:46 +00:00
|
|
|
OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict,
|
|
|
|
|
ThreadList &core_thread_list,
|
|
|
|
|
ThreadList &old_thread_list,
|
|
|
|
|
bool *did_create_ptr)
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
{
|
|
|
|
|
ThreadSP thread_sp;
|
|
|
|
|
if (thread_dict)
|
|
|
|
|
{
|
|
|
|
|
PythonString tid_pystr("tid");
|
|
|
|
|
const tid_t tid = thread_dict.GetItemForKeyAsInteger (tid_pystr, LLDB_INVALID_THREAD_ID);
|
2013-01-25 18:06:21 +00:00
|
|
|
if (tid != LLDB_INVALID_THREAD_ID)
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
{
|
2013-04-12 20:07:46 +00:00
|
|
|
PythonString core_pystr("core");
|
2013-01-25 18:06:21 +00:00
|
|
|
PythonString name_pystr("name");
|
|
|
|
|
PythonString queue_pystr("queue");
|
2013-05-01 21:54:04 +00:00
|
|
|
//PythonString state_pystr("state");
|
|
|
|
|
//PythonString stop_reason_pystr("stop_reason");
|
2013-01-25 18:06:21 +00:00
|
|
|
PythonString reg_data_addr_pystr ("register_data_addr");
|
|
|
|
|
|
2013-04-12 20:07:46 +00:00
|
|
|
const uint32_t core_number = thread_dict.GetItemForKeyAsInteger (core_pystr, UINT32_MAX);
|
2013-01-25 18:06:21 +00:00
|
|
|
const addr_t reg_data_addr = thread_dict.GetItemForKeyAsInteger (reg_data_addr_pystr, LLDB_INVALID_ADDRESS);
|
|
|
|
|
const char *name = thread_dict.GetItemForKeyAsString (name_pystr);
|
|
|
|
|
const char *queue = thread_dict.GetItemForKeyAsString (queue_pystr);
|
|
|
|
|
//const char *state = thread_dict.GetItemForKeyAsString (state_pystr);
|
|
|
|
|
//const char *stop_reason = thread_dict.GetItemForKeyAsString (stop_reason_pystr);
|
|
|
|
|
|
2013-05-01 21:54:04 +00:00
|
|
|
// See if a thread already exists for "tid"
|
2013-04-12 20:07:46 +00:00
|
|
|
thread_sp = old_thread_list.FindThreadByID (tid, false);
|
2013-05-01 21:54:04 +00:00
|
|
|
if (thread_sp)
|
|
|
|
|
{
|
|
|
|
|
// A thread already does exist for "tid", make sure it was an operating system
|
|
|
|
|
// plug-in generated thread.
|
|
|
|
|
if (!IsOperatingSystemPluginThread(thread_sp))
|
|
|
|
|
{
|
|
|
|
|
// We have thread ID overlap between the protocol threads and the
|
|
|
|
|
// operating system threads, clear the thread so we create an
|
|
|
|
|
// operating system thread for this.
|
|
|
|
|
thread_sp.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-25 18:06:21 +00:00
|
|
|
if (!thread_sp)
|
|
|
|
|
{
|
|
|
|
|
if (did_create_ptr)
|
|
|
|
|
*did_create_ptr = true;
|
|
|
|
|
thread_sp.reset (new ThreadMemory (*m_process,
|
|
|
|
|
tid,
|
|
|
|
|
name,
|
|
|
|
|
queue,
|
|
|
|
|
reg_data_addr));
|
2013-04-12 20:07:46 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (core_number < core_thread_list.GetSize(false))
|
|
|
|
|
{
|
2013-05-01 21:54:04 +00:00
|
|
|
ThreadSP core_thread_sp (core_thread_list.GetThreadAtIndex(core_number, false));
|
|
|
|
|
if (core_thread_sp)
|
|
|
|
|
{
|
|
|
|
|
ThreadSP backing_core_thread_sp (core_thread_sp->GetBackingThread());
|
|
|
|
|
if (backing_core_thread_sp)
|
|
|
|
|
{
|
|
|
|
|
thread_sp->SetBackingThread(backing_core_thread_sp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
thread_sp->SetBackingThread(core_thread_sp);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-25 18:06:21 +00:00
|
|
|
}
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return thread_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
void
|
|
|
|
|
OperatingSystemPython::ThreadWasSelected (Thread *thread)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegisterContextSP
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t reg_data_addr)
|
2012-08-23 21:17:11 +00:00
|
|
|
{
|
2012-08-24 05:45:15 +00:00
|
|
|
RegisterContextSP reg_ctx_sp;
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
if (!m_interpreter || !m_python_object_sp || !thread)
|
2013-05-01 21:54:04 +00:00
|
|
|
return reg_ctx_sp;
|
|
|
|
|
|
|
|
|
|
if (!IsOperatingSystemPluginThread(thread->shared_from_this()))
|
|
|
|
|
return reg_ctx_sp;
|
2012-10-24 18:39:14 +00:00
|
|
|
|
2012-12-07 17:42:15 +00:00
|
|
|
// 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.
|
|
|
|
|
// So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
|
|
|
|
|
Target &target = m_process->GetTarget();
|
|
|
|
|
Mutex::Locker api_locker (target.GetAPIMutex());
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
|
2012-10-24 18:39:14 +00:00
|
|
|
|
2013-03-28 00:27:30 +00:00
|
|
|
auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure python objects stays alive
|
2012-10-25 17:56:31 +00:00
|
|
|
if (reg_data_addr != LLDB_INVALID_ADDRESS)
|
2012-08-24 05:45:15 +00:00
|
|
|
{
|
2012-10-25 17:56:31 +00:00
|
|
|
// The registers data is in contiguous memory, just create the register
|
|
|
|
|
// context using the address provided
|
|
|
|
|
if (log)
|
2013-05-01 21:54:04 +00:00
|
|
|
log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64 ") creating memory register context",
|
|
|
|
|
thread->GetID(),
|
|
|
|
|
thread->GetProtocolID(),
|
|
|
|
|
reg_data_addr);
|
2012-10-25 17:56:31 +00:00
|
|
|
reg_ctx_sp.reset (new RegisterContextMemory (*thread, 0, *GetDynamicRegisterInfo (), reg_data_addr));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// No register data address is provided, query the python plug-in to let
|
|
|
|
|
// it make up the data as it sees fit
|
|
|
|
|
if (log)
|
2013-05-01 21:54:04 +00:00
|
|
|
log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ", 0x%" PRIx64 ") fetching register data from python",
|
|
|
|
|
thread->GetID(),
|
|
|
|
|
thread->GetProtocolID());
|
2012-10-25 17:56:31 +00:00
|
|
|
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
PythonString reg_context_data(m_interpreter->OSPlugin_RegisterContextData (m_python_object_sp, thread->GetID()));
|
2012-10-25 17:56:31 +00:00
|
|
|
if (reg_context_data)
|
2012-08-24 05:45:15 +00:00
|
|
|
{
|
2012-10-25 17:56:31 +00:00
|
|
|
DataBufferSP data_sp (new DataBufferHeap (reg_context_data.GetString(),
|
|
|
|
|
reg_context_data.GetSize()));
|
|
|
|
|
if (data_sp->GetByteSize())
|
2012-08-24 05:45:15 +00:00
|
|
|
{
|
2012-10-25 17:56:31 +00:00
|
|
|
RegisterContextMemory *reg_ctx_memory = new RegisterContextMemory (*thread, 0, *GetDynamicRegisterInfo (), LLDB_INVALID_ADDRESS);
|
|
|
|
|
if (reg_ctx_memory)
|
|
|
|
|
{
|
|
|
|
|
reg_ctx_sp.reset(reg_ctx_memory);
|
|
|
|
|
reg_ctx_memory->SetAllRegisterData (data_sp);
|
|
|
|
|
}
|
2012-08-24 05:45:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-22 18:26:52 +00:00
|
|
|
// if we still have no register data, fallback on a dummy context to avoid crashing
|
|
|
|
|
if (!reg_ctx_sp)
|
|
|
|
|
{
|
|
|
|
|
if (log)
|
|
|
|
|
log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ") forcing a dummy register context", thread->GetID());
|
|
|
|
|
reg_ctx_sp.reset(new RegisterContextDummy(*thread,0,target.GetArchitecture().GetAddressByteSize()));
|
|
|
|
|
}
|
2012-08-23 21:17:11 +00:00
|
|
|
return reg_ctx_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StopInfoSP
|
|
|
|
|
OperatingSystemPython::CreateThreadStopReason (lldb_private::Thread *thread)
|
|
|
|
|
{
|
|
|
|
|
// We should have gotten the thread stop info from the dictionary of data for
|
|
|
|
|
// the thread in the initial call to get_thread_info(), this should have been
|
|
|
|
|
// cached so we can return it here
|
|
|
|
|
StopInfoSP stop_info_sp; //(StopInfo::CreateStopReasonWithSignal (*thread, SIGSTOP));
|
|
|
|
|
return stop_info_sp;
|
|
|
|
|
}
|
|
|
|
|
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
lldb::ThreadSP
|
|
|
|
|
OperatingSystemPython::CreateThread (lldb::tid_t tid, addr_t context)
|
|
|
|
|
{
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
|
log->Printf ("OperatingSystemPython::CreateThread (tid = 0x%" PRIx64 ", context = 0x%" PRIx64 ") fetching register data from python", tid, context);
|
|
|
|
|
|
|
|
|
|
if (m_interpreter && m_python_object_sp)
|
|
|
|
|
{
|
|
|
|
|
// 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.
|
|
|
|
|
// So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
|
|
|
|
|
Target &target = m_process->GetTarget();
|
|
|
|
|
Mutex::Locker api_locker (target.GetAPIMutex());
|
|
|
|
|
|
2013-03-28 00:27:30 +00:00
|
|
|
auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
PythonDictionary thread_info_dict (m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context));
|
|
|
|
|
if (thread_info_dict)
|
|
|
|
|
{
|
2013-04-12 20:07:46 +00:00
|
|
|
ThreadList core_threads(m_process);
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
ThreadList &thread_list = m_process->GetThreadList();
|
|
|
|
|
bool did_create = false;
|
2013-04-12 20:07:46 +00:00
|
|
|
ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_info_dict, core_threads, thread_list, &did_create));
|
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-18 23:41:08 +00:00
|
|
|
if (did_create)
|
|
|
|
|
thread_list.AddThread(thread_sp);
|
|
|
|
|
return thread_sp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ThreadSP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
|
|
|
|
|
#endif // #ifndef LLDB_DISABLE_PYTHON
|