9#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H
10#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H
15#include "lldb/Host/Config.h"
25#include "llvm/Support/Error.h"
41typedef struct swig_type_info swig_type_info;
43python::PythonObject ToSWIGHelper(
void *obj, swig_type_info *info);
47template <
typename T>
class ScopedPythonObject : PythonObject {
49 ScopedPythonObject(T *sb, swig_type_info *info)
50 : PythonObject(ToSWIGHelper(sb, info)), m_sb(sb) {}
51 ~ScopedPythonObject() {
55 ScopedPythonObject(ScopedPythonObject &&rhs)
56 : PythonObject(std::move(rhs)), m_sb(std::exchange(rhs.m_sb, nullptr)) {}
57 ScopedPythonObject(
const ScopedPythonObject &) =
delete;
58 ScopedPythonObject &operator=(
const ScopedPythonObject &) =
delete;
59 ScopedPythonObject &operator=(ScopedPythonObject &&) =
delete;
61 const PythonObject &obj()
const {
return *
this; }
83 static PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb);
89 static PythonObject ToSWIGWrapper(
const Status &status);
90 static PythonObject ToSWIGWrapper(
const StructuredDataImpl &data_impl);
98 static PythonObject ToSWIGWrapper(
const TypeSummaryOptions &summary_options);
99 static PythonObject ToSWIGWrapper(
const SymbolContext &sym_ctx);
105 static PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb);
107 ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb);
109 ToSWIGWrapper(std::unique_ptr<lldb::SBFileSpec> file_spec_sb);
111 ToSWIGWrapper(std::unique_ptr<lldb::SBModuleSpec> module_spec_sb);
113 static python::ScopedPythonObject<lldb::SBCommandReturnObject>
114 ToSWIGWrapper(CommandReturnObject &cmd_retobj);
115 static python::ScopedPythonObject<lldb::SBEvent> ToSWIGWrapper(Event *event);
120 static llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
121 const char *python_function_name,
const char *session_dictionary_name,
126 static bool LLDBSwigPythonWatchpointCallbackFunction(
127 const char *python_function_name,
const char *session_dictionary_name,
131 LLDBSwigPythonFormatterCallbackFunction(
const char *python_function_name,
132 const char *session_dictionary_name,
135 static bool LLDBSwigPythonCallTypeScript(
136 const char *python_function_name,
const void *session_dictionary,
140 static python::PythonObject
141 LLDBSwigPythonCreateSyntheticProvider(
const char *python_class_name,
142 const char *session_dictionary_name,
145 static python::PythonObject
146 LLDBSwigPythonCreateCommandObject(
const char *python_class_name,
147 const char *session_dictionary_name,
150 static python::PythonObject LLDBSwigPythonCreateScriptedThreadPlan(
151 const char *python_class_name,
const char *session_dictionary_name,
152 const StructuredDataImpl &args_data, std::string &error_string,
155 static bool LLDBSWIGPythonCallThreadPlan(
void *implementor,
156 const char *method_name,
160 static bool LLDBSWIGPythonCallThreadPlan(
void *implementor,
161 const char *method_name,
165 static python::PythonObject LLDBSwigPythonCreateScriptedBreakpointResolver(
166 const char *python_class_name,
const char *session_dictionary_name,
170 LLDBSwigPythonCallBreakpointResolver(
void *implementor,
171 const char *method_name,
174 static python::PythonObject LLDBSwigPythonCreateScriptedStopHook(
176 const char *session_dictionary_name,
const StructuredDataImpl &args,
180 LLDBSwigPythonStopHookCallHandleStop(
void *implementor,
184 static size_t LLDBSwigPython_CalculateNumChildren(PyObject *implementor,
187 static PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor,
190 static int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor,
191 const char *child_name);
194 LLDBSWIGPython_GetValueObjectSPFromSBValue(
void *data);
196 static bool LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor);
199 LLDBSwigPython_MightHaveChildrenSynthProviderInstance(PyObject *implementor);
202 LLDBSwigPython_GetValueSynthProviderInstance(PyObject *implementor);
205 LLDBSwigPythonCallCommand(
const char *python_function_name,
206 const char *session_dictionary_name,
212 LLDBSwigPythonCallCommandObject(PyObject *implementor,
217 LLDBSwigPythonCallParsedCommandObject(PyObject *implementor,
219 StructuredDataImpl &args_impl,
223 static bool LLDBSwigPythonCallModuleInit(
const char *python_module_name,
224 const char *session_dictionary_name,
227 static python::PythonObject
228 LLDBSWIGPythonCreateOSPlugin(
const char *python_class_name,
229 const char *session_dictionary_name,
232 static python::PythonObject
233 LLDBSWIGPython_CreateFrameRecognizer(
const char *python_class_name,
234 const char *session_dictionary_name);
237 LLDBSwigPython_GetRecognizedArguments(PyObject *implementor,
240 static bool LLDBSWIGPythonRunScriptKeywordProcess(
241 const char *python_function_name,
const char *session_dictionary_name,
244 static std::optional<std::string>
245 LLDBSWIGPythonRunScriptKeywordThread(
const char *python_function_name,
246 const char *session_dictionary_name,
249 static bool LLDBSWIGPythonRunScriptKeywordTarget(
250 const char *python_function_name,
const char *session_dictionary_name,
253 static std::optional<std::string>
254 LLDBSWIGPythonRunScriptKeywordFrame(
const char *python_function_name,
255 const char *session_dictionary_name,
258 static bool LLDBSWIGPythonRunScriptKeywordValue(
259 const char *python_function_name,
const char *session_dictionary_name,
263 LLDBSWIGPython_GetDynamicSetting(
void *module,
const char *setting,
267void *LLDBSWIGPython_CastPyObjectToSBData(PyObject *data);
268void *LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data);
269void *LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data);
270void *LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data);
271void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data);
272void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data);
273void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data);
static llvm::raw_ostream & error(Stream &strm)
A stream class that can stream formatted output to a file.
Defines a symbol context baton that can be handed other debug core functions.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
class LLDB_API SBFileSpec
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
class LLDB_API SBStructuredData
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
std::shared_ptr< lldb_private::TypeSummaryOptions > TypeSummaryOptionsSP
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
class LLDB_API SBStringList
std::shared_ptr< lldb_private::TypeImpl > TypeImplSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
class LLDB_API SBModuleSpec
class LLDB_API SBCommandReturnObject
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP