diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -5,117 +5,117 @@ return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)}; } -PythonObject ToSWIGWrapper(std::unique_ptr value_sb) { +PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr value_sb) { return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue); } -PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp) { - return ToSWIGWrapper(std::make_unique(std::move(value_sp))); +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ValueObjectSP value_sp) { + return ToSWIGWrapper(std::unique_ptr(new lldb::SBValue(value_sp))); } -PythonObject ToSWIGWrapper(lldb::TargetSP target_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::TargetSP target_sp) { return ToSWIGHelper(new lldb::SBTarget(std::move(target_sp)), SWIGTYPE_p_lldb__SBTarget); } -PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP process_sp) { return ToSWIGHelper(new lldb::SBProcess(std::move(process_sp)), SWIGTYPE_p_lldb__SBProcess); } -PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) { return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)), SWIGTYPE_p_lldb__SBThreadPlan); } -PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) { return ToSWIGHelper(new lldb::SBBreakpoint(std::move(breakpoint_sp)), SWIGTYPE_p_lldb__SBBreakpoint); } -PythonObject ToSWIGWrapper(const Status& status) { +PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) { return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError); } -PythonObject ToSWIGWrapper(std::unique_ptr stream_sb) { +PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr stream_sb) { return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream); } -PythonObject ToSWIGWrapper(std::unique_ptr data_sb) { +PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr data_sb) { return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData); } -PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl) { - return ToSWIGWrapper(std::make_unique(data_impl)); +PythonObject SWIGBridge::ToSWIGWrapper(const StructuredDataImpl &data_impl) { + return ToSWIGWrapper(std::unique_ptr(new lldb::SBStructuredData(data_impl))); } -PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadSP thread_sp) { return ToSWIGHelper(new lldb::SBThread(std::move(thread_sp)), SWIGTYPE_p_lldb__SBThread); } -PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::StackFrameSP frame_sp) { return ToSWIGHelper(new lldb::SBFrame(std::move(frame_sp)), SWIGTYPE_p_lldb__SBFrame); } -PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::DebuggerSP debugger_sp) { return ToSWIGHelper(new lldb::SBDebugger(std::move(debugger_sp)), SWIGTYPE_p_lldb__SBDebugger); } -PythonObject ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) { return ToSWIGHelper(new lldb::SBWatchpoint(std::move(watchpoint_sp)), SWIGTYPE_p_lldb__SBWatchpoint); } -PythonObject ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) { return ToSWIGHelper(new lldb::SBBreakpointLocation(std::move(bp_loc_sp)), SWIGTYPE_p_lldb__SBBreakpointLocation); } -PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) { return ToSWIGHelper(new lldb::SBExecutionContext(std::move(ctx_sp)), SWIGTYPE_p_lldb__SBExecutionContext); } -PythonObject ToSWIGWrapper(lldb::TypeImplSP type_impl_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::TypeImplSP type_impl_sp) { return ToSWIGHelper(new lldb::SBType(type_impl_sp), SWIGTYPE_p_lldb__SBType); } -PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options) { +PythonObject SWIGBridge::ToSWIGWrapper(const TypeSummaryOptions &summary_options) { return ToSWIGHelper(new lldb::SBTypeSummaryOptions(summary_options), SWIGTYPE_p_lldb__SBTypeSummaryOptions); } -PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx) { +PythonObject SWIGBridge::ToSWIGWrapper(const SymbolContext &sym_ctx) { return ToSWIGHelper(new lldb::SBSymbolContext(sym_ctx), SWIGTYPE_p_lldb__SBSymbolContext); } -PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) { return ToSWIGHelper(new lldb::ProcessLaunchInfoSP(std::move(launch_info_sp)), SWIGTYPE_p_lldb__SBLaunchInfo); } - PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) { + PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) { return ToSWIGHelper(new lldb::ProcessAttachInfoSP(std::move(attach_info_sp)), SWIGTYPE_p_lldb__SBAttachInfo); } -PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_sp) { +PythonObject SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP data_sp) { return ToSWIGHelper(new lldb::DataExtractorSP(std::move(data_sp)), SWIGTYPE_p_lldb__SBData); } ScopedPythonObject -ToSWIGWrapper(CommandReturnObject &cmd_retobj) { +SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) { return ScopedPythonObject( new lldb::SBCommandReturnObject(cmd_retobj), SWIGTYPE_p_lldb__SBCommandReturnObject); } -ScopedPythonObject ToSWIGWrapper(Event *event) { +ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) { return ScopedPythonObject(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent); } diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -16,7 +16,7 @@ bool m_print; }; -llvm::Expected lldb_private::LLDBSwigPythonBreakpointCallbackFunction( +llvm::Expected 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 @@ 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 @@ // 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 @@ 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 @@ // 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 @@ 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 @@ 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 @@ if (!pfunc.IsAllocated()) return PythonObject(); - auto sb_value = std::make_unique(valobj_sp); + auto sb_value = std::unique_ptr(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 @@ 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 @@ 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 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 @@ 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 @@ return PythonObject(); } - PythonObject tp_arg = ToSWIGWrapper(thread_plan_sp); + PythonObject tp_arg = SWIGBridge::ToSWIGWrapper(thread_plan_sp); llvm::Expected arg_info = pfunc.GetArgInfo(); if (!arg_info) { @@ -307,7 +307,7 @@ } PythonObject result = {}; - auto args_sb = std::make_unique(args_impl); + auto args_sb = std::unique_ptr(new lldb::SBStructuredData(args_impl)); if (arg_info.get().max_positional_args == 2) { if (args_sb->IsValid()) { error_string.assign( @@ -316,7 +316,7 @@ } 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 @@ 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 @@ PythonObject result; if (event != nullptr) { - ScopedPythonObject event_arg = ToSWIGWrapper(event); + ScopedPythonObject event_arg = SWIGBridge::ToSWIGWrapper(event); result = pfunc(event_arg.obj()); } else result = pfunc(); @@ -367,7 +367,7 @@ return false; } -bool lldb_private::LLDBSWIGPythonCallThreadPlan( +bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( void *implementor, const char *method_name, lldb_private::Stream *stream, bool &got_error) { got_error = false; @@ -381,7 +381,7 @@ auto *sb_stream = new lldb::SBStream(); PythonObject sb_stream_arg = - ToSWIGWrapper(std::unique_ptr(sb_stream)); + SWIGBridge::ToSWIGWrapper(std::unique_ptr(sb_stream)); PythonObject result; result = pfunc(sb_stream_arg); @@ -399,7 +399,7 @@ } -PythonObject lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( +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) { @@ -419,7 +419,7 @@ 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. @@ -432,7 +432,7 @@ 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); @@ -442,7 +442,7 @@ 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(); @@ -471,7 +471,7 @@ 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) { @@ -498,7 +498,7 @@ } 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: @@ -529,7 +529,7 @@ 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"... @@ -545,9 +545,9 @@ auto *sb_stream = new lldb::SBStream(); PythonObject sb_stream_arg = - ToSWIGWrapper(std::unique_ptr(sb_stream)); + SWIGBridge::ToSWIGWrapper(std::unique_ptr(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."); @@ -591,7 +591,7 @@ 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("num_children"); @@ -624,7 +624,7 @@ 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); @@ -650,7 +650,7 @@ 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); @@ -676,7 +676,7 @@ return UINT32_MAX; } -bool lldb_private::LLDBSwigPython_UpdateSynthProviderInstance(PyObject * +bool lldb_private::python::SWIGBridge::LLDBSwigPython_UpdateSynthProviderInstance(PyObject * implementor) { bool ret_val = false; @@ -693,7 +693,7 @@ return ret_val; } -bool lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance( +bool lldb_private::python::SWIGBridge::LLDBSwigPython_MightHaveChildrenSynthProviderInstance( PyObject * implementor) { bool ret_val = false; @@ -710,7 +710,7 @@ return ret_val; } -PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance( +PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance( PyObject * implementor) { PyObject *ret_val = nullptr; @@ -821,7 +821,7 @@ 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, @@ -841,19 +841,19 @@ 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) { @@ -866,15 +866,15 @@ 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' || @@ -891,10 +891,10 @@ 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) @@ -913,11 +913,11 @@ 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 = @@ -925,7 +925,7 @@ 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; @@ -937,12 +937,12 @@ 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) { @@ -960,14 +960,14 @@ 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 lldb_private::LLDBSWIGPythonRunScriptKeywordThread( +std::optional 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' || @@ -984,12 +984,12 @@ 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) { @@ -1007,14 +1007,14 @@ 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 lldb_private::LLDBSWIGPythonRunScriptKeywordFrame( +std::optional 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' || @@ -1031,12 +1031,12 @@ 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) { @@ -1054,14 +1054,14 @@ 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; @@ -1080,12 +1080,12 @@ 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) { diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -15,7 +15,10 @@ namespace lldb_private { class ScriptInterpreter; +namespace python { +class SWIGBridge; } +} // namespace lldb_private namespace lldb { @@ -26,10 +29,6 @@ SBBreakpoint(const lldb::SBBreakpoint &rhs); -#ifndef SWIG - SBBreakpoint(const lldb::BreakpointSP &bp_sp); -#endif - ~SBBreakpoint(); const lldb::SBBreakpoint &operator=(const lldb::SBBreakpoint &rhs); @@ -160,6 +159,9 @@ friend class SBTarget; friend class lldb_private::ScriptInterpreter; + friend class lldb_private::python::SWIGBridge; + + SBBreakpoint(const lldb::BreakpointSP &bp_sp); lldb::BreakpointSP GetSP() const; diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h --- a/lldb/include/lldb/API/SBBreakpointLocation.h +++ b/lldb/include/lldb/API/SBBreakpointLocation.h @@ -12,6 +12,12 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBDefines.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBBreakpointLocation { @@ -90,9 +96,9 @@ SBBreakpoint GetBreakpoint(); -#ifndef SWIG +protected: + friend class lldb_private::python::SWIGBridge; SBBreakpointLocation(const lldb::BreakpointLocationSP &break_loc_sp); -#endif private: friend class SBBreakpoint; diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -14,6 +14,10 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" +namespace lldb_private { +class CommandPluginInterfaceImplementation; +} + namespace lldb { class SBCommandInterpreter { @@ -263,9 +267,6 @@ bool SetCommandOverrideCallback(const char *command_name, lldb::CommandOverrideCallback callback, void *baton); - SBCommandInterpreter( - lldb_private::CommandInterpreter *interpreter_ptr = - nullptr); // Access using SBDebugger::GetCommandInterpreter(); #endif /// Return true if the command interpreter is the active IO handler. @@ -314,6 +315,11 @@ void ResolveCommand(const char *command_line, SBCommandReturnObject &result); protected: + friend class lldb_private::CommandPluginInterfaceImplementation; + + SBCommandInterpreter( + lldb_private::CommandInterpreter *interpreter_ptr = + nullptr); // Access using SBDebugger::GetCommandInterpreter(); lldb_private::CommandInterpreter &ref(); lldb_private::CommandInterpreter *get(); diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h --- a/lldb/include/lldb/API/SBCommandReturnObject.h +++ b/lldb/include/lldb/API/SBCommandReturnObject.h @@ -16,8 +16,12 @@ #include "lldb/API/SBDefines.h" namespace lldb_private { +class CommandPluginInterfaceImplementation; class SBCommandReturnObjectImpl; +namespace python { +class SWIGBridge; } +} // namespace lldb_private namespace lldb { @@ -25,10 +29,6 @@ public: SBCommandReturnObject(); -#ifndef SWIG - SBCommandReturnObject(lldb_private::CommandReturnObject &ref); -#endif - // rvalue ctor+assignment are incompatible with Reproducers. SBCommandReturnObject(const lldb::SBCommandReturnObject &rhs); @@ -119,6 +119,11 @@ friend class SBCommandInterpreter; friend class SBOptions; + friend class lldb_private::CommandPluginInterfaceImplementation; + friend class lldb_private::python::SWIGBridge; + + SBCommandReturnObject(lldb_private::CommandReturnObject &ref); + lldb_private::CommandReturnObject *operator->() const; lldb_private::CommandReturnObject *get() const; diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -14,6 +14,13 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBPlatform.h" +namespace lldb_private { +class CommandPluginInterfaceImplementation; +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { #ifndef SWIG @@ -45,10 +52,6 @@ SBDebugger(const lldb::SBDebugger &rhs); -#ifndef SWIG - SBDebugger(const lldb::DebuggerSP &debugger_sp); -#endif - ~SBDebugger(); static const char *GetBroadcasterClass(); @@ -464,6 +467,12 @@ SBTrace LoadTraceFromFile(SBError &error, const SBFileSpec &trace_description_file); +protected: + friend class lldb_private::CommandPluginInterfaceImplementation; + friend class lldb_private::python::SWIGBridge; + + SBDebugger(const lldb::DebuggerSP &debugger_sp); + private: friend class SBCommandInterpreter; friend class SBInputReader; diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h --- a/lldb/include/lldb/API/SBError.h +++ b/lldb/include/lldb/API/SBError.h @@ -13,6 +13,9 @@ namespace lldb_private { class ScriptInterpreter; +namespace python { +class SWIGBridge; +} } // namespace lldb_private namespace lldb { @@ -25,10 +28,6 @@ SBError(const char *message); -#ifndef SWIG - SBError(const lldb_private::Status &error); -#endif - ~SBError(); const SBError &operator=(const lldb::SBError &rhs); @@ -94,6 +93,9 @@ friend class SBWatchpoint; friend class lldb_private::ScriptInterpreter; + friend class lldb_private::python::SWIGBridge; + + SBError(const lldb_private::Status &error); lldb_private::Status *get(); diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h --- a/lldb/include/lldb/API/SBEvent.h +++ b/lldb/include/lldb/API/SBEvent.h @@ -14,6 +14,12 @@ #include #include +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBBroadcaster; @@ -27,12 +33,6 @@ // Make an event that contains a C string. SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len); -#ifndef SWIG - SBEvent(lldb::EventSP &event_sp); - - SBEvent(lldb_private::Event *event_sp); -#endif - ~SBEvent(); const SBEvent &operator=(const lldb::SBEvent &rhs); @@ -73,6 +73,12 @@ friend class SBThread; friend class SBWatchpoint; + friend class lldb_private::python::SWIGBridge; + + SBEvent(lldb::EventSP &event_sp); + + SBEvent(lldb_private::Event *event_sp); + lldb::EventSP &GetSP() const; void reset(lldb::EventSP &event_sp); diff --git a/lldb/include/lldb/API/SBExecutionContext.h b/lldb/include/lldb/API/SBExecutionContext.h --- a/lldb/include/lldb/API/SBExecutionContext.h +++ b/lldb/include/lldb/API/SBExecutionContext.h @@ -15,6 +15,12 @@ #include #include +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBExecutionContext { @@ -25,10 +31,6 @@ SBExecutionContext(const lldb::SBExecutionContext &rhs); -#ifndef SWIG - SBExecutionContext(lldb::ExecutionContextRefSP exe_ctx_ref_sp); -#endif - SBExecutionContext(const lldb::SBTarget &target); SBExecutionContext(const lldb::SBProcess &process); @@ -52,8 +54,12 @@ SBFrame GetFrame() const; protected: + friend class lldb_private::python::SWIGBridge; + lldb_private::ExecutionContextRef *get() const; + SBExecutionContext(lldb::ExecutionContextRefSP exe_ctx_ref_sp); + private: mutable lldb::ExecutionContextRefSP m_exe_ctx_sp; }; diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -12,6 +12,12 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBValueList.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBFrame { @@ -184,10 +190,6 @@ bool GetDescription(lldb::SBStream &description); -#ifndef SWIG - SBFrame(const lldb::StackFrameSP &lldb_object_sp); -#endif - protected: friend class SBBlock; friend class SBExecutionContext; @@ -195,6 +197,10 @@ friend class SBThread; friend class SBValue; + friend class lldb_private::python::SWIGBridge; + + SBFrame(const lldb::StackFrameSP &lldb_object_sp); + lldb::StackFrameSP GetFrameSP() const; void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -16,6 +16,12 @@ #include "lldb/API/SBTarget.h" #include +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBEvent; @@ -36,10 +42,6 @@ const lldb::SBProcess &operator=(const lldb::SBProcess &rhs); -#ifndef SWIG - SBProcess(const lldb::ProcessSP &process_sp); -#endif - ~SBProcess(); static const char *GetBroadcasterClassName(); @@ -440,6 +442,7 @@ protected: friend class SBAddress; friend class SBBreakpoint; + friend class SBBreakpointCallbackBaton; friend class SBBreakpointLocation; friend class SBCommandInterpreter; friend class SBDebugger; @@ -451,6 +454,10 @@ friend class SBValue; friend class lldb_private::QueueImpl; + friend class lldb_private::python::SWIGBridge; + + SBProcess(const lldb::ProcessSP &process_sp); + lldb::ProcessSP GetSP() const; void SetSP(const lldb::ProcessSP &process_sp); diff --git a/lldb/include/lldb/API/SBQueue.h b/lldb/include/lldb/API/SBQueue.h --- a/lldb/include/lldb/API/SBQueue.h +++ b/lldb/include/lldb/API/SBQueue.h @@ -20,8 +20,6 @@ public: SBQueue(); - SBQueue(const QueueSP &queue_sp); - SBQueue(const SBQueue &rhs); const SBQueue &operator=(const lldb::SBQueue &rhs); @@ -58,6 +56,8 @@ friend class SBProcess; friend class SBThread; + SBQueue(const QueueSP &queue_sp); + void SetQueue(const lldb::QueueSP &queue_sp); private: diff --git a/lldb/include/lldb/API/SBQueueItem.h b/lldb/include/lldb/API/SBQueueItem.h --- a/lldb/include/lldb/API/SBQueueItem.h +++ b/lldb/include/lldb/API/SBQueueItem.h @@ -12,14 +12,16 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBDefines.h" +namespace lldb_private { +class QueueImpl; +} + namespace lldb { class LLDB_API SBQueueItem { public: SBQueueItem(); - SBQueueItem(const lldb::QueueItemSP &queue_item_sp); - ~SBQueueItem(); explicit operator bool() const; @@ -36,10 +38,15 @@ void SetAddress(lldb::SBAddress addr); - void SetQueueItem(const lldb::QueueItemSP &queue_item_sp); - SBThread GetExtendedBacktraceThread(const char *type); +protected: + friend class lldb_private::QueueImpl; + + SBQueueItem(const lldb::QueueItemSP &queue_item_sp); + + void SetQueueItem(const lldb::QueueItemSP &queue_item_sp); + private: lldb::QueueItemSP m_queue_item_sp; }; diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h --- a/lldb/include/lldb/API/SBStructuredData.h +++ b/lldb/include/lldb/API/SBStructuredData.h @@ -12,6 +12,12 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBModule.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBStructuredData { @@ -20,12 +26,6 @@ SBStructuredData(const lldb::SBStructuredData &rhs); - SBStructuredData(const lldb::EventSP &event_sp); - -#ifndef SWIG - SBStructuredData(const lldb_private::StructuredDataImpl &impl); -#endif - ~SBStructuredData(); lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs); @@ -103,6 +103,11 @@ friend class SBBreakpointLocation; friend class SBBreakpointName; friend class SBTrace; + friend class lldb_private::python::SWIGBridge; + + SBStructuredData(const lldb_private::StructuredDataImpl &impl); + + SBStructuredData(const lldb::EventSP &event_sp); StructuredDataImplUP m_impl_up; }; diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h --- a/lldb/include/lldb/API/SBSymbolContext.h +++ b/lldb/include/lldb/API/SBSymbolContext.h @@ -17,6 +17,12 @@ #include "lldb/API/SBModule.h" #include "lldb/API/SBSymbol.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBSymbolContext { @@ -25,10 +31,6 @@ SBSymbolContext(const lldb::SBSymbolContext &rhs); -#ifndef SWIG - SBSymbolContext(const lldb_private::SymbolContext &sc_ptr); -#endif - ~SBSymbolContext(); explicit operator bool() const; @@ -64,6 +66,10 @@ friend class SBTarget; friend class SBSymbolContextList; + friend class lldb_private::python::SWIGBridge; + + SBSymbolContext(const lldb_private::SymbolContext &sc_ptr); + lldb_private::SymbolContext *operator->() const; lldb_private::SymbolContext &operator*(); diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -22,6 +22,12 @@ #include "lldb/API/SBValue.h" #include "lldb/API/SBWatchpoint.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBPlatform; @@ -42,10 +48,6 @@ SBTarget(const lldb::SBTarget &rhs); -#ifndef SWIG - SBTarget(const lldb::TargetSP &target_sp); -#endif - // Destructor ~SBTarget(); @@ -917,10 +919,12 @@ protected: friend class SBAddress; friend class SBBlock; + friend class SBBreakpoint; friend class SBBreakpointList; friend class SBBreakpointNameImpl; friend class SBDebugger; friend class SBExecutionContext; + friend class SBFrame; friend class SBFunction; friend class SBInstruction; friend class SBModule; @@ -932,9 +936,13 @@ friend class SBValue; friend class SBVariablesOptions; + friend class lldb_private::python::SWIGBridge; + // Constructors are private, use static Target::Create function to create an // instance of this class. + SBTarget(const lldb::TargetSP &target_sp); + lldb::TargetSP GetSP() const; void SetSP(const lldb::TargetSP &target_sp); diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -13,6 +13,12 @@ #include +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBFrame; @@ -33,10 +39,6 @@ SBThread(const lldb::SBThread &thread); -#ifndef SWIG - SBThread(const lldb::ThreadSP &lldb_object_sp); -#endif - ~SBThread(); lldb::SBQueue GetQueue() const; @@ -223,9 +225,14 @@ friend class SBValue; friend class lldb_private::QueueImpl; friend class SBQueueItem; + friend class SBThreadCollection; friend class SBThreadPlan; friend class SBTrace; + friend class lldb_private::python::SWIGBridge; + + SBThread(const lldb::ThreadSP &lldb_object_sp); + void SetThread(const lldb::ThreadSP &lldb_object_sp); SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx, diff --git a/lldb/include/lldb/API/SBThreadPlan.h b/lldb/include/lldb/API/SBThreadPlan.h --- a/lldb/include/lldb/API/SBThreadPlan.h +++ b/lldb/include/lldb/API/SBThreadPlan.h @@ -13,6 +13,12 @@ #include +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBThreadPlan { @@ -22,8 +28,6 @@ SBThreadPlan(const lldb::SBThreadPlan &threadPlan); - SBThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp); - SBThreadPlan(lldb::SBThread &thread, const char *class_name); SBThreadPlan(lldb::SBThread &thread, const char *class_name, @@ -112,6 +116,11 @@ lldb::SBStructuredData &args_data, SBError &error); +protected: + friend class lldb_private::python::SWIGBridge; + + SBThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp); + private: friend class SBBreakpoint; friend class SBBreakpointLocation; diff --git a/lldb/include/lldb/API/SBTrace.h b/lldb/include/lldb/API/SBTrace.h --- a/lldb/include/lldb/API/SBTrace.h +++ b/lldb/include/lldb/API/SBTrace.h @@ -20,10 +20,6 @@ /// Default constructor for an invalid Trace object. SBTrace(); -#ifndef SWIG - SBTrace(const lldb::TraceSP &trace_sp); -#endif - /// See SBDebugger::LoadTraceFromFile. static SBTrace LoadTraceFromFile(SBError &error, SBDebugger &debugger, const SBFileSpec &trace_description_file); @@ -139,6 +135,10 @@ bool IsValid(); protected: + friend class SBTarget; + + SBTrace(const lldb::TraceSP &trace_sp); + lldb::TraceSP m_opaque_sp; /// deprecated lldb::ProcessWP m_opaque_wp; diff --git a/lldb/include/lldb/API/SBTraceCursor.h b/lldb/include/lldb/API/SBTraceCursor.h --- a/lldb/include/lldb/API/SBTraceCursor.h +++ b/lldb/include/lldb/API/SBTraceCursor.h @@ -20,10 +20,6 @@ /// Default constructor for an invalid \a SBTraceCursor object. SBTraceCursor(); - /// Create a cursor that initially points to the end of the trace, i.e. the - /// most recent item. - SBTraceCursor(lldb::TraceCursorSP trace_cursor_sp); - /// Set the direction to use in the \a SBTraceCursor::Next() method. /// /// \param[in] forwards @@ -169,6 +165,12 @@ explicit operator bool() const; protected: + friend class SBTrace; + + /// Create a cursor that initially points to the end of the trace, i.e. the + /// most recent item. + SBTraceCursor(lldb::TraceCursorSP trace_cursor_sp); + lldb::TraceCursorSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -11,6 +11,12 @@ #include "lldb/API/SBDefines.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class SBTypeList; @@ -106,9 +112,6 @@ SBType(); SBType(const lldb::SBType &rhs); -#ifndef SWIG - SBType(const lldb::TypeImplSP &); -#endif ~SBType(); @@ -241,8 +244,11 @@ friend class SBValue; friend class SBWatchpoint; + friend class lldb_private::python::SWIGBridge; + SBType(const lldb_private::CompilerType &); SBType(const lldb::TypeSP &); + SBType(const lldb::TypeImplSP &); }; class SBTypeList { diff --git a/lldb/include/lldb/API/SBTypeSummary.h b/lldb/include/lldb/API/SBTypeSummary.h --- a/lldb/include/lldb/API/SBTypeSummary.h +++ b/lldb/include/lldb/API/SBTypeSummary.h @@ -12,6 +12,12 @@ #include "lldb/API/SBDefines.h" +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBTypeSummaryOptions { public: @@ -19,9 +25,6 @@ SBTypeSummaryOptions(const lldb::SBTypeSummaryOptions &rhs); -#ifndef SWIG - SBTypeSummaryOptions(const lldb_private::TypeSummaryOptions &lldb_object); -#endif ~SBTypeSummaryOptions(); @@ -39,6 +42,11 @@ protected: friend class SBValue; + friend class SBTypeSummary; + + friend class lldb_private::python::SWIGBridge; + + SBTypeSummaryOptions(const lldb_private::TypeSummaryOptions &lldb_object); lldb_private::TypeSummaryOptions *operator->(); diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -16,6 +16,12 @@ class ValueImpl; class ValueLocker; +namespace lldb_private { +namespace python { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBValue { @@ -309,10 +315,6 @@ const SBExpressionOptions &options, const char *name) const; -#ifndef SWIG - SBValue(const lldb::ValueObjectSP &value_sp); -#endif - /// Watch this value if it resides in memory. /// /// Sets a watchpoint on the value. @@ -370,7 +372,19 @@ lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write, SBError &error); -#ifndef SWIG +protected: + friend class SBBlock; + friend class SBFrame; + friend class SBModule; + friend class SBTarget; + friend class SBThread; + friend class SBTypeSummary; + friend class SBValueList; + + friend class lldb_private::python::SWIGBridge; + + SBValue(const lldb::ValueObjectSP &value_sp); + /// Same as the protected version of GetSP that takes a locker, except that we /// make the /// locker locally in the function. Since the Target API mutex is recursive, @@ -383,14 +397,6 @@ /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we /// can cons up, in accordance with the SBValue's settings. lldb::ValueObjectSP GetSP() const; -#endif - -protected: - friend class SBBlock; - friend class SBFrame; - friend class SBTarget; - friend class SBThread; - friend class SBValueList; /// Get the appropriate ValueObjectSP from this SBValue, consulting the /// use_dynamic and use_synthetic options passed in to SetSP when the diff --git a/lldb/include/lldb/API/SBWatchpoint.h b/lldb/include/lldb/API/SBWatchpoint.h --- a/lldb/include/lldb/API/SBWatchpoint.h +++ b/lldb/include/lldb/API/SBWatchpoint.h @@ -12,6 +12,12 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBType.h" +namespace lldb_private { +namespace ptyhon { +class SWIGBridge; +} +} // namespace lldb_private + namespace lldb { class LLDB_API SBWatchpoint { @@ -20,10 +26,6 @@ SBWatchpoint(const lldb::SBWatchpoint &rhs); -#ifndef SWIG - SBWatchpoint(const lldb::WatchpointSP &wp_sp); -#endif - ~SBWatchpoint(); const lldb::SBWatchpoint &operator=(const lldb::SBWatchpoint &rhs); @@ -65,12 +67,6 @@ void Clear(); -#ifndef SWIG - lldb::WatchpointSP GetSP() const; - - void SetSP(const lldb::WatchpointSP &sp); -#endif - static bool EventIsWatchpointEvent(const lldb::SBEvent &event); static lldb::WatchpointEventType @@ -88,6 +84,15 @@ bool IsWatchingWrites(); +protected: + friend class lldb_private::python::SWIGBridge; + + SBWatchpoint(const lldb::WatchpointSP &wp_sp); + + lldb::WatchpointSP GetSP() const; + + void SetSP(const lldb::WatchpointSP &sp); + private: friend class SBTarget; friend class SBValue; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -33,6 +33,7 @@ using namespace lldb; using namespace lldb_private; +namespace lldb_private { class CommandPluginInterfaceImplementation : public CommandObjectParsed { public: CommandPluginInterfaceImplementation(CommandInterpreter &interpreter, @@ -73,13 +74,14 @@ SBCommandReturnObject sb_return(result); SBCommandInterpreter sb_interpreter(&m_interpreter); SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this()); - bool ret = m_backend->DoExecute( - debugger_sb, command.GetArgumentVector(), sb_return); + bool ret = m_backend->DoExecute(debugger_sb, command.GetArgumentVector(), + sb_return); return ret; } std::shared_ptr m_backend; std::optional m_auto_repeat_command; }; +} // namespace lldb_private SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter) : m_opaque_ptr(interpreter) { diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -65,42 +65,6 @@ using namespace lldb; using namespace lldb_private; -static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, - const FileSpec &spec, - Status &error) { - llvm::sys::DynamicLibrary dynlib = - llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); - if (dynlib.isValid()) { - typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); - - lldb::SBDebugger debugger_sb(debugger_sp); - // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) - // function. - // TODO: mangle this differently for your system - on OSX, the first - // underscore needs to be removed and the second one stays - LLDBCommandPluginInit init_func = - (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( - "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); - if (init_func) { - if (init_func(debugger_sb)) - return dynlib; - else - error.SetErrorString("plug-in refused to load " - "(lldb::PluginInitialize(lldb::SBDebugger) " - "returned false)"); - } else { - error.SetErrorString("plug-in is missing the required initialization: " - "lldb::PluginInitialize(lldb::SBDebugger)"); - } - } else { - if (FileSystem::Instance().Exists(spec)) - error.SetErrorString("this file does not represent a loadable dylib"); - else - error.SetErrorString("no such file"); - } - return llvm::sys::DynamicLibrary(); -} - static llvm::ManagedStatic g_debugger_lifetime; SBError SBInputReader::Initialize( @@ -214,6 +178,42 @@ lldb::SBError SBDebugger::InitializeWithErrorHandling() { LLDB_INSTRUMENT(); + auto LoadPlugin = [](const lldb::DebuggerSP &debugger_sp, + const FileSpec &spec, + Status &error) -> llvm::sys::DynamicLibrary { + llvm::sys::DynamicLibrary dynlib = + llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); + if (dynlib.isValid()) { + typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); + + lldb::SBDebugger debugger_sb(debugger_sp); + // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) + // function. + // TODO: mangle this differently for your system - on OSX, the first + // underscore needs to be removed and the second one stays + LLDBCommandPluginInit init_func = + (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( + "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); + if (init_func) { + if (init_func(debugger_sb)) + return dynlib; + else + error.SetErrorString("plug-in refused to load " + "(lldb::PluginInitialize(lldb::SBDebugger) " + "returned false)"); + } else { + error.SetErrorString("plug-in is missing the required initialization: " + "lldb::PluginInitialize(lldb::SBDebugger)"); + } + } else { + if (FileSystem::Instance().Exists(spec)) + error.SetErrorString("this file does not represent a loadable dylib"); + else + error.SetErrorString("no such file"); + } + return llvm::sys::DynamicLibrary(); + }; + SBError error; if (auto e = g_debugger_lifetime->Initialize( std::make_unique(), LoadPlugin)) { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h --- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h @@ -61,187 +61,197 @@ T *m_sb; }; -PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp); -PythonObject ToSWIGWrapper(lldb::TargetSP target_sp); -PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp); -PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp); -PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp); -PythonObject ToSWIGWrapper(const Status &status); -PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl); -PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp); -PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp); -PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp); -PythonObject ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp); -PythonObject ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp); -PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp); -PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options); -PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx); - -PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp); -PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp); -PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_extractor_sp); - -PythonObject ToSWIGWrapper(std::unique_ptr value_sb); -PythonObject ToSWIGWrapper(std::unique_ptr stream_sb); -PythonObject ToSWIGWrapper(std::unique_ptr data_sb); - -python::ScopedPythonObject -ToSWIGWrapper(CommandReturnObject &cmd_retobj); -python::ScopedPythonObject ToSWIGWrapper(Event *event); +class SWIGBridge { +public: + static PythonObject ToSWIGWrapper(std::unique_ptr value_sb); + static PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp); + static PythonObject ToSWIGWrapper(lldb::TargetSP target_sp); + static PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp); + static PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp); + static PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp); + static PythonObject ToSWIGWrapper(const Status &status); + static PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl); + static PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp); + static PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp); + static PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp); + static PythonObject ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp); + static PythonObject ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp); + static PythonObject ToSWIGWrapper(lldb::TypeImplSP type_impl_sp); + static PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp); + static PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options); + static PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx); + + static PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp); + static PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp); + static PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_extractor_sp); + + static PythonObject ToSWIGWrapper(std::unique_ptr stream_sb); + static PythonObject + ToSWIGWrapper(std::unique_ptr data_sb); + + static python::ScopedPythonObject + ToSWIGWrapper(CommandReturnObject &cmd_retobj); + static python::ScopedPythonObject ToSWIGWrapper(Event *event); + // These prototypes are the Pythonic implementations of the required + // callbacks. Although these are scripting-language specific, their definition + // depends on the public API. + + static python::PythonObject LLDBSwigPythonCreateScriptedObject( + const char *python_class_name, const char *session_dictionary_name, + lldb::ExecutionContextRefSP exe_ctx_sp, + const lldb_private::StructuredDataImpl &args_impl, + std::string &error_string); + + static llvm::Expected LLDBSwigPythonBreakpointCallbackFunction( + const char *python_function_name, const char *session_dictionary_name, + const lldb::StackFrameSP &sb_frame, + const lldb::BreakpointLocationSP &sb_bp_loc, + const lldb_private::StructuredDataImpl &args_impl); + + static bool LLDBSwigPythonWatchpointCallbackFunction( + const char *python_function_name, const char *session_dictionary_name, + const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp); + + static bool + LLDBSwigPythonFormatterCallbackFunction(const char *python_function_name, + const char *session_dictionary_name, + lldb::TypeImplSP type_impl_sp); -} // namespace python + static bool 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); -void *LLDBSWIGPython_CastPyObjectToSBData(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data); -void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data); + static python::PythonObject + LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, + const char *session_dictionary_name, + const lldb::ValueObjectSP &valobj_sp); -// These prototypes are the Pythonic implementations of the required callbacks. -// Although these are scripting-language specific, their definition depends on -// the public API. - -python::PythonObject LLDBSwigPythonCreateScriptedObject( - const char *python_class_name, const char *session_dictionary_name, - lldb::ExecutionContextRefSP exe_ctx_sp, - const lldb_private::StructuredDataImpl &args_impl, - std::string &error_string); - -llvm::Expected LLDBSwigPythonBreakpointCallbackFunction( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &sb_frame, - const lldb::BreakpointLocationSP &sb_bp_loc, - const lldb_private::StructuredDataImpl &args_impl); - -bool LLDBSwigPythonWatchpointCallbackFunction( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp); - -bool LLDBSwigPythonFormatterCallbackFunction( - const char *python_function_name, const char *session_dictionary_name, - lldb::TypeImplSP type_impl_sp); - -bool 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); - -python::PythonObject -LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP &valobj_sp); + static python::PythonObject + LLDBSwigPythonCreateCommandObject(const char *python_class_name, + const char *session_dictionary_name, + lldb::DebuggerSP debugger_sp); -python::PythonObject -LLDBSwigPythonCreateCommandObject(const char *python_class_name, - const char *session_dictionary_name, - lldb::DebuggerSP debugger_sp); + static python::PythonObject LLDBSwigPythonCreateScriptedThreadPlan( + const char *python_class_name, const char *session_dictionary_name, + const StructuredDataImpl &args_data, std::string &error_string, + const lldb::ThreadPlanSP &thread_plan_sp); -python::PythonObject LLDBSwigPythonCreateScriptedThreadPlan( - const char *python_class_name, const char *session_dictionary_name, - const StructuredDataImpl &args_data, std::string &error_string, - const lldb::ThreadPlanSP &thread_plan_sp); + static bool LLDBSWIGPythonCallThreadPlan(void *implementor, + const char *method_name, + lldb_private::Event *event_sp, + bool &got_error); -bool LLDBSWIGPythonCallThreadPlan(void *implementor, const char *method_name, - lldb_private::Event *event_sp, - bool &got_error); - -bool LLDBSWIGPythonCallThreadPlan(void *implementor, - const char *method_name, - lldb_private::Stream *stream, - bool &got_error); + static bool LLDBSWIGPythonCallThreadPlan(void *implementor, + const char *method_name, + lldb_private::Stream *stream, + bool &got_error); -python::PythonObject LLDBSwigPythonCreateScriptedBreakpointResolver( - const char *python_class_name, const char *session_dictionary_name, - const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp); + static python::PythonObject LLDBSwigPythonCreateScriptedBreakpointResolver( + const char *python_class_name, const char *session_dictionary_name, + const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp); -unsigned int -LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name, - lldb_private::SymbolContext *sym_ctx); + static unsigned int + LLDBSwigPythonCallBreakpointResolver(void *implementor, + const char *method_name, + lldb_private::SymbolContext *sym_ctx); -python::PythonObject LLDBSwigPythonCreateScriptedStopHook( - lldb::TargetSP target_sp, const char *python_class_name, - const char *session_dictionary_name, const StructuredDataImpl &args, - lldb_private::Status &error); + static python::PythonObject LLDBSwigPythonCreateScriptedStopHook( + lldb::TargetSP target_sp, const char *python_class_name, + const char *session_dictionary_name, const StructuredDataImpl &args, + lldb_private::Status &error); -bool LLDBSwigPythonStopHookCallHandleStop(void *implementor, - lldb::ExecutionContextRefSP exc_ctx, - lldb::StreamSP stream); + static bool + LLDBSwigPythonStopHookCallHandleStop(void *implementor, + lldb::ExecutionContextRefSP exc_ctx, + lldb::StreamSP stream); -size_t LLDBSwigPython_CalculateNumChildren(PyObject *implementor, uint32_t max); + static size_t LLDBSwigPython_CalculateNumChildren(PyObject *implementor, + uint32_t max); -PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor, uint32_t idx); + static PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor, + uint32_t idx); -int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor, - const char *child_name); + static int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor, + const char *child_name); -lldb::ValueObjectSP LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data); + static lldb::ValueObjectSP + LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data); -bool LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor); + static bool LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor); -bool LLDBSwigPython_MightHaveChildrenSynthProviderInstance( - PyObject *implementor); + static bool + LLDBSwigPython_MightHaveChildrenSynthProviderInstance(PyObject *implementor); -PyObject *LLDBSwigPython_GetValueSynthProviderInstance(PyObject *implementor); + static PyObject * + LLDBSwigPython_GetValueSynthProviderInstance(PyObject *implementor); -bool LLDBSwigPythonCallCommand(const char *python_function_name, - const char *session_dictionary_name, - lldb::DebuggerSP debugger, const char *args, - lldb_private::CommandReturnObject &cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); + static bool + LLDBSwigPythonCallCommand(const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP debugger, const char *args, + lldb_private::CommandReturnObject &cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + + static bool + LLDBSwigPythonCallCommandObject(PyObject *implementor, + lldb::DebuggerSP debugger, const char *args, + lldb_private::CommandReturnObject &cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + + static bool LLDBSwigPythonCallModuleInit(const char *python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP debugger); -bool LLDBSwigPythonCallCommandObject( - PyObject *implementor, lldb::DebuggerSP debugger, const char *args, - lldb_private::CommandReturnObject &cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); + static python::PythonObject + LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, + const char *session_dictionary_name, + const lldb::ProcessSP &process_sp); -bool LLDBSwigPythonCallModuleInit(const char *python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP debugger); + static python::PythonObject + LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name, + const char *session_dictionary_name); -python::PythonObject -LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp); + static PyObject * + LLDBSwigPython_GetRecognizedArguments(PyObject *implementor, + const lldb::StackFrameSP &frame_sp); -python::PythonObject -LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name, - const char *session_dictionary_name); + static bool LLDBSWIGPythonRunScriptKeywordProcess( + const char *python_function_name, const char *session_dictionary_name, + const lldb::ProcessSP &process, std::string &output); -PyObject * -LLDBSwigPython_GetRecognizedArguments(PyObject *implementor, - const lldb::StackFrameSP &frame_sp); + static std::optional + LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name, + const char *session_dictionary_name, + lldb::ThreadSP thread); -bool LLDBSWIGPythonRunScriptKeywordProcess(const char *python_function_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process, - std::string &output); + static bool LLDBSWIGPythonRunScriptKeywordTarget( + const char *python_function_name, const char *session_dictionary_name, + const lldb::TargetSP &target, std::string &output); -std::optional -LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name, - const char *session_dictionary_name, - lldb::ThreadSP thread); + static std::optional + LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name, + const char *session_dictionary_name, + lldb::StackFrameSP frame); -bool LLDBSWIGPythonRunScriptKeywordTarget(const char *python_function_name, - const char *session_dictionary_name, - const lldb::TargetSP &target, - std::string &output); + static bool LLDBSWIGPythonRunScriptKeywordValue( + const char *python_function_name, const char *session_dictionary_name, + const lldb::ValueObjectSP &value, std::string &output); -std::optional -LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name, - const char *session_dictionary_name, - lldb::StackFrameSP frame); + static void * + LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting, + const lldb::TargetSP &target_sp); +}; -bool LLDBSWIGPythonRunScriptKeywordValue(const char *python_function_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP &value, - std::string &output); +} // namespace python -void *LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting, - const lldb::TargetSP &target_sp); +void *LLDBSWIGPython_CastPyObjectToSBData(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data); +void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data); } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1463,7 +1463,7 @@ return StructuredData::GenericSP(); Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - PythonObject ret_val = LLDBSWIGPython_CreateFrameRecognizer( + PythonObject ret_val = SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer( class_name, m_dictionary_name.c_str()); return StructuredData::GenericSP( @@ -1488,9 +1488,9 @@ if (!implementor.IsAllocated()) return ValueObjectListSP(); - PythonObject py_return( - PyRefType::Owned, - LLDBSwigPython_GetRecognizedArguments(implementor.get(), frame_sp)); + PythonObject py_return(PyRefType::Owned, + SWIGBridge::LLDBSwigPython_GetRecognizedArguments( + implementor.get(), frame_sp)); // if it fails, print the error but otherwise go on if (PyErr_Occurred()) { @@ -1504,7 +1504,8 @@ PyObject *item = result_list.GetItemAtIndex(i).get(); lldb::SBValue *sb_value_ptr = (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(item); - auto valobj_sp = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr); + auto valobj_sp = + SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr); if (valobj_sp) result->Append(valobj_sp); } @@ -1528,7 +1529,7 @@ return StructuredData::GenericSP(); Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - PythonObject ret_val = LLDBSWIGPythonCreateOSPlugin( + PythonObject ret_val = SWIGBridge::LLDBSWIGPythonCreateOSPlugin( class_name, m_dictionary_name.c_str(), process_sp); return StructuredData::GenericSP( @@ -1689,7 +1690,7 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PythonObject ret_val = LLDBSwigPythonCreateScriptedThreadPlan( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan( class_name, python_interpreter->m_dictionary_name.c_str(), args_data, error_str, thread_plan_sp); if (!ret_val) @@ -1708,7 +1709,7 @@ if (generic) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - explains_stop = LLDBSWIGPythonCallThreadPlan( + explains_stop = SWIGBridge::LLDBSWIGPythonCallThreadPlan( generic->GetValue(), "explains_stop", event, script_error); if (script_error) return true; @@ -1725,7 +1726,7 @@ if (generic) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - should_stop = LLDBSWIGPythonCallThreadPlan( + should_stop = SWIGBridge::LLDBSWIGPythonCallThreadPlan( generic->GetValue(), "should_stop", event, script_error); if (script_error) return true; @@ -1742,8 +1743,8 @@ if (generic) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - is_stale = LLDBSWIGPythonCallThreadPlan(generic->GetValue(), "is_stale", - (Event *) nullptr, script_error); + is_stale = SWIGBridge::LLDBSWIGPythonCallThreadPlan( + generic->GetValue(), "is_stale", (Event *)nullptr, script_error); if (script_error) return true; } @@ -1759,8 +1760,8 @@ if (generic) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - should_step = LLDBSWIGPythonCallThreadPlan( - generic->GetValue(), "should_step", (Event *) nullptr, script_error); + should_step = SWIGBridge::LLDBSWIGPythonCallThreadPlan( + generic->GetValue(), "should_step", (Event *)nullptr, script_error); if (script_error) should_step = true; } @@ -1782,8 +1783,8 @@ } Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - return LLDBSWIGPythonCallThreadPlan(generic->GetValue(), "stop_description", - stream, script_error); + return SWIGBridge::LLDBSWIGPythonCallThreadPlan( + generic->GetValue(), "stop_description", stream, script_error); } @@ -1808,9 +1809,10 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PythonObject ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver( - class_name, python_interpreter->m_dictionary_name.c_str(), args_data, - bkpt_sp); + PythonObject ret_val = + SWIGBridge::LLDBSwigPythonCreateScriptedBreakpointResolver( + class_name, python_interpreter->m_dictionary_name.c_str(), args_data, + bkpt_sp); return StructuredData::GenericSP( new StructuredPythonObject(std::move(ret_val))); @@ -1823,7 +1825,7 @@ if (implementor_sp) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - should_continue = LLDBSwigPythonCallBreakpointResolver( + should_continue = SWIGBridge::LLDBSwigPythonCallBreakpointResolver( implementor_sp->GetValue(), "__callback__", sym_ctx); if (PyErr_Occurred()) { PyErr_Print(); @@ -1840,7 +1842,7 @@ if (implementor_sp) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - depth_as_int = LLDBSwigPythonCallBreakpointResolver( + depth_as_int = SWIGBridge::LLDBSwigPythonCallBreakpointResolver( implementor_sp->GetValue(), "__get_depth__", nullptr); if (PyErr_Occurred()) { PyErr_Print(); @@ -1880,7 +1882,7 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PythonObject ret_val = LLDBSwigPythonCreateScriptedStopHook( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedStopHook( target_sp, class_name, python_interpreter->m_dictionary_name.c_str(), args_data, error); @@ -1900,7 +1902,7 @@ lldb::ExecutionContextRefSP exc_ctx_ref_sp(new ExecutionContextRef(exc_ctx)); - bool ret_val = LLDBSwigPythonStopHookCallHandleStop( + bool ret_val = SWIGBridge::LLDBSwigPythonStopHookCallHandleStop( implementor_sp->GetValue(), exc_ctx_ref_sp, stream_sp); return ret_val; } @@ -1937,7 +1939,7 @@ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); TargetSP target_sp(target->shared_from_this()); - auto setting = (PyObject *)LLDBSWIGPython_GetDynamicSetting( + auto setting = (PyObject *)SWIGBridge::LLDBSWIGPython_GetDynamicSetting( generic->GetValue(), setting_name, target_sp); if (!setting) @@ -1976,7 +1978,7 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PythonObject ret_val = LLDBSwigPythonCreateSyntheticProvider( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateSyntheticProvider( class_name, python_interpreter->m_dictionary_name.c_str(), valobj); return StructuredData::ObjectSP( @@ -1995,7 +1997,7 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PythonObject ret_val = LLDBSwigPythonCreateCommandObject( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateCommandObject( class_name, m_dictionary_name.c_str(), debugger_sp); if (ret_val.IsValid()) @@ -2102,7 +2104,7 @@ static Timer::Category func_cat("LLDBSwigPythonCallTypeScript"); Timer scoped_timer(func_cat, "LLDBSwigPythonCallTypeScript"); - ret_val = LLDBSwigPythonCallTypeScript( + ret_val = SWIGBridge::LLDBSwigPythonCallTypeScript( python_function_name, GetSessionDictionary().get(), valobj, &new_callee, options_sp, retval); } @@ -2126,7 +2128,7 @@ const char *python_function_name, TypeImplSP type_impl_sp) { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - return LLDBSwigPythonFormatterCallbackFunction( + return SWIGBridge::LLDBSwigPythonFormatterCallbackFunction( python_function_name, m_dictionary_name.c_str(), type_impl_sp); } @@ -2166,7 +2168,7 @@ Locker::InitSession | Locker::NoSTDIN); Expected maybe_ret_val = - LLDBSwigPythonBreakpointCallbackFunction( + SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction( python_function_name, python_interpreter->m_dictionary_name.c_str(), stop_frame_sp, bp_loc_sp, bp_option_data->m_extra_args); @@ -2227,7 +2229,7 @@ Locker py_lock(python_interpreter, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonWatchpointCallbackFunction( + ret_val = SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction( python_function_name, python_interpreter->m_dictionary_name.c_str(), stop_frame_sp, wp_sp); @@ -2257,7 +2259,7 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPython_CalculateNumChildren(implementor, max); + ret_val = SWIGBridge::LLDBSwigPython_CalculateNumChildren(implementor, max); } return ret_val; @@ -2279,14 +2281,16 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - PyObject *child_ptr = LLDBSwigPython_GetChildAtIndex(implementor, idx); + PyObject *child_ptr = + SWIGBridge::LLDBSwigPython_GetChildAtIndex(implementor, idx); if (child_ptr != nullptr && child_ptr != Py_None) { lldb::SBValue *sb_value_ptr = (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr); if (sb_value_ptr == nullptr) Py_XDECREF(child_ptr); else - ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr); + ret_val = SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue( + sb_value_ptr); } else { Py_XDECREF(child_ptr); } @@ -2312,7 +2316,7 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPython_GetIndexOfChildWithName(implementor, child_name); + ret_val = SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(implementor, child_name); } return ret_val; @@ -2335,7 +2339,8 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPython_UpdateSynthProviderInstance(implementor); + ret_val = + SWIGBridge::LLDBSwigPython_UpdateSynthProviderInstance(implementor); } return ret_val; @@ -2358,8 +2363,8 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = - LLDBSwigPython_MightHaveChildrenSynthProviderInstance(implementor); + ret_val = SWIGBridge::LLDBSwigPython_MightHaveChildrenSynthProviderInstance( + implementor); } return ret_val; @@ -2383,14 +2388,15 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); PyObject *child_ptr = - LLDBSwigPython_GetValueSynthProviderInstance(implementor); + SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(implementor); if (child_ptr != nullptr && child_ptr != Py_None) { lldb::SBValue *sb_value_ptr = (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr); if (sb_value_ptr == nullptr) Py_XDECREF(child_ptr); else - ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr); + ret_val = SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue( + sb_value_ptr); } else { Py_XDECREF(child_ptr); } @@ -2461,7 +2467,7 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSWIGPythonRunScriptKeywordProcess( + ret_val = SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess( impl_function, m_dictionary_name.c_str(), process->shared_from_this(), output); if (!ret_val) @@ -2484,9 +2490,10 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - if (std::optional result = LLDBSWIGPythonRunScriptKeywordThread( - impl_function, m_dictionary_name.c_str(), - thread->shared_from_this())) { + if (std::optional result = + SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread( + impl_function, m_dictionary_name.c_str(), + thread->shared_from_this())) { output = std::move(*result); return true; } @@ -2511,7 +2518,7 @@ TargetSP target_sp(target->shared_from_this()); Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSWIGPythonRunScriptKeywordTarget( + ret_val = SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget( impl_function, m_dictionary_name.c_str(), target_sp, output); if (!ret_val) error.SetErrorString("python script evaluation failed"); @@ -2533,9 +2540,10 @@ Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - if (std::optional result = LLDBSWIGPythonRunScriptKeywordFrame( - impl_function, m_dictionary_name.c_str(), - frame->shared_from_this())) { + if (std::optional result = + SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame( + impl_function, m_dictionary_name.c_str(), + frame->shared_from_this())) { output = std::move(*result); return true; } @@ -2559,7 +2567,7 @@ { Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSWIGPythonRunScriptKeywordValue( + ret_val = SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue( impl_function, m_dictionary_name.c_str(), value->GetSP(), output); if (!ret_val) error.SetErrorString("python script evaluation failed"); @@ -2739,9 +2747,9 @@ // if we are here, everything worked // call __lldb_init_module(debugger,dict) - if (!LLDBSwigPythonCallModuleInit(module_name.c_str(), - m_dictionary_name.c_str(), - m_debugger.shared_from_this())) { + if (!SWIGBridge::LLDBSwigPythonCallModuleInit( + module_name.c_str(), m_dictionary_name.c_str(), + m_debugger.shared_from_this())) { error.SetErrorString("calling __lldb_init_module failed"); return false; } @@ -2835,7 +2843,7 @@ SynchronicityHandler synch_handler(debugger_sp, synchronicity); std::string args_str = args.str(); - ret_val = LLDBSwigPythonCallCommand( + ret_val = SWIGBridge::LLDBSwigPythonCallCommand( impl_function, m_dictionary_name.c_str(), debugger_sp, args_str.c_str(), cmd_retobj, exe_ctx_ref_sp); } @@ -2880,7 +2888,7 @@ SynchronicityHandler synch_handler(debugger_sp, synchronicity); std::string args_str = args.str(); - ret_val = LLDBSwigPythonCallCommandObject( + ret_val = SWIGBridge::LLDBSwigPythonCallCommandObject( static_cast(impl_obj_sp->GetValue()), debugger_sp, args_str.c_str(), cmd_retobj, exe_ctx_ref_sp); } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp @@ -44,7 +44,7 @@ lldb::ExecutionContextRefSP exe_ctx_ref_sp = std::make_shared(exe_ctx); - PythonObject ret_val = LLDBSwigPythonCreateScriptedObject( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedObject( class_name.str().c_str(), m_interpreter.GetDictionaryName(), exe_ctx_ref_sp, args_impl, error_string); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -48,7 +48,7 @@ lldb::ExecutionContextRefSP exe_ctx_ref_sp = std::make_shared(exe_ctx); - PythonObject ret_val = LLDBSwigPythonCreateScriptedObject( + PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedObject( class_name.str().c_str(), m_interpreter.GetDictionaryName(), exe_ctx_ref_sp, args_impl, error_string); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -119,19 +119,19 @@ } python::PythonObject Transform(Status arg) { - return python::ToSWIGWrapper(arg); + return python::SWIGBridge::ToSWIGWrapper(arg); } python::PythonObject Transform(lldb::ProcessAttachInfoSP arg) { - return python::ToSWIGWrapper(arg); + return python::SWIGBridge::ToSWIGWrapper(arg); } python::PythonObject Transform(lldb::ProcessLaunchInfoSP arg) { - return python::ToSWIGWrapper(arg); + return python::SWIGBridge::ToSWIGWrapper(arg); } python::PythonObject Transform(lldb::DataExtractorSP arg) { - return python::ToSWIGWrapper(arg); + return python::SWIGBridge::ToSWIGWrapper(arg); } template diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp @@ -46,7 +46,7 @@ if (!script_obj) { lldb::ExecutionContextRefSP exe_ctx_ref_sp = std::make_shared(exe_ctx); - ret_val = LLDBSwigPythonCreateScriptedObject( + ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedObject( class_name.str().c_str(), m_interpreter.GetDictionaryName(), exe_ctx_ref_sp, args_impl, error_string); } else diff --git a/lldb/unittests/API/CMakeLists.txt b/lldb/unittests/API/CMakeLists.txt --- a/lldb/unittests/API/CMakeLists.txt +++ b/lldb/unittests/API/CMakeLists.txt @@ -1,6 +1,5 @@ add_lldb_unittest(APITests SBCommandInterpreterTest.cpp - SBStructuredDataTest.cpp LINK_LIBS liblldb diff --git a/lldb/unittests/API/SBCommandInterpreterTest.cpp b/lldb/unittests/API/SBCommandInterpreterTest.cpp --- a/lldb/unittests/API/SBCommandInterpreterTest.cpp +++ b/lldb/unittests/API/SBCommandInterpreterTest.cpp @@ -22,11 +22,9 @@ void SetUp() override { SBDebugger::Initialize(); m_dbg = SBDebugger::Create(/*source_init_files=*/false); - m_interp = m_dbg.GetCommandInterpreter(); } SBDebugger m_dbg; - SBCommandInterpreter m_interp; }; class DummyCommand : public SBCommandPluginInterface { @@ -47,53 +45,55 @@ TEST_F(SBCommandInterpreterTest, SingleWordCommand) { // We first test a command without autorepeat DummyCommand dummy("It worked"); - m_interp.AddCommand("dummy", &dummy, /*help=*/nullptr); + SBCommandInterpreter interp = m_dbg.GetCommandInterpreter(); + interp.AddCommand("dummy", &dummy, /*help=*/nullptr); { SBCommandReturnObject result; - m_interp.HandleCommand("dummy", result, /*add_to_history=*/true); + interp.HandleCommand("dummy", result, /*add_to_history=*/true); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked\n"); } { SBCommandReturnObject result; - m_interp.HandleCommand("", result); + interp.HandleCommand("", result); EXPECT_FALSE(result.Succeeded()); EXPECT_STREQ(result.GetError(), "error: No auto repeat.\n"); } // Now we test a command with autorepeat - m_interp.AddCommand("dummy_with_autorepeat", &dummy, /*help=*/nullptr, - /*syntax=*/nullptr, /*auto_repeat_command=*/nullptr); + interp.AddCommand("dummy_with_autorepeat", &dummy, /*help=*/nullptr, + /*syntax=*/nullptr, /*auto_repeat_command=*/nullptr); { SBCommandReturnObject result; - m_interp.HandleCommand("dummy_with_autorepeat", result, - /*add_to_history=*/true); + interp.HandleCommand("dummy_with_autorepeat", result, + /*add_to_history=*/true); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked\n"); } { SBCommandReturnObject result; - m_interp.HandleCommand("", result); + interp.HandleCommand("", result); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked\n"); } } TEST_F(SBCommandInterpreterTest, MultiWordCommand) { - auto command = m_interp.AddMultiwordCommand("multicommand", /*help=*/nullptr); + SBCommandInterpreter interp = m_dbg.GetCommandInterpreter(); + auto command = interp.AddMultiwordCommand("multicommand", /*help=*/nullptr); // We first test a subcommand without autorepeat DummyCommand subcommand("It worked again"); command.AddCommand("subcommand", &subcommand, /*help=*/nullptr); { SBCommandReturnObject result; - m_interp.HandleCommand("multicommand subcommand", result, - /*add_to_history=*/true); + interp.HandleCommand("multicommand subcommand", result, + /*add_to_history=*/true); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked again\n"); } { SBCommandReturnObject result; - m_interp.HandleCommand("", result); + interp.HandleCommand("", result); EXPECT_FALSE(result.Succeeded()); EXPECT_STREQ(result.GetError(), "error: No auto repeat.\n"); } @@ -104,14 +104,14 @@ /*auto_repeat_command=*/nullptr); { SBCommandReturnObject result; - m_interp.HandleCommand("multicommand subcommand_with_autorepeat", result, - /*add_to_history=*/true); + interp.HandleCommand("multicommand subcommand_with_autorepeat", result, + /*add_to_history=*/true); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked again\n"); } { SBCommandReturnObject result; - m_interp.HandleCommand("", result); + interp.HandleCommand("", result); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked again\n"); } @@ -124,14 +124,14 @@ /*auto_repeat_command=*/"multicommand subcommand_with_autorepeat"); { SBCommandReturnObject result; - m_interp.HandleCommand("multicommand subcommand_with_custom_autorepeat", - result, /*add_to_history=*/true); + interp.HandleCommand("multicommand subcommand_with_custom_autorepeat", + result, /*add_to_history=*/true); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked again 2\n"); } { SBCommandReturnObject result; - m_interp.HandleCommand("", result); + interp.HandleCommand("", result); EXPECT_TRUE(result.Succeeded()); EXPECT_STREQ(result.GetOutput(), "It worked again\n"); } diff --git a/lldb/unittests/API/SBStructuredDataTest.cpp b/lldb/unittests/API/SBStructuredDataTest.cpp deleted file mode 100644 --- a/lldb/unittests/API/SBStructuredDataTest.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===-- SBStructuredDataTest.cpp ------------------------===----------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===/ - -#include "gtest/gtest.h" - -#include "lldb/API/SBStringList.h" -#include "lldb/API/SBStructuredData.h" - -#include -#include - -using namespace lldb; - -class SBStructuredDataTest : public testing::Test {}; - -TEST_F(SBStructuredDataTest, NullImpl) { - SBStructuredData data(nullptr); - EXPECT_EQ(data.GetType(), eStructuredDataTypeInvalid); - EXPECT_EQ(data.GetSize(), 0ul); - SBStringList keys; - EXPECT_FALSE(data.GetKeys(keys)); - EXPECT_EQ(data.GetValueForKey("key").GetType(), eStructuredDataTypeInvalid); - EXPECT_EQ(data.GetItemAtIndex(0).GetType(), eStructuredDataTypeInvalid); - EXPECT_EQ(data.GetIntegerValue(UINT64_MAX), UINT64_MAX); - EXPECT_EQ(data.GetFloatValue(DBL_MAX), DBL_MAX); - EXPECT_TRUE(data.GetBooleanValue(true)); - EXPECT_FALSE(data.GetBooleanValue(false)); - char dst[1]; - EXPECT_EQ(data.GetStringValue(dst, sizeof(dst)), 0ul); -} diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp --- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp +++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp @@ -54,7 +54,8 @@ extern "C" PyObject *PyInit__lldb(void) { return nullptr; } -llvm::Expected lldb_private::LLDBSwigPythonBreakpointCallbackFunction( +llvm::Expected +lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::BreakpointLocationSP &sb_bp_loc, @@ -62,83 +63,84 @@ return false; } -bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction( +bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) { return false; } -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) { return false; } -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) { return false; } -python::PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider( +python::PythonObject +lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider( const char *python_class_name, const char *session_dictionary_name, const lldb::ValueObjectSP &valobj_sp) { return python::PythonObject(); } -python::PythonObject lldb_private::LLDBSwigPythonCreateCommandObject( +python::PythonObject +lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject( const char *python_class_name, const char *session_dictionary_name, lldb::DebuggerSP debugger_sp) { return python::PythonObject(); } -python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( +python::PythonObject +lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan( const char *python_class_name, const char *session_dictionary_name, const StructuredDataImpl &args_data, std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) { return python::PythonObject(); } -bool lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor, - const char *method_name, - Event *event_sp, - bool &got_error) { +bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( + void *implementor, const char *method_name, Event *event_sp, + bool &got_error) { return false; } -bool -lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor, - const char *method_name, - Stream *event_sp, - bool &got_error) { +bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( + void *implementor, const char *method_name, Stream *event_sp, + bool &got_error) { return false; } -python::PythonObject -lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( - const char *python_class_name, const char *session_dictionary_name, - const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp) { +python::PythonObject lldb_private::python::SWIGBridge:: + LLDBSwigPythonCreateScriptedBreakpointResolver( + const char *python_class_name, const char *session_dictionary_name, + const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp) { return python::PythonObject(); } -unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver( +unsigned int +lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver( void *implementor, const char *method_name, lldb_private::SymbolContext *sym_ctx) { return 0; } -size_t lldb_private::LLDBSwigPython_CalculateNumChildren(PyObject *implementor, - uint32_t max) { +size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren( + PyObject *implementor, uint32_t max) { return 0; } -PyObject *lldb_private::LLDBSwigPython_GetChildAtIndex(PyObject *implementor, - uint32_t idx) { +PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex( + PyObject *implementor, uint32_t idx) { return nullptr; } -int lldb_private::LLDBSwigPython_GetIndexOfChildWithName( +int lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName( PyObject *implementor, const char *child_name) { return 0; } @@ -173,26 +175,29 @@ } lldb::ValueObjectSP -lldb_private::LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data) { +lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue( + void *data) { return nullptr; } -bool lldb_private::LLDBSwigPython_UpdateSynthProviderInstance( - PyObject *implementor) { +bool lldb_private::python::SWIGBridge:: + LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor) { return false; } -bool lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance( - PyObject *implementor) { +bool lldb_private::python::SWIGBridge:: + LLDBSwigPython_MightHaveChildrenSynthProviderInstance( + PyObject *implementor) { return false; } -PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance( +PyObject * +lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance( PyObject *implementor) { return nullptr; } -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, @@ -200,106 +205,113 @@ return false; } -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) { return false; } -bool lldb_private::LLDBSwigPythonCallModuleInit( +bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit( const char *python_module_name, const char *session_dictionary_name, lldb::DebuggerSP debugger) { return false; } python::PythonObject -lldb_private::LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp) { +lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin( + const char *python_class_name, const char *session_dictionary_name, + const lldb::ProcessSP &process_sp) { return python::PythonObject(); } -python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject( +python::PythonObject +lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject( const char *python_class_name, const char *session_dictionary_name, lldb::ExecutionContextRefSP exe_ctx_sp, const StructuredDataImpl &args_impl, std::string &error_string) { return python::PythonObject(); } -python::PythonObject lldb_private::LLDBSWIGPython_CreateFrameRecognizer( +python::PythonObject +lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer( const char *python_class_name, const char *session_dictionary_name) { return python::PythonObject(); } -PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments( +PyObject * +lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments( PyObject *implementor, const lldb::StackFrameSP &frame_sp) { return nullptr; } -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) { return false; } -std::optional lldb_private::LLDBSWIGPythonRunScriptKeywordThread( +std::optional +lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread( const char *python_function_name, const char *session_dictionary_name, lldb::ThreadSP thread) { return std::nullopt; } -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) { return false; } -std::optional lldb_private::LLDBSWIGPythonRunScriptKeywordFrame( +std::optional +lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame( const char *python_function_name, const char *session_dictionary_name, lldb::StackFrameSP frame) { return std::nullopt; } -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) { return false; } -void *lldb_private::LLDBSWIGPython_GetDynamicSetting( +void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting( void *module, const char *setting, const lldb::TargetSP &target_sp) { return nullptr; } -python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook( +python::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) { return python::PythonObject(); } -bool lldb_private::LLDBSwigPythonStopHookCallHandleStop( +bool lldb_private::python::SWIGBridge::LLDBSwigPythonStopHookCallHandleStop( void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp, lldb::StreamSP stream) { return false; } -python::PythonObject lldb_private::python::ToSWIGWrapper(const Status &status) { +python::PythonObject +lldb_private::python::SWIGBridge::ToSWIGWrapper(const Status &status) { return python::PythonObject(); } python::PythonObject -lldb_private::python::ToSWIGWrapper(lldb::ProcessAttachInfoSP) { +lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP) { return python::PythonObject(); } python::PythonObject -lldb_private::python::ToSWIGWrapper(lldb::ProcessLaunchInfoSP) { +lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP) { return python::PythonObject(); } python::PythonObject -lldb_private::python::ToSWIGWrapper(lldb::DataExtractorSP) { +lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP) { return python::PythonObject(); }