Author: jdevlieghere Date: Mon Mar 25 13:39:08 2019 New Revision: 356944 URL: http://llvm.org/viewvc/llvm-project?rev=356944&view=rev Log: [ScriptInterpreterPython] Make SWIG callback private (NFC)
With the initialization taking place inside the Python script interpreter, these function no longer need to be public. The exception is the g_swig_init_callback which is used from the RAII object. Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=356944&r1=356943&r2=356944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Mon Mar 25 13:39:08 2019 @@ -194,65 +194,66 @@ LLDBSWIGPython_GetDynamicSetting(void *m #endif -static ScriptInterpreterPython::SWIGInitCallback g_swig_init_callback = nullptr; -static ScriptInterpreterPython::SWIGBreakpointCallbackFunction - g_swig_breakpoint_callback = nullptr; -static ScriptInterpreterPython::SWIGWatchpointCallbackFunction - g_swig_watchpoint_callback = nullptr; -static ScriptInterpreterPython::SWIGPythonTypeScriptCallbackFunction - g_swig_typescript_callback = nullptr; -static ScriptInterpreterPython::SWIGPythonCreateSyntheticProvider - g_swig_synthetic_script = nullptr; -static ScriptInterpreterPython::SWIGPythonCreateCommandObject - g_swig_create_cmd = nullptr; -static ScriptInterpreterPython::SWIGPythonCalculateNumChildren - g_swig_calc_children = nullptr; -static ScriptInterpreterPython::SWIGPythonGetChildAtIndex - g_swig_get_child_index = nullptr; -static ScriptInterpreterPython::SWIGPythonGetIndexOfChildWithName - g_swig_get_index_child = nullptr; -static ScriptInterpreterPython::SWIGPythonCastPyObjectToSBValue - g_swig_cast_to_sbvalue = nullptr; -static ScriptInterpreterPython::SWIGPythonGetValueObjectSPFromSBValue - g_swig_get_valobj_sp_from_sbvalue = nullptr; -static ScriptInterpreterPython::SWIGPythonUpdateSynthProviderInstance - g_swig_update_provider = nullptr; -static ScriptInterpreterPython::SWIGPythonMightHaveChildrenSynthProviderInstance - g_swig_mighthavechildren_provider = nullptr; -static ScriptInterpreterPython::SWIGPythonGetValueSynthProviderInstance - g_swig_getvalue_provider = nullptr; -static ScriptInterpreterPython::SWIGPythonCallCommand g_swig_call_command = - nullptr; -static ScriptInterpreterPython::SWIGPythonCallCommandObject - g_swig_call_command_object = nullptr; -static ScriptInterpreterPython::SWIGPythonCallModuleInit - g_swig_call_module_init = nullptr; -static ScriptInterpreterPython::SWIGPythonCreateOSPlugin - g_swig_create_os_plugin = nullptr; -static ScriptInterpreterPython::SWIGPythonCreateFrameRecognizer - g_swig_create_frame_recognizer = nullptr; -static ScriptInterpreterPython::SWIGPythonGetRecognizedArguments - g_swig_get_recognized_arguments = nullptr; -static ScriptInterpreterPython::SWIGPythonScriptKeyword_Process - g_swig_run_script_keyword_process = nullptr; -static ScriptInterpreterPython::SWIGPythonScriptKeyword_Thread - g_swig_run_script_keyword_thread = nullptr; -static ScriptInterpreterPython::SWIGPythonScriptKeyword_Target - g_swig_run_script_keyword_target = nullptr; -static ScriptInterpreterPython::SWIGPythonScriptKeyword_Frame - g_swig_run_script_keyword_frame = nullptr; -static ScriptInterpreterPython::SWIGPythonScriptKeyword_Value - g_swig_run_script_keyword_value = nullptr; -static ScriptInterpreterPython::SWIGPython_GetDynamicSetting g_swig_plugin_get = - nullptr; -static ScriptInterpreterPython::SWIGPythonCreateScriptedThreadPlan - g_swig_thread_plan_script = nullptr; -static ScriptInterpreterPython::SWIGPythonCallThreadPlan - g_swig_call_thread_plan = nullptr; -static ScriptInterpreterPython::SWIGPythonCreateScriptedBreakpointResolver - g_swig_bkpt_resolver_script = nullptr; -static ScriptInterpreterPython::SWIGPythonCallBreakpointResolver - g_swig_call_bkpt_resolver = nullptr; +ScriptInterpreterPython::SWIGInitCallback + ScriptInterpreterPython::g_swig_init_callback = nullptr; +ScriptInterpreterPython::SWIGBreakpointCallbackFunction + ScriptInterpreterPython::g_swig_breakpoint_callback = nullptr; +ScriptInterpreterPython::SWIGWatchpointCallbackFunction + ScriptInterpreterPython::g_swig_watchpoint_callback = nullptr; +ScriptInterpreterPython::SWIGPythonTypeScriptCallbackFunction + ScriptInterpreterPython::g_swig_typescript_callback = nullptr; +ScriptInterpreterPython::SWIGPythonCreateSyntheticProvider + ScriptInterpreterPython::g_swig_synthetic_script = nullptr; +ScriptInterpreterPython::SWIGPythonCreateCommandObject + ScriptInterpreterPython::g_swig_create_cmd = nullptr; +ScriptInterpreterPython::SWIGPythonCalculateNumChildren + ScriptInterpreterPython::g_swig_calc_children = nullptr; +ScriptInterpreterPython::SWIGPythonGetChildAtIndex + ScriptInterpreterPython::g_swig_get_child_index = nullptr; +ScriptInterpreterPython::SWIGPythonGetIndexOfChildWithName + ScriptInterpreterPython::g_swig_get_index_child = nullptr; +ScriptInterpreterPython::SWIGPythonCastPyObjectToSBValue + ScriptInterpreterPython::g_swig_cast_to_sbvalue = nullptr; +ScriptInterpreterPython::SWIGPythonGetValueObjectSPFromSBValue + ScriptInterpreterPython::g_swig_get_valobj_sp_from_sbvalue = nullptr; +ScriptInterpreterPython::SWIGPythonUpdateSynthProviderInstance + ScriptInterpreterPython::g_swig_update_provider = nullptr; +ScriptInterpreterPython::SWIGPythonMightHaveChildrenSynthProviderInstance + ScriptInterpreterPython::g_swig_mighthavechildren_provider = nullptr; +ScriptInterpreterPython::SWIGPythonGetValueSynthProviderInstance + ScriptInterpreterPython::g_swig_getvalue_provider = nullptr; +ScriptInterpreterPython::SWIGPythonCallCommand + ScriptInterpreterPython::g_swig_call_command = nullptr; +ScriptInterpreterPython::SWIGPythonCallCommandObject + ScriptInterpreterPython::g_swig_call_command_object = nullptr; +ScriptInterpreterPython::SWIGPythonCallModuleInit + ScriptInterpreterPython::g_swig_call_module_init = nullptr; +ScriptInterpreterPython::SWIGPythonCreateOSPlugin + ScriptInterpreterPython::g_swig_create_os_plugin = nullptr; +ScriptInterpreterPython::SWIGPythonCreateFrameRecognizer + ScriptInterpreterPython::g_swig_create_frame_recognizer = nullptr; +ScriptInterpreterPython::SWIGPythonGetRecognizedArguments + ScriptInterpreterPython::g_swig_get_recognized_arguments = nullptr; +ScriptInterpreterPython::SWIGPythonScriptKeyword_Process + ScriptInterpreterPython::g_swig_run_script_keyword_process = nullptr; +ScriptInterpreterPython::SWIGPythonScriptKeyword_Thread + ScriptInterpreterPython::g_swig_run_script_keyword_thread = nullptr; +ScriptInterpreterPython::SWIGPythonScriptKeyword_Target + ScriptInterpreterPython::g_swig_run_script_keyword_target = nullptr; +ScriptInterpreterPython::SWIGPythonScriptKeyword_Frame + ScriptInterpreterPython::g_swig_run_script_keyword_frame = nullptr; +ScriptInterpreterPython::SWIGPythonScriptKeyword_Value + ScriptInterpreterPython::g_swig_run_script_keyword_value = nullptr; +ScriptInterpreterPython::SWIGPython_GetDynamicSetting + ScriptInterpreterPython::g_swig_plugin_get = nullptr; +ScriptInterpreterPython::SWIGPythonCreateScriptedThreadPlan + ScriptInterpreterPython::g_swig_thread_plan_script = nullptr; +ScriptInterpreterPython::SWIGPythonCallThreadPlan + ScriptInterpreterPython::g_swig_call_thread_plan = nullptr; +ScriptInterpreterPython::SWIGPythonCreateScriptedBreakpointResolver + ScriptInterpreterPython::g_swig_bkpt_resolver_script = nullptr; +ScriptInterpreterPython::SWIGPythonCallBreakpointResolver + ScriptInterpreterPython::g_swig_call_bkpt_resolver = nullptr; static bool g_initialized = false; @@ -275,7 +276,8 @@ public: InitializePythonHome(); // Register _lldb as a built-in module. - PyImport_AppendInittab("_lldb", g_swig_init_callback); + PyImport_AppendInittab("_lldb", + ScriptInterpreterPython::g_swig_init_callback); // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for // calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h?rev=356944&r1=356943&r2=356944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h Mon Mar 25 13:39:08 2019 @@ -40,118 +40,6 @@ public: } }; -#if PY_MAJOR_VERSION >= 3 - typedef PyObject *(*SWIGInitCallback)(void); -#else - typedef void (*SWIGInitCallback)(void); -#endif - - typedef bool (*SWIGBreakpointCallbackFunction)( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &frame_sp, - const lldb::BreakpointLocationSP &bp_loc_sp); - - typedef bool (*SWIGWatchpointCallbackFunction)( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp); - - typedef bool (*SWIGPythonTypeScriptCallbackFunction)( - const char *python_function_name, void *session_dictionary, - const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper, - const lldb::TypeSummaryOptionsSP &options, std::string &retval); - - typedef void *(*SWIGPythonCreateSyntheticProvider)( - const char *python_class_name, const char *session_dictionary_name, - const lldb::ValueObjectSP &valobj_sp); - - typedef void *(*SWIGPythonCreateCommandObject)( - const char *python_class_name, const char *session_dictionary_name, - const lldb::DebuggerSP debugger_sp); - - typedef void *(*SWIGPythonCreateScriptedThreadPlan)( - const char *python_class_name, const char *session_dictionary_name, - const lldb::ThreadPlanSP &thread_plan_sp); - - typedef bool (*SWIGPythonCallThreadPlan)(void *implementor, - const char *method_name, - Event *event_sp, bool &got_error); - - typedef void *(*SWIGPythonCreateScriptedBreakpointResolver)( - const char *python_class_name, const char *session_dictionary_name, - lldb_private::StructuredDataImpl *args_impl, - lldb::BreakpointSP &bkpt_sp); - - typedef unsigned int (*SWIGPythonCallBreakpointResolver)(void *implementor, - const char *method_name, - lldb_private::SymbolContext *sym_ctx); - - typedef void *(*SWIGPythonCreateOSPlugin)(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp); - - typedef void *(*SWIGPythonCreateFrameRecognizer)( - const char *python_class_name, const char *session_dictionary_name); - - typedef void *(*SWIGPythonGetRecognizedArguments)( - void *implementor, const lldb::StackFrameSP &frame_sp); - - typedef size_t (*SWIGPythonCalculateNumChildren)(void *implementor, - uint32_t max); - - typedef void *(*SWIGPythonGetChildAtIndex)(void *implementor, uint32_t idx); - - typedef int (*SWIGPythonGetIndexOfChildWithName)(void *implementor, - const char *child_name); - - typedef void *(*SWIGPythonCastPyObjectToSBValue)(void *data); - - typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue)( - void *data); - - typedef bool (*SWIGPythonUpdateSynthProviderInstance)(void *data); - - typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance)(void *data); - - typedef void *(*SWIGPythonGetValueSynthProviderInstance)(void *implementor); - - typedef bool (*SWIGPythonCallCommand)( - 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); - - typedef bool (*SWIGPythonCallCommandObject)( - void *implementor, lldb::DebuggerSP &debugger, const char *args, - lldb_private::CommandReturnObject &cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); - - typedef bool (*SWIGPythonCallModuleInit)(const char *python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP &debugger); - - typedef bool (*SWIGPythonScriptKeyword_Process)( - const char *python_function_name, const char *session_dictionary_name, - lldb::ProcessSP &process, std::string &output); - - typedef bool (*SWIGPythonScriptKeyword_Thread)( - const char *python_function_name, const char *session_dictionary_name, - lldb::ThreadSP &thread, std::string &output); - - typedef bool (*SWIGPythonScriptKeyword_Target)( - const char *python_function_name, const char *session_dictionary_name, - lldb::TargetSP &target, std::string &output); - - typedef bool (*SWIGPythonScriptKeyword_Frame)( - const char *python_function_name, const char *session_dictionary_name, - lldb::StackFrameSP &frame, std::string &output); - - typedef bool (*SWIGPythonScriptKeyword_Value)( - const char *python_function_name, const char *session_dictionary_name, - lldb::ValueObjectSP &value, std::string &output); - - typedef void *(*SWIGPython_GetDynamicSetting)( - void *module, const char *setting, const lldb::TargetSP &target_sp); - friend class ::IOHandlerPythonInterpreter; ScriptInterpreterPython(CommandInterpreter &interpreter); @@ -477,7 +365,121 @@ public: PyGILState_STATE m_GILState; }; + // FIXME: This is currently used from the InitializePythonRAII. Make this + // private when we're able to break the dependency. +#if PY_MAJOR_VERSION >= 3 + typedef PyObject *(*SWIGInitCallback)(void); +#else + typedef void (*SWIGInitCallback)(void); +#endif + static SWIGInitCallback g_swig_init_callback; + protected: + typedef bool (*SWIGBreakpointCallbackFunction)( + const char *python_function_name, const char *session_dictionary_name, + const lldb::StackFrameSP &frame_sp, + const lldb::BreakpointLocationSP &bp_loc_sp); + + typedef bool (*SWIGWatchpointCallbackFunction)( + const char *python_function_name, const char *session_dictionary_name, + const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp); + + typedef bool (*SWIGPythonTypeScriptCallbackFunction)( + const char *python_function_name, void *session_dictionary, + const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper, + const lldb::TypeSummaryOptionsSP &options, std::string &retval); + + typedef void *(*SWIGPythonCreateSyntheticProvider)( + const char *python_class_name, const char *session_dictionary_name, + const lldb::ValueObjectSP &valobj_sp); + + typedef void *(*SWIGPythonCreateCommandObject)( + const char *python_class_name, const char *session_dictionary_name, + const lldb::DebuggerSP debugger_sp); + + typedef void *(*SWIGPythonCreateScriptedThreadPlan)( + const char *python_class_name, const char *session_dictionary_name, + const lldb::ThreadPlanSP &thread_plan_sp); + + typedef bool (*SWIGPythonCallThreadPlan)(void *implementor, + const char *method_name, + Event *event_sp, bool &got_error); + + typedef void *(*SWIGPythonCreateScriptedBreakpointResolver)( + const char *python_class_name, const char *session_dictionary_name, + lldb_private::StructuredDataImpl *args_impl, lldb::BreakpointSP &bkpt_sp); + + typedef unsigned int (*SWIGPythonCallBreakpointResolver)( + void *implementor, const char *method_name, + lldb_private::SymbolContext *sym_ctx); + + typedef void *(*SWIGPythonCreateOSPlugin)(const char *python_class_name, + const char *session_dictionary_name, + const lldb::ProcessSP &process_sp); + + typedef void *(*SWIGPythonCreateFrameRecognizer)( + const char *python_class_name, const char *session_dictionary_name); + + typedef void *(*SWIGPythonGetRecognizedArguments)( + void *implementor, const lldb::StackFrameSP &frame_sp); + + typedef size_t (*SWIGPythonCalculateNumChildren)(void *implementor, + uint32_t max); + + typedef void *(*SWIGPythonGetChildAtIndex)(void *implementor, uint32_t idx); + + typedef int (*SWIGPythonGetIndexOfChildWithName)(void *implementor, + const char *child_name); + + typedef void *(*SWIGPythonCastPyObjectToSBValue)(void *data); + + typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue)( + void *data); + + typedef bool (*SWIGPythonUpdateSynthProviderInstance)(void *data); + + typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance)(void *data); + + typedef void *(*SWIGPythonGetValueSynthProviderInstance)(void *implementor); + + typedef bool (*SWIGPythonCallCommand)( + 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); + + typedef bool (*SWIGPythonCallCommandObject)( + void *implementor, lldb::DebuggerSP &debugger, const char *args, + lldb_private::CommandReturnObject &cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + + typedef bool (*SWIGPythonCallModuleInit)(const char *python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP &debugger); + + typedef bool (*SWIGPythonScriptKeyword_Process)( + const char *python_function_name, const char *session_dictionary_name, + lldb::ProcessSP &process, std::string &output); + + typedef bool (*SWIGPythonScriptKeyword_Thread)( + const char *python_function_name, const char *session_dictionary_name, + lldb::ThreadSP &thread, std::string &output); + + typedef bool (*SWIGPythonScriptKeyword_Target)( + const char *python_function_name, const char *session_dictionary_name, + lldb::TargetSP &target, std::string &output); + + typedef bool (*SWIGPythonScriptKeyword_Frame)( + const char *python_function_name, const char *session_dictionary_name, + lldb::StackFrameSP &frame, std::string &output); + + typedef bool (*SWIGPythonScriptKeyword_Value)( + const char *python_function_name, const char *session_dictionary_name, + lldb::ValueObjectSP &value, std::string &output); + + typedef void *(*SWIGPython_GetDynamicSetting)( + void *module, const char *setting, const lldb::TargetSP &target_sp); + static void InitializePrivate(); static void InitializeInterpreter( @@ -585,6 +587,38 @@ protected: bool m_valid_session; uint32_t m_lock_count; PyThreadState *m_command_thread_state; + + static SWIGBreakpointCallbackFunction g_swig_breakpoint_callback; + static SWIGWatchpointCallbackFunction g_swig_watchpoint_callback; + static SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback; + static SWIGPythonCreateSyntheticProvider g_swig_synthetic_script; + static SWIGPythonCreateCommandObject g_swig_create_cmd; + static SWIGPythonCalculateNumChildren g_swig_calc_children; + static SWIGPythonGetChildAtIndex g_swig_get_child_index; + static SWIGPythonGetIndexOfChildWithName g_swig_get_index_child; + static SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue; + static SWIGPythonGetValueObjectSPFromSBValue + g_swig_get_valobj_sp_from_sbvalue; + static SWIGPythonUpdateSynthProviderInstance g_swig_update_provider; + static SWIGPythonMightHaveChildrenSynthProviderInstance + g_swig_mighthavechildren_provider; + static SWIGPythonGetValueSynthProviderInstance g_swig_getvalue_provider; + static SWIGPythonCallCommand g_swig_call_command; + static SWIGPythonCallCommandObject g_swig_call_command_object; + static SWIGPythonCallModuleInit g_swig_call_module_init; + static SWIGPythonCreateOSPlugin g_swig_create_os_plugin; + static SWIGPythonCreateFrameRecognizer g_swig_create_frame_recognizer; + static SWIGPythonGetRecognizedArguments g_swig_get_recognized_arguments; + static SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process; + static SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread; + static SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target; + static SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame; + static SWIGPythonScriptKeyword_Value g_swig_run_script_keyword_value; + static SWIGPython_GetDynamicSetting g_swig_plugin_get; + static SWIGPythonCreateScriptedThreadPlan g_swig_thread_plan_script; + static SWIGPythonCallThreadPlan g_swig_call_thread_plan; + static SWIGPythonCreateScriptedBreakpointResolver g_swig_bkpt_resolver_script; + static SWIGPythonCallBreakpointResolver g_swig_call_bkpt_resolver; }; } // namespace lldb_private _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits