2015-10-21 18:46:17 +00:00
|
|
|
//===-- OperatingSystemPython.h ---------------------------------*- C++ -*-===//
|
2012-08-23 21:17:11 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-08-23 21:17:11 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#ifndef liblldb_OperatingSystemPython_h_
|
|
|
|
|
#define liblldb_OperatingSystemPython_h_
|
|
|
|
|
|
2019-12-10 08:54:30 -08:00
|
|
|
#include "lldb/Host/Config.h"
|
|
|
|
|
|
2019-12-13 10:37:33 -08:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2015-10-21 18:46:17 +00:00
|
|
|
|
2021-10-01 17:21:45 +02:00
|
|
|
#include "lldb/Target/DynamicRegisterInfo.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
#include "lldb/Target/OperatingSystem.h"
|
2017-06-27 10:45:31 +00:00
|
|
|
#include "lldb/Utility/StructuredData.h"
|
2012-08-23 21:17:11 +00:00
|
|
|
|
2015-03-17 20:04:04 +00:00
|
|
|
namespace lldb_private {
|
|
|
|
|
class ScriptInterpreter;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
class OperatingSystemPython : public lldb_private::OperatingSystem {
|
|
|
|
|
public:
|
2015-10-21 18:46:17 +00:00
|
|
|
OperatingSystemPython(lldb_private::Process *process,
|
|
|
|
|
const lldb_private::FileSpec &python_module_path);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-21 18:46:17 +00:00
|
|
|
~OperatingSystemPython() override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
// Static Functions
|
|
|
|
|
static lldb_private::OperatingSystem *
|
|
|
|
|
CreateInstance(lldb_private::Process *process, bool force);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
static void Initialize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
static void Terminate();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-05-10 21:47:16 +00:00
|
|
|
static lldb_private::ConstString GetPluginNameStatic();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
static const char *GetPluginDescriptionStatic();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
// lldb_private::PluginInterface Methods
|
2015-10-21 18:46:17 +00:00
|
|
|
lldb_private::ConstString GetPluginName() override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
// lldb_private::OperatingSystem Methods
|
2015-10-21 18:46:17 +00:00
|
|
|
bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
|
|
|
|
|
lldb_private::ThreadList &real_thread_list,
|
|
|
|
|
lldb_private::ThreadList &new_thread_list) override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-21 18:46:17 +00:00
|
|
|
void ThreadWasSelected(lldb_private::Thread *thread) override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-21 18:46:17 +00:00
|
|
|
lldb::RegisterContextSP
|
|
|
|
|
CreateRegisterContextForThread(lldb_private::Thread *thread,
|
|
|
|
|
lldb::addr_t reg_data_addr) override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-21 18:46:17 +00:00
|
|
|
lldb::StopInfoSP
|
|
|
|
|
CreateThreadStopReason(lldb_private::Thread *thread) override;
|
2016-09-06 20:57:50 +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
|
|
|
// Method for lazy creation of threads on demand
|
2015-10-21 18:46:17 +00:00
|
|
|
lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) override;
|
<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
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
protected:
|
2012-10-18 22:40:37 +00:00
|
|
|
bool IsValid() const {
|
2015-03-17 20:04:04 +00:00
|
|
|
return m_python_object_sp && m_python_object_sp->IsValid();
|
2012-10-18 22:40:37 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-17 20:04:04 +00:00
|
|
|
lldb::ThreadSP CreateThreadFromThreadInfo(
|
|
|
|
|
lldb_private::StructuredData::Dictionary &thread_dict,
|
|
|
|
|
lldb_private::ThreadList &core_thread_list,
|
|
|
|
|
lldb_private::ThreadList &old_thread_list,
|
|
|
|
|
std::vector<bool> &core_used_map, bool *did_create_ptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-10-01 17:21:45 +02:00
|
|
|
lldb_private::DynamicRegisterInfo *GetDynamicRegisterInfo();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-23 21:17:11 +00:00
|
|
|
lldb::ValueObjectSP m_thread_list_valobj_sp;
|
2021-10-01 17:21:45 +02:00
|
|
|
std::unique_ptr<lldb_private::DynamicRegisterInfo> m_register_info_up;
|
2012-08-24 00:30:47 +00:00
|
|
|
lldb_private::ScriptInterpreter *m_interpreter;
|
2015-03-17 20:04:04 +00:00
|
|
|
lldb_private::StructuredData::ObjectSP m_python_object_sp;
|
2012-08-23 21:17:11 +00:00
|
|
|
};
|
|
|
|
|
|
2021-10-01 17:21:45 +02:00
|
|
|
#endif // LLDB_ENABLE_PYTHON
|
2015-10-21 18:46:17 +00:00
|
|
|
|
|
|
|
|
#endif // liblldb_OperatingSystemPython_h_
|