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);
85 ToSWIGWrapper(std::unique_ptr<lldb::SBCommandReturnObject> result_up);
92 static PythonObject ToSWIGWrapper(Status &&status);
93 static PythonObject ToSWIGWrapper(
const StructuredDataImpl &data_impl);
101 static PythonObject ToSWIGWrapper(
const TypeSummaryOptions &summary_options);
102 static PythonObject ToSWIGWrapper(
const SymbolContext &sym_ctx);
103 static PythonObject ToSWIGWrapper(
const Stream *stream);
104 static PythonObject ToSWIGWrapper(std::shared_ptr<lldb::SBStream> stream_sb);
105 static PythonObject ToSWIGWrapper(Event *event);
112 ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb);
114 ToSWIGWrapper(std::unique_ptr<lldb::SBFileSpec> file_spec_sb);
116 ToSWIGWrapper(std::unique_ptr<lldb::SBModuleSpec> module_spec_sb);
118 static python::ScopedPythonObject<lldb::SBCommandReturnObject>
119 ToSWIGWrapper(CommandReturnObject &cmd_retobj);
124 static llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
125 const char *python_function_name,
const char *session_dictionary_name,
128 const lldb_private::StructuredDataImpl &args_impl);
130 static bool LLDBSwigPythonWatchpointCallbackFunction(
131 const char *python_function_name,
const char *session_dictionary_name,
135 LLDBSwigPythonFormatterCallbackFunction(
const char *python_function_name,
136 const char *session_dictionary_name,
139 static bool LLDBSwigPythonCallTypeScript(
140 const char *python_function_name,
const void *session_dictionary,
144 static python::PythonObject
145 LLDBSwigPythonCreateSyntheticProvider(
const char *python_class_name,
146 const char *session_dictionary_name,
149 static python::PythonObject
150 LLDBSwigPythonCreateCommandObject(
const char *python_class_name,
151 const char *session_dictionary_name,
154 static size_t LLDBSwigPython_CalculateNumChildren(PyObject *implementor,
157 static PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor,
160 static int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor,
161 const char *child_name);
164 LLDBSWIGPython_GetValueObjectSPFromSBValue(
void *data);
166 static bool LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor);
169 LLDBSwigPython_MightHaveChildrenSynthProviderInstance(PyObject *implementor);
172 LLDBSwigPython_GetValueSynthProviderInstance(PyObject *implementor);
175 LLDBSwigPythonCallCommand(
const char *python_function_name,
176 const char *session_dictionary_name,
178 lldb_private::CommandReturnObject &cmd_retobj,
182 LLDBSwigPythonCallCommandObject(PyObject *implementor,
184 lldb_private::CommandReturnObject &cmd_retobj,
186 static bool LLDBSwigPythonCallParsedCommandObject(
188 StructuredDataImpl &args_impl,
189 lldb_private::CommandReturnObject &cmd_retobj,
192 static std::optional<std::string>
193 LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor,
194 std::string &command);
196 static StructuredData::DictionarySP
197 LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(
198 PyObject *implementor, std::vector<llvm::StringRef> &args_impl,
199 size_t args_pos,
size_t pos_in_arg);
201 static StructuredData::DictionarySP
202 LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(
203 PyObject *implementor, llvm::StringRef &long_option,
size_t pos_in_arg);
205 static bool LLDBSwigPythonCallModuleInit(
const char *python_module_name,
206 const char *session_dictionary_name,
210 LLDBSwigPythonCallModuleNewTarget(
const char *python_module_name,
211 const char *session_dictionary_name,
214 static python::PythonObject
215 LLDBSWIGPythonCreateOSPlugin(
const char *python_class_name,
216 const char *session_dictionary_name,
219 static python::PythonObject
220 LLDBSWIGPython_CreateFrameRecognizer(
const char *python_class_name,
221 const char *session_dictionary_name);
224 LLDBSwigPython_GetRecognizedArguments(PyObject *implementor,
227 static bool LLDBSwigPython_ShouldHide(PyObject *implementor,
230 static bool LLDBSWIGPythonRunScriptKeywordProcess(
231 const char *python_function_name,
const char *session_dictionary_name,
234 static std::optional<std::string>
235 LLDBSWIGPythonRunScriptKeywordThread(
const char *python_function_name,
236 const char *session_dictionary_name,
239 static bool LLDBSWIGPythonRunScriptKeywordTarget(
240 const char *python_function_name,
const char *session_dictionary_name,
243 static std::optional<std::string>
244 LLDBSWIGPythonRunScriptKeywordFrame(
const char *python_function_name,
245 const char *session_dictionary_name,
248 static bool LLDBSWIGPythonRunScriptKeywordValue(
249 const char *python_function_name,
const char *session_dictionary_name,
253 LLDBSWIGPython_GetDynamicSetting(
void *module,
const char *setting,
257void *LLDBSWIGPython_CastPyObjectToSBData(PyObject *data);
258void *LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data);
259void *LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data);
260void *LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data);
261void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data);
262void *LLDBSWIGPython_CastPyObjectToSBEvent(PyObject *data);
263void *LLDBSWIGPython_CastPyObjectToSBStream(PyObject *data);
264void *LLDBSWIGPython_CastPyObjectToSBSymbolContext(PyObject *data);
265void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data);
266void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data);
267void *LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyObject *data);
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
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::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
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
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP