forked from OSchip/llvm-project
[lldb/Plugins] Move ScriptedThreadInterface to ScriptedThread
Since we can have multiple Scripted Threads per Scripted Process, having only a single ScriptedThreadInterface (with a single object instance) will cause the method calls to be done on the wrong object. Instead, this patch creates a separate ScriptedThreadInterface for each new lldb_private::ScriptedThread to make sure we interact with the right instance. rdar://87427911 Differential Revision: https://reviews.llvm.org/D117070 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
parent
4858fe04a1
commit
1b86344fa8
|
@ -68,11 +68,9 @@ public:
|
|||
|
||||
protected:
|
||||
friend class ScriptedThread;
|
||||
virtual lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() {
|
||||
virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr;
|
||||
};
|
||||
|
||||
class ScriptedThreadInterface : virtual public ScriptedInterface {
|
||||
|
|
|
@ -29,7 +29,9 @@ void ScriptedThread::CheckInterpreterAndScriptObject() const {
|
|||
}
|
||||
|
||||
ScriptedThread::ScriptedThread(ScriptedProcess &process, Status &error)
|
||||
: Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process) {
|
||||
: Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process),
|
||||
m_scripted_thread_interface_sp(
|
||||
m_scripted_process.GetInterface().CreateScriptedThreadInterface()) {
|
||||
if (!process.IsValid()) {
|
||||
error.SetErrorString("Invalid scripted process");
|
||||
return;
|
||||
|
@ -190,7 +192,7 @@ void ScriptedThread::RefreshStateAfterStop() {
|
|||
}
|
||||
|
||||
lldb::ScriptedThreadInterfaceSP ScriptedThread::GetInterface() const {
|
||||
return m_scripted_process.GetInterface().GetScriptedThreadInterface();
|
||||
return m_scripted_thread_interface_sp;
|
||||
}
|
||||
|
||||
std::shared_ptr<DynamicRegisterInfo> ScriptedThread::GetDynamicRegisterInfo() {
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo();
|
||||
|
||||
const ScriptedProcess &m_scripted_process;
|
||||
lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr;
|
||||
std::shared_ptr<DynamicRegisterInfo> m_register_info_sp = nullptr;
|
||||
lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr;
|
||||
};
|
||||
|
|
|
@ -165,12 +165,8 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() {
|
|||
}
|
||||
|
||||
lldb::ScriptedThreadInterfaceSP
|
||||
ScriptedProcessPythonInterface::GetScriptedThreadInterface() {
|
||||
if (!m_scripted_thread_interface_sp)
|
||||
m_scripted_thread_interface_sp =
|
||||
std::make_shared<ScriptedThreadPythonInterface>(m_interpreter);
|
||||
|
||||
return m_scripted_thread_interface_sp;
|
||||
ScriptedProcessPythonInterface::CreateScriptedThreadInterface() {
|
||||
return std::make_shared<ScriptedThreadPythonInterface>(m_interpreter);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
llvm::Optional<std::string> GetScriptedThreadPluginName() override;
|
||||
|
||||
private:
|
||||
lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() override;
|
||||
lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
|
||||
};
|
||||
} // namespace lldb_private
|
||||
|
||||
|
|
Loading…
Reference in New Issue