aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2024-09-20 09:52:32 +0000
committerDavid Spickett <david.spickett@linaro.org>2024-09-20 09:57:07 +0000
commit801046e3303eed43bffebb84e9e505cc19cad5c0 (patch)
treecdec65aa41de8e852ba5b01c020fc47a396ec746 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent413b12a5aba09f136c51923fe568c7269ef93c35 (diff)
downloadllvm-801046e3303eed43bffebb84e9e505cc19cad5c0.zip
llvm-801046e3303eed43bffebb84e9e505cc19cad5c0.tar.gz
llvm-801046e3303eed43bffebb84e9e505cc19cad5c0.tar.bz2
Revert "[lldb] Fix SWIG wrapper compilation error"
...and "[lldb/Interpreter] Introduce `ScriptedStopHook{,Python}Interface` & make use of it (#105449)" This reverts commit 76b827bb4d5b4cc4d3229c4c6de2529e8b156810, and commit 1e131ddfa8f1d7b18c85c6e4079458be8b419421 because the first commit caused the test command-stop-hook-output.test to fail.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp56
1 files changed, 51 insertions, 5 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 155efc0..63691d2 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1559,11 +1559,6 @@ ScriptInterpreterPythonImpl::CreateScriptedProcessInterface() {
return std::make_unique<ScriptedProcessPythonInterface>(*this);
}
-ScriptedStopHookInterfaceSP
-ScriptInterpreterPythonImpl::CreateScriptedStopHookInterface() {
- return std::make_shared<ScriptedStopHookPythonInterface>(*this);
-}
-
ScriptedThreadInterfaceSP
ScriptInterpreterPythonImpl::CreateScriptedThreadInterface() {
return std::make_shared<ScriptedThreadPythonInterface>(*this);
@@ -1659,6 +1654,57 @@ ScriptInterpreterPythonImpl::ScriptedBreakpointResolverSearchDepth(
return lldb::eSearchDepthModule;
}
+StructuredData::GenericSP ScriptInterpreterPythonImpl::CreateScriptedStopHook(
+ TargetSP target_sp, const char *class_name,
+ const StructuredDataImpl &args_data, Status &error) {
+
+ if (!target_sp) {
+ error = Status::FromErrorString("No target for scripted stop-hook.");
+ return StructuredData::GenericSP();
+ }
+
+ if (class_name == nullptr || class_name[0] == '\0') {
+ error = Status::FromErrorString("No class name for scripted stop-hook.");
+ return StructuredData::GenericSP();
+ }
+
+ ScriptInterpreterPythonImpl *python_interpreter =
+ GetPythonInterpreter(m_debugger);
+
+ if (!python_interpreter) {
+ error = Status::FromErrorString(
+ "No script interpreter for scripted stop-hook.");
+ return StructuredData::GenericSP();
+ }
+
+ Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+
+ PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedStopHook(
+ target_sp, class_name, python_interpreter->m_dictionary_name.c_str(),
+ args_data, error);
+
+ return StructuredData::GenericSP(
+ new StructuredPythonObject(std::move(ret_val)));
+}
+
+bool ScriptInterpreterPythonImpl::ScriptedStopHookHandleStop(
+ StructuredData::GenericSP implementor_sp, ExecutionContext &exc_ctx,
+ lldb::StreamSP stream_sp) {
+ assert(implementor_sp &&
+ "can't call a stop hook with an invalid implementor");
+ assert(stream_sp && "can't call a stop hook with an invalid stream");
+
+ Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+
+ lldb::ExecutionContextRefSP exc_ctx_ref_sp(new ExecutionContextRef(exc_ctx));
+
+ bool ret_val = SWIGBridge::LLDBSwigPythonStopHookCallHandleStop(
+ implementor_sp->GetValue(), exc_ctx_ref_sp, stream_sp);
+ return ret_val;
+}
+
StructuredData::ObjectSP
ScriptInterpreterPythonImpl::LoadPluginModule(const FileSpec &file_spec,
lldb_private::Status &error) {