aboutsummaryrefslogtreecommitdiff
path: root/lldb/bindings/python/python-wrapper.swig
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /lldb/bindings/python/python-wrapper.swig
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'lldb/bindings/python/python-wrapper.swig')
-rw-r--r--lldb/bindings/python/python-wrapper.swig272
1 files changed, 201 insertions, 71 deletions
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index 9a08c3000b79..cb54901e66d0 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -16,7 +16,7 @@ private:
bool m_print;
};
-llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
+llvm::Expected<bool> lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &frame_sp,
const lldb::BreakpointLocationSP &bp_loc_sp,
@@ -37,13 +37,13 @@ llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
else
return arg_info.takeError();
- PythonObject frame_arg = ToSWIGWrapper(frame_sp);
- PythonObject bp_loc_arg = ToSWIGWrapper(bp_loc_sp);
+ PythonObject frame_arg = SWIGBridge::ToSWIGWrapper(frame_sp);
+ PythonObject bp_loc_arg = SWIGBridge::ToSWIGWrapper(bp_loc_sp);
auto result =
max_positional_args < 4
? pfunc.Call(frame_arg, bp_loc_arg, dict)
- : pfunc.Call(frame_arg, bp_loc_arg, ToSWIGWrapper(args_impl), dict);
+ : pfunc.Call(frame_arg, bp_loc_arg, SWIGBridge::ToSWIGWrapper(args_impl), dict);
if (!result)
return result.takeError();
@@ -65,7 +65,7 @@ llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
// lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...) and is
// used when a script command is attached to a watchpoint for execution.
-bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp) {
@@ -82,7 +82,7 @@ bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
return stop_at_watchpoint;
PythonObject result =
- pfunc(ToSWIGWrapper(frame_sp), ToSWIGWrapper(wp_sp), dict);
+ pfunc(SWIGBridge::ToSWIGWrapper(frame_sp), SWIGBridge::ToSWIGWrapper(wp_sp), dict);
if (result.get() == Py_False)
stop_at_watchpoint = false;
@@ -94,7 +94,7 @@ bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
// ScriptInterpreterPython::FormatterMatchingCallbackFunction and it's used when
// a data formatter provides the name of a callback to inspect a candidate type
// before considering a match.
-bool lldb_private::LLDBSwigPythonFormatterCallbackFunction(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonFormatterCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
lldb::TypeImplSP type_impl_sp) {
@@ -109,14 +109,14 @@ bool lldb_private::LLDBSwigPythonFormatterCallbackFunction(
return false;
PythonObject result =
- pfunc(ToSWIGWrapper(type_impl_sp), dict);
+ pfunc(SWIGBridge::ToSWIGWrapper(type_impl_sp), dict);
// Only if everything goes okay and the function returns True we'll consider
// it a match.
return result.get() == Py_True;
}
-bool lldb_private::LLDBSwigPythonCallTypeScript(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(
const char *python_function_name, const void *session_dictionary,
const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {
@@ -166,19 +166,19 @@ bool lldb_private::LLDBSwigPythonCallTypeScript(
return false;
}
- PythonObject value_arg = ToSWIGWrapper(valobj_sp);
+ PythonObject value_arg = SWIGBridge::ToSWIGWrapper(valobj_sp);
if (argc.get().max_positional_args < 3)
result = pfunc(value_arg, dict);
else
- result = pfunc(value_arg, dict, ToSWIGWrapper(*options_sp));
+ result = pfunc(value_arg, dict, SWIGBridge::ToSWIGWrapper(*options_sp));
retval = result.Str().GetString().str();
return true;
}
-PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider(
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider(
const char *python_class_name, const char *session_dictionary_name,
const lldb::ValueObjectSP &valobj_sp) {
if (python_class_name == NULL || python_class_name[0] == '\0' ||
@@ -195,10 +195,10 @@ PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider(
if (!pfunc.IsAllocated())
return PythonObject();
- auto sb_value = std::make_unique<lldb::SBValue>(valobj_sp);
+ auto sb_value = std::unique_ptr<lldb::SBValue>(new lldb::SBValue(valobj_sp));
sb_value->SetPreferSyntheticValue(false);
- PythonObject val_arg = ToSWIGWrapper(std::move(sb_value));
+ PythonObject val_arg = SWIGBridge::ToSWIGWrapper(std::move(sb_value));
if (!val_arg.IsAllocated())
return PythonObject();
@@ -210,7 +210,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider(
return PythonObject();
}
-PythonObject lldb_private::LLDBSwigPythonCreateCommandObject(
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject(
const char *python_class_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger_sp) {
if (python_class_name == NULL || python_class_name[0] == '\0' ||
@@ -226,10 +226,10 @@ PythonObject lldb_private::LLDBSwigPythonCreateCommandObject(
if (!pfunc.IsAllocated())
return PythonObject();
- return pfunc(ToSWIGWrapper(std::move(debugger_sp)), dict);
+ return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
}
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject(
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject(
const char *python_class_name, const char *session_dictionary_name,
lldb::ExecutionContextRefSP exe_ctx_sp,
const lldb_private::StructuredDataImpl &args_impl,
@@ -264,7 +264,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject(
PythonObject result = {};
if (arg_info.get().max_positional_args == 2) {
- result = pfunc(ToSWIGWrapper(exe_ctx_sp), ToSWIGWrapper(args_impl));
+ result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp), SWIGBridge::ToSWIGWrapper(args_impl));
} else {
error_string.assign("wrong number of arguments in __init__, should be 2 "
"(not including self)");
@@ -272,7 +272,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject(
return result;
}
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
const char *python_class_name, const char *session_dictionary_name,
const lldb_private::StructuredDataImpl &args_impl,
std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) {
@@ -293,7 +293,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
return PythonObject();
}
- PythonObject tp_arg = ToSWIGWrapper(thread_plan_sp);
+ PythonObject tp_arg = SWIGBridge::ToSWIGWrapper(thread_plan_sp);
llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo();
if (!arg_info) {
@@ -307,7 +307,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
}
PythonObject result = {};
- auto args_sb = std::make_unique<lldb::SBStructuredData>(args_impl);
+ auto args_sb = std::unique_ptr<lldb::SBStructuredData>(new lldb::SBStructuredData(args_impl));
if (arg_info.get().max_positional_args == 2) {
if (args_sb->IsValid()) {
error_string.assign(
@@ -316,7 +316,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
}
result = pfunc(tp_arg, dict);
} else if (arg_info.get().max_positional_args >= 3) {
- result = pfunc(tp_arg, ToSWIGWrapper(std::move(args_sb)), dict);
+ result = pfunc(tp_arg, SWIGBridge::ToSWIGWrapper(std::move(args_sb)), dict);
} else {
error_string.assign("wrong number of arguments in __init__, should be 2 or "
"3 (not including self)");
@@ -329,7 +329,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
return result;
}
-bool lldb_private::LLDBSWIGPythonCallThreadPlan(
+bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
void *implementor, const char *method_name, lldb_private::Event *event,
bool &got_error) {
got_error = false;
@@ -343,7 +343,7 @@ bool lldb_private::LLDBSWIGPythonCallThreadPlan(
PythonObject result;
if (event != nullptr) {
- ScopedPythonObject<SBEvent> event_arg = ToSWIGWrapper(event);
+ ScopedPythonObject<SBEvent> event_arg = SWIGBridge::ToSWIGWrapper(event);
result = pfunc(event_arg.obj());
} else
result = pfunc();
@@ -367,7 +367,39 @@ bool lldb_private::LLDBSWIGPythonCallThreadPlan(
return false;
}
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
+bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
+ void *implementor, const char *method_name, lldb_private::Stream *stream,
+ bool &got_error) {
+ got_error = false;
+
+ PyErr_Cleaner py_err_cleaner(false);
+ PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementor));
+ auto pfunc = self.ResolveName<PythonCallable>(method_name);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ auto *sb_stream = new lldb::SBStream();
+ PythonObject sb_stream_arg =
+ SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStream>(sb_stream));
+
+ PythonObject result;
+ result = pfunc(sb_stream_arg);
+
+ if (PyErr_Occurred()) {
+ printf("Error occured for call to %s.\n",
+ method_name);
+ PyErr_Print();
+ got_error = true;
+ return false;
+ }
+ if (stream)
+ stream->PutCString(sb_stream->GetData());
+ return true;
+
+}
+
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedBreakpointResolver(
const char *python_class_name, const char *session_dictionary_name,
const StructuredDataImpl &args_impl,
const lldb::BreakpointSP &breakpoint_sp) {
@@ -387,7 +419,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
return PythonObject();
PythonObject result =
- pfunc(ToSWIGWrapper(breakpoint_sp), ToSWIGWrapper(args_impl), dict);
+ pfunc(SWIGBridge::ToSWIGWrapper(breakpoint_sp), SWIGBridge::ToSWIGWrapper(args_impl), dict);
// FIXME: At this point we should check that the class we found supports all
// the methods that we need.
@@ -400,7 +432,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
return PythonObject();
}
-unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver(
+unsigned int lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver(
void *implementor, const char *method_name,
lldb_private::SymbolContext *sym_ctx) {
PyErr_Cleaner py_err_cleaner(false);
@@ -410,7 +442,7 @@ unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver(
if (!pfunc.IsAllocated())
return 0;
- PythonObject result = sym_ctx ? pfunc(ToSWIGWrapper(*sym_ctx)) : pfunc();
+ PythonObject result = sym_ctx ? pfunc(SWIGBridge::ToSWIGWrapper(*sym_ctx)) : pfunc();
if (PyErr_Occurred()) {
PyErr_Print();
@@ -439,7 +471,7 @@ unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver(
return ret_val;
}
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook(
+PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopHook(
lldb::TargetSP target_sp, const char *python_class_name,
const char *session_dictionary_name, const StructuredDataImpl &args_impl,
Status &error) {
@@ -466,7 +498,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook(
}
PythonObject result =
- pfunc(ToSWIGWrapper(target_sp), ToSWIGWrapper(args_impl), dict);
+ pfunc(SWIGBridge::ToSWIGWrapper(target_sp), SWIGBridge::ToSWIGWrapper(args_impl), dict);
if (result.IsAllocated()) {
// Check that the handle_stop callback is defined:
@@ -497,7 +529,7 @@ PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook(
return PythonObject();
}
-bool lldb_private::LLDBSwigPythonStopHookCallHandleStop(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonStopHookCallHandleStop(
void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp,
lldb::StreamSP stream) {
// handle_stop will return a bool with the meaning "should_stop"...
@@ -513,9 +545,9 @@ bool lldb_private::LLDBSwigPythonStopHookCallHandleStop(
auto *sb_stream = new lldb::SBStream();
PythonObject sb_stream_arg =
- ToSWIGWrapper(std::unique_ptr<lldb::SBStream>(sb_stream));
+ SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStream>(sb_stream));
PythonObject result =
- pfunc(ToSWIGWrapper(std::move(exc_ctx_sp)), sb_stream_arg);
+ pfunc(SWIGBridge::ToSWIGWrapper(std::move(exc_ctx_sp)), sb_stream_arg);
if (PyErr_Occurred()) {
stream->PutCString("Python error occurred handling stop-hook.");
@@ -559,7 +591,7 @@ static PyObject *LLDBSwigPython_CallOptionalMember(
return result.release();
}
-size_t lldb_private::LLDBSwigPython_CalculateNumChildren(PyObject * implementor,
+size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren(PyObject * implementor,
uint32_t max) {
PythonObject self(PyRefType::Borrowed, implementor);
auto pfunc = self.ResolveName<PythonCallable>("num_children");
@@ -592,7 +624,7 @@ size_t lldb_private::LLDBSwigPython_CalculateNumChildren(PyObject * implementor,
return ret_val;
}
-PyObject *lldb_private::LLDBSwigPython_GetChildAtIndex(PyObject * implementor,
+PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex(PyObject * implementor,
uint32_t idx) {
PyErr_Cleaner py_err_cleaner(true);
@@ -618,7 +650,7 @@ PyObject *lldb_private::LLDBSwigPython_GetChildAtIndex(PyObject * implementor,
return result.release();
}
-int lldb_private::LLDBSwigPython_GetIndexOfChildWithName(
+int lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(
PyObject * implementor, const char *child_name) {
PyErr_Cleaner py_err_cleaner(true);
@@ -644,7 +676,7 @@ int lldb_private::LLDBSwigPython_GetIndexOfChildWithName(
return UINT32_MAX;
}
-bool lldb_private::LLDBSwigPython_UpdateSynthProviderInstance(PyObject *
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_UpdateSynthProviderInstance(PyObject *
implementor) {
bool ret_val = false;
@@ -661,7 +693,7 @@ bool lldb_private::LLDBSwigPython_UpdateSynthProviderInstance(PyObject *
return ret_val;
}
-bool lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
PyObject * implementor) {
bool ret_val = false;
@@ -678,7 +710,7 @@ bool lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
return ret_val;
}
-PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance(
+PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(
PyObject * implementor) {
PyObject *ret_val = nullptr;
@@ -704,7 +736,7 @@ PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance(
return ret_val;
}
-void *lldb_private::LLDBSWIGPython_CastPyObjectToSBData(PyObject * data) {
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBData(PyObject * data) {
lldb::SBData *sb_ptr = nullptr;
int valid_cast =
@@ -716,7 +748,43 @@ void *lldb_private::LLDBSWIGPython_CastPyObjectToSBData(PyObject * data) {
return sb_ptr;
}
-void *lldb_private::LLDBSWIGPython_CastPyObjectToSBError(PyObject * data) {
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject * data) {
+ lldb::SBBreakpoint *sb_ptr = nullptr;
+
+ int valid_cast =
+ SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBBreakpoint, 0);
+
+ if (valid_cast == -1)
+ return NULL;
+
+ return sb_ptr;
+}
+
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject * data) {
+ lldb::SBAttachInfo *sb_ptr = nullptr;
+
+ int valid_cast =
+ SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBAttachInfo, 0);
+
+ if (valid_cast == -1)
+ return NULL;
+
+ return sb_ptr;
+}
+
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject * data) {
+ lldb::SBLaunchInfo *sb_ptr = nullptr;
+
+ int valid_cast =
+ SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBLaunchInfo, 0);
+
+ if (valid_cast == -1)
+ return NULL;
+
+ return sb_ptr;
+}
+
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBError(PyObject * data) {
lldb::SBError *sb_ptr = nullptr;
int valid_cast =
@@ -728,7 +796,7 @@ void *lldb_private::LLDBSWIGPython_CastPyObjectToSBError(PyObject * data) {
return sb_ptr;
}
-void *lldb_private::LLDBSWIGPython_CastPyObjectToSBValue(PyObject * data) {
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue(PyObject * data) {
lldb::SBValue *sb_ptr = NULL;
int valid_cast =
@@ -740,7 +808,7 @@ void *lldb_private::LLDBSWIGPython_CastPyObjectToSBValue(PyObject * data) {
return sb_ptr;
}
-void *lldb_private::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *
data) {
lldb::SBMemoryRegionInfo *sb_ptr = NULL;
@@ -753,7 +821,7 @@ void *lldb_private::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *
return sb_ptr;
}
-bool lldb_private::LLDBSwigPythonCallCommand(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
const char *python_function_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger, const char *args,
lldb_private::CommandReturnObject &cmd_retobj,
@@ -773,19 +841,19 @@ bool lldb_private::LLDBSwigPythonCallCommand(
llvm::consumeError(argc.takeError());
return false;
}
- PythonObject debugger_arg = ToSWIGWrapper(std::move(debugger));
- auto cmd_retobj_arg = ToSWIGWrapper(cmd_retobj);
+ PythonObject debugger_arg = SWIGBridge::ToSWIGWrapper(std::move(debugger));
+ auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);
if (argc.get().max_positional_args < 5u)
pfunc(debugger_arg, PythonString(args), cmd_retobj_arg.obj(), dict);
else
pfunc(debugger_arg, PythonString(args),
- ToSWIGWrapper(std::move(exe_ctx_ref_sp)), cmd_retobj_arg.obj(), dict);
+ SWIGBridge::ToSWIGWrapper(std::move(exe_ctx_ref_sp)), cmd_retobj_arg.obj(), dict);
return true;
}
-bool lldb_private::LLDBSwigPythonCallCommandObject(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
lldb_private::CommandReturnObject &cmd_retobj,
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
@@ -798,15 +866,15 @@ bool lldb_private::LLDBSwigPythonCallCommandObject(
if (!pfunc.IsAllocated())
return false;
- auto cmd_retobj_arg = ToSWIGWrapper(cmd_retobj);
+ auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);
- pfunc(ToSWIGWrapper(std::move(debugger)), PythonString(args),
- ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
+ pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
+ SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
return true;
}
-PythonObject lldb_private::LLDBSWIGPythonCreateOSPlugin(
+PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
const char *python_class_name, const char *session_dictionary_name,
const lldb::ProcessSP &process_sp) {
if (python_class_name == NULL || python_class_name[0] == '\0' ||
@@ -823,10 +891,10 @@ PythonObject lldb_private::LLDBSWIGPythonCreateOSPlugin(
if (!pfunc.IsAllocated())
return PythonObject();
- return pfunc(ToSWIGWrapper(process_sp));
+ return pfunc(SWIGBridge::ToSWIGWrapper(process_sp));
}
-PythonObject lldb_private::LLDBSWIGPython_CreateFrameRecognizer(
+PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer(
const char *python_class_name, const char *session_dictionary_name) {
if (python_class_name == NULL || python_class_name[0] == '\0' ||
!session_dictionary_name)
@@ -845,11 +913,11 @@ PythonObject lldb_private::LLDBSWIGPython_CreateFrameRecognizer(
return pfunc();
}
-PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments(
+PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
static char callee_name[] = "get_recognized_arguments";
- PythonObject arg = ToSWIGWrapper(frame_sp);
+ PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
PythonString str(callee_name);
PyObject *result =
@@ -857,7 +925,7 @@ PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments(
return result;
}
-void *lldb_private::LLDBSWIGPython_GetDynamicSetting(
+void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
void *module, const char *setting, const lldb::TargetSP &target_sp) {
if (!module || !setting)
Py_RETURN_NONE;
@@ -869,12 +937,12 @@ void *lldb_private::LLDBSWIGPython_GetDynamicSetting(
if (!pfunc.IsAllocated())
Py_RETURN_NONE;
- auto result = pfunc(ToSWIGWrapper(target_sp), PythonString(setting));
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(target_sp), PythonString(setting));
return result.release();
}
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
+bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess(
const char *python_function_name, const char *session_dictionary_name,
const lldb::ProcessSP &process, std::string &output) {
@@ -892,14 +960,14 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
if (!pfunc.IsAllocated())
return false;
- auto result = pfunc(ToSWIGWrapper(process), dict);
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(process), dict);
output = result.Str().GetString().str();
return true;
}
-std::optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
+std::optional<std::string> lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread(
const char *python_function_name, const char *session_dictionary_name,
lldb::ThreadSP thread) {
if (python_function_name == NULL || python_function_name[0] == '\0' ||
@@ -916,12 +984,12 @@ std::optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
if (!pfunc.IsAllocated())
return std::nullopt;
- auto result = pfunc(ToSWIGWrapper(std::move(thread)), dict);
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(std::move(thread)), dict);
return result.Str().GetString().str();
}
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
+bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget(
const char *python_function_name, const char *session_dictionary_name,
const lldb::TargetSP &target, std::string &output) {
@@ -939,14 +1007,14 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
if (!pfunc.IsAllocated())
return false;
- auto result = pfunc(ToSWIGWrapper(target), dict);
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(target), dict);
output = result.Str().GetString().str();
return true;
}
-std::optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
+std::optional<std::string> lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame(
const char *python_function_name, const char *session_dictionary_name,
lldb::StackFrameSP frame) {
if (python_function_name == NULL || python_function_name[0] == '\0' ||
@@ -963,12 +1031,12 @@ std::optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
if (!pfunc.IsAllocated())
return std::nullopt;
- auto result = pfunc(ToSWIGWrapper(std::move(frame)), dict);
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(std::move(frame)), dict);
return result.Str().GetString().str();
}
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
+bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue(
const char *python_function_name, const char *session_dictionary_name,
const lldb::ValueObjectSP &value, std::string &output) {
@@ -986,14 +1054,14 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
if (!pfunc.IsAllocated())
return false;
- auto result = pfunc(ToSWIGWrapper(value), dict);
+ auto result = pfunc(SWIGBridge::ToSWIGWrapper(value), dict);
output = result.Str().GetString().str();
return true;
}
-bool lldb_private::LLDBSwigPythonCallModuleInit(
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit(
const char *python_module_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger) {
std::string python_function_name_string = python_module_name;
@@ -1012,12 +1080,12 @@ bool lldb_private::LLDBSwigPythonCallModuleInit(
if (!pfunc.IsAllocated())
return true;
- pfunc(ToSWIGWrapper(std::move(debugger)), dict);
+ pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), dict);
return true;
}
-lldb::ValueObjectSP lldb_private::LLDBSWIGPython_GetValueObjectSPFromSBValue(
+lldb::ValueObjectSP lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(
void *data) {
lldb::ValueObjectSP valobj_sp;
if (data) {
@@ -1038,4 +1106,66 @@ static void LLDBSwigPythonCallPythonLogOutputCallback(const char *str,
SWIG_PYTHON_THREAD_END_BLOCK;
}
}
+
+// For DebuggerTerminateCallback functions
+static void LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t debugger_id,
+ void *baton) {
+ if (baton != Py_None) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyObject *result = PyObject_CallFunction(
+ reinterpret_cast<PyObject *>(baton), const_cast<char *>("l"), debugger_id);
+ Py_XDECREF(result);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+}
+
+static SBError LLDBSwigPythonCallLocateModuleCallback(
+ void *callback_baton, const SBModuleSpec &module_spec_sb,
+ SBFileSpec &module_file_spec_sb, SBFileSpec &symbol_file_spec_sb) {
+ SWIG_Python_Thread_Block swig_thread_block;
+
+ PyErr_Cleaner py_err_cleaner(true);
+ PythonObject module_spec_arg = SWIGBridge::ToSWIGWrapper(
+ std::make_unique<SBModuleSpec>(module_spec_sb));
+ PythonObject module_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+ std::make_unique<SBFileSpec>(module_file_spec_sb));
+ PythonObject symbol_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+ std::make_unique<SBFileSpec>(symbol_file_spec_sb));
+
+ PythonCallable callable =
+ Retain<PythonCallable>(reinterpret_cast<PyObject *>(callback_baton));
+ if (!callable.IsValid()) {
+ return SBError("The callback callable is not valid.");
+ }
+
+ PythonObject result = callable(module_spec_arg, module_file_spec_arg,
+ symbol_file_spec_arg);
+
+ if (!result.IsAllocated())
+ return SBError("No result.");
+ lldb::SBError *sb_error_ptr = nullptr;
+ if (SWIG_ConvertPtr(result.get(), (void **)&sb_error_ptr,
+ SWIGTYPE_p_lldb__SBError, 0) == -1) {
+ return SBError("Result is not SBError.");
+ }
+
+ if (sb_error_ptr->Success()) {
+ lldb::SBFileSpec *sb_module_file_spec_ptr = nullptr;
+ if (SWIG_ConvertPtr(module_file_spec_arg.get(),
+ (void **)&sb_module_file_spec_ptr,
+ SWIGTYPE_p_lldb__SBFileSpec, 0) == -1)
+ return SBError("module_file_spec is not SBFileSpec.");
+
+ lldb::SBFileSpec *sb_symbol_file_spec_ptr = nullptr;
+ if (SWIG_ConvertPtr(symbol_file_spec_arg.get(),
+ (void **)&sb_symbol_file_spec_ptr,
+ SWIGTYPE_p_lldb__SBFileSpec, 0) == -1)
+ return SBError("symbol_file_spec is not SBFileSpec.");
+
+ module_file_spec_sb = *sb_module_file_spec_ptr;
+ symbol_file_spec_sb = *sb_symbol_file_spec_ptr;
+ }
+
+ return *sb_error_ptr;
+}
%}