[Lldb-commits] [lldb] 1b86344 - [lldb/Plugins] Move ScriptedThreadInterface to ScriptedThread
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 24 11:26:12 PST 2022
Author: Med Ismail Bennani
Date: 2022-01-24T20:25:53+01:00
New Revision: 1b86344fa80bd11853e0347ea33dc6cb5a460c4f
URL: https://github.com/llvm/llvm-project/commit/1b86344fa80bd11853e0347ea33dc6cb5a460c4f
DIFF: https://github.com/llvm/llvm-project/commit/1b86344fa80bd11853e0347ea33dc6cb5a460c4f.diff
LOG: [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 at gmail.com>
Added:
Modified:
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
index efdea6df2d417..d62767417f339 100644
--- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -68,11 +68,9 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
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 {
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index 959b8c5818852..4185e1b67587b 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -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() {
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.h b/lldb/source/Plugins/Process/scripted/ScriptedThread.h
index cdcd543702a48..54b095777ab73 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.h
@@ -59,6 +59,7 @@ class ScriptedThread : public lldb_private::Thread {
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;
};
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
index 447bceebb00b4..29516c4c4501e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -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
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
index ac4e768b2d31b..83507a93bb973 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -57,7 +57,7 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
llvm::Optional<std::string> GetScriptedThreadPluginName() override;
private:
- lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() override;
+ lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
};
} // namespace lldb_private
More information about the lldb-commits
mailing list