diff options
author | Med Ismail Bennani <medismail.bennani@gmail.com> | 2021-10-06 00:09:20 +0000 |
---|---|---|
committer | Med Ismail Bennani <medismail.bennani@gmail.com> | 2021-10-08 14:54:07 +0200 |
commit | 59d8dd79e1f9dead2dc2756e139073083e487228 (patch) | |
tree | 4f45c1452f97e10655c8e69549ab146ee93d0d2c /lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | |
parent | 6393c21d476de2584b3ac010aace6a9b26d5bbec (diff) | |
download | llvm-59d8dd79e1f9dead2dc2756e139073083e487228.zip llvm-59d8dd79e1f9dead2dc2756e139073083e487228.tar.gz llvm-59d8dd79e1f9dead2dc2756e139073083e487228.tar.bz2 |
[lldb/Plugins] Add support for ScriptedThread in ScriptedProcess
This patch introduces the `ScriptedThread` class with its python
interface.
When used with `ScriptedProcess`, `ScriptedThreaad` can provide various
information such as the thread state, stop reason or even its register
context.
This can be used to reconstruct the program stack frames using lldb's unwinder.
rdar://74503836
Differential Revision: https://reviews.llvm.org/D107585
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index bac4efb..9f76ed8 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -38,15 +38,13 @@ protected: using namespace python; using Locker = ScriptInterpreterPythonImpl::Locker; - auto error_with_message = [&method_name, &error](llvm::StringRef message) { - error.SetErrorStringWithFormatv( - "ScriptedPythonInterface::{0} ({1}) ERROR = {2}", __FUNCTION__, - method_name, message); - return T(); - }; - + std::string caller_signature = + llvm::Twine(__PRETTY_FUNCTION__ + llvm::Twine(" (") + + llvm::Twine(method_name) + llvm::Twine(")")) + .str(); if (!m_object_instance_sp) - return error_with_message("Python object ill-formed"); + return ErrorWithMessage<T>(caller_signature, "Python object ill-formed", + error); Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); @@ -55,7 +53,8 @@ protected: (PyObject *)m_object_instance_sp->GetValue()); if (!implementor.IsAllocated()) - return error_with_message("Python implementor not allocated."); + return ErrorWithMessage<T>(caller_signature, + "Python implementor not allocated.", error); PythonObject pmeth( PyRefType::Owned, @@ -65,12 +64,14 @@ protected: PyErr_Clear(); if (!pmeth.IsAllocated()) - return error_with_message("Python method not allocated."); + return ErrorWithMessage<T>(caller_signature, + "Python method not allocated.", error); if (PyCallable_Check(pmeth.get()) == 0) { if (PyErr_Occurred()) PyErr_Clear(); - return error_with_message("Python method not callable."); + return ErrorWithMessage<T>(caller_signature, + "Python method not callable.", error); } if (PyErr_Occurred()) @@ -96,11 +97,13 @@ protected: if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); - return error_with_message("Python method could not be called."); + return ErrorWithMessage<T>(caller_signature, + "Python method could not be called.", error); } if (!py_return.IsAllocated()) - return error_with_message("Returned object is null."); + return ErrorWithMessage<T>(caller_signature, "Returned object is null.", + error); return ExtractValueFromPythonObject<T>(py_return, error); } @@ -124,6 +127,11 @@ protected: }; template <> +StructuredData::DictionarySP +ScriptedPythonInterface::ExtractValueFromPythonObject< + StructuredData::DictionarySP>(python::PythonObject &p, Status &error); + +template <> Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>( python::PythonObject &p, Status &error); |