[Lldb-commits] [lldb] 9a14ade - [lldb] Remove 'extern "C"' from the lldb-swig-python interface

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 30 02:06:17 PST 2021


Author: Pavel Labath
Date: 2021-11-30T11:06:09+01:00
New Revision: 9a14adeae00015798843ff5cad987e5fdbdddb34

URL: https://github.com/llvm/llvm-project/commit/9a14adeae00015798843ff5cad987e5fdbdddb34
DIFF: https://github.com/llvm/llvm-project/commit/9a14adeae00015798843ff5cad987e5fdbdddb34.diff

LOG: [lldb] Remove 'extern "C"' from the lldb-swig-python interface

The LLDBSWIGPython functions had (at least) two problems:
- There wasn't a single source of truth (a header file) for the
  prototypes of these functions. This meant that subtle differences
  in copies of function declarations could go by undetected. And
  not-so-subtle differences would result in strange runtime failures.
- All of the declarations had to have an extern "C" interface, because
  the function definitions were being placed inside and extert "C" block
  generated by swig.

This patch fixes both problems by moving the function definitions to the
%header block of the swig files. This block is not surrounded by extern
"C", and seems more appropriate anyway, as swig docs say it is meant for
"user-defined support code" (whereas the previous %wrapper code was for
automatically-generated wrappers).

It also puts the declarations into the SWIGPythonBridge header file
(which seems to have been created for this purpose), and ensures it is
included by all code wishing to define or use these functions. This
means that any differences in the declaration become a compiler error
instead of a runtime failure.

Differential Revision: https://reviews.llvm.org/D114369

Added: 
    

Modified: 
    lldb/bindings/python/python-wrapper.swig
    lldb/bindings/python/python.swig
    lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
    lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index 8159423c62bbd..079f8d12dafab 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -22,32 +22,8 @@ private:
     bool m_print;
 };
 
-%}
-
-%wrapper %{
-
-// resolve a dotted Python name in the form
-// foo.bar.baz.Foobar to an actual Python object
-// if pmodule is NULL, the __main__ module will be used
-// as the starting point for the search
-
-
-// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
-// and is used when a script command is attached to a breakpoint for execution.
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
-
-// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
-// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
-// incompatible with C
-#if _MSC_VER
-#pragma warning (push)
-#pragma warning (disable : 4190)
-#endif
-
-SWIGEXPORT llvm::Expected<bool>
-LLDBSwigPythonBreakpointCallbackFunction
+llvm::Expected<bool>
+lldb_private::LLDBSwigPythonBreakpointCallbackFunction
 (
     const char *python_function_name,
     const char *session_dictionary_name,
@@ -93,17 +69,20 @@ LLDBSwigPythonBreakpointCallbackFunction
     return result.get().get() != Py_False;
 }
 
-#if _MSC_VER
-#pragma warning (pop)
-#endif
+// resolve a dotted Python name in the form
+// foo.bar.baz.Foobar to an actual Python object
+// if pmodule is NULL, the __main__ module will be used
+// as the starting point for the search
 
-#pragma clang diagnostic pop
+
+// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
+// and is used when a script command is attached to a breakpoint for execution.
 
 // This function is called by lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...)
 // and is used when a script command is attached to a watchpoint for execution.
 
-SWIGEXPORT bool
-LLDBSwigPythonWatchpointCallbackFunction
+bool
+lldb_private::LLDBSwigPythonWatchpointCallbackFunction
 (
     const char *python_function_name,
     const char *session_dictionary_name,
@@ -134,8 +113,8 @@ LLDBSwigPythonWatchpointCallbackFunction
     return stop_at_watchpoint;
 }
 
-SWIGEXPORT bool
-LLDBSwigPythonCallTypeScript
+bool
+lldb_private::LLDBSwigPythonCallTypeScript
 (
     const char *python_function_name,
     const void *session_dictionary,
@@ -207,8 +186,8 @@ LLDBSwigPythonCallTypeScript
     return true;
 }
 
-SWIGEXPORT void*
-LLDBSwigPythonCreateSyntheticProvider
+void*
+lldb_private::LLDBSwigPythonCreateSyntheticProvider
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -241,8 +220,8 @@ LLDBSwigPythonCreateSyntheticProvider
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT void*
-LLDBSwigPythonCreateCommandObject
+void*
+lldb_private::LLDBSwigPythonCreateCommandObject
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -269,8 +248,8 @@ LLDBSwigPythonCreateCommandObject
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT void*
-LLDBSwigPythonCreateScriptedProcess
+void*
+lldb_private::LLDBSwigPythonCreateScriptedProcess
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -323,8 +302,8 @@ LLDBSwigPythonCreateScriptedProcess
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT void*
-LLDBSwigPythonCreateScriptedThread
+void*
+lldb_private::LLDBSwigPythonCreateScriptedThread
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -375,8 +354,8 @@ LLDBSwigPythonCreateScriptedThread
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT void*
-LLDBSwigPythonCreateScriptedThreadPlan
+void*
+lldb_private::LLDBSwigPythonCreateScriptedThreadPlan
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -439,8 +418,8 @@ LLDBSwigPythonCreateScriptedThreadPlan
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT bool
-LLDBSWIGPythonCallThreadPlan
+bool
+lldb_private::LLDBSWIGPythonCallThreadPlan
 (
     void *implementor,
     const char *method_name,
@@ -486,7 +465,7 @@ LLDBSWIGPythonCallThreadPlan
     return false;
 }
 
-SWIGEXPORT void *LLDBSwigPythonCreateScriptedBreakpointResolver(
+void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
     const char *python_class_name, const char *session_dictionary_name,
     lldb_private::StructuredDataImpl *args_impl,
     const lldb::BreakpointSP &breakpoint_sp) {
@@ -522,8 +501,8 @@ SWIGEXPORT void *LLDBSwigPythonCreateScriptedBreakpointResolver(
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT unsigned int
-LLDBSwigPythonCallBreakpointResolver
+unsigned int
+lldb_private::LLDBSwigPythonCallBreakpointResolver
 (
     void *implementor,
     const char *method_name,
@@ -573,8 +552,8 @@ LLDBSwigPythonCallBreakpointResolver
     return ret_val;
 }
 
-SWIGEXPORT void *
-LLDBSwigPythonCreateScriptedStopHook
+void *
+lldb_private::LLDBSwigPythonCreateScriptedStopHook
 (
     lldb::TargetSP target_sp,
     const char *python_class_name,
@@ -644,8 +623,8 @@ LLDBSwigPythonCreateScriptedStopHook
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT bool
-LLDBSwigPythonStopHookCallHandleStop
+bool
+lldb_private::LLDBSwigPythonStopHookCallHandleStop
 (
     void *implementor,
     lldb::ExecutionContextRefSP exc_ctx_sp,
@@ -720,8 +699,8 @@ LLDBSwigPython_CallOptionalMember
     return result.release();
 }
 
-SWIGEXPORT size_t
-LLDBSwigPython_CalculateNumChildren
+size_t
+lldb_private::LLDBSwigPython_CalculateNumChildren
 (
     PyObject *implementor,
     uint32_t max
@@ -758,8 +737,8 @@ LLDBSwigPython_CalculateNumChildren
     return ret_val;
 }
 
-SWIGEXPORT PyObject*
-LLDBSwigPython_GetChildAtIndex
+PyObject*
+lldb_private::LLDBSwigPython_GetChildAtIndex
 (
     PyObject *implementor,
     uint32_t idx
@@ -788,8 +767,8 @@ LLDBSwigPython_GetChildAtIndex
     return result.release();
 }
 
-SWIGEXPORT int
-LLDBSwigPython_GetIndexOfChildWithName
+int
+lldb_private::LLDBSwigPython_GetIndexOfChildWithName
 (
     PyObject *implementor,
     const char* child_name
@@ -818,8 +797,8 @@ LLDBSwigPython_GetIndexOfChildWithName
     return UINT32_MAX;
 }
 
-SWIGEXPORT bool
-LLDBSwigPython_UpdateSynthProviderInstance
+bool
+lldb_private::LLDBSwigPython_UpdateSynthProviderInstance
 (
     PyObject *implementor
 )
@@ -838,8 +817,8 @@ LLDBSwigPython_UpdateSynthProviderInstance
     return ret_val;
 }
 
-SWIGEXPORT bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance
+bool
+lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance
 (
     PyObject *implementor
 )
@@ -858,8 +837,8 @@ LLDBSwigPython_MightHaveChildrenSynthProviderInstance
     return ret_val;
 }
 
-SWIGEXPORT PyObject*
-LLDBSwigPython_GetValueSynthProviderInstance
+PyObject*
+lldb_private::LLDBSwigPython_GetValueSynthProviderInstance
 (
     PyObject *implementor
 )
@@ -886,8 +865,8 @@ LLDBSwigPython_GetValueSynthProviderInstance
     return ret_val;
 }
 
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBData
+void*
+lldb_private::LLDBSWIGPython_CastPyObjectToSBData
 (
     PyObject* data
 )
@@ -903,8 +882,8 @@ LLDBSWIGPython_CastPyObjectToSBData
 }
 
 
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBError
+void*
+lldb_private::LLDBSWIGPython_CastPyObjectToSBError
 (
     PyObject* data
 )
@@ -920,8 +899,8 @@ LLDBSWIGPython_CastPyObjectToSBError
 }
 
 
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBValue
+void*
+lldb_private::LLDBSWIGPython_CastPyObjectToSBValue
 (
     PyObject* data
 )
@@ -936,8 +915,8 @@ LLDBSWIGPython_CastPyObjectToSBValue
     return sb_ptr;
 }
 
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo
+void*
+lldb_private::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo
 (
     PyObject* data
 )
@@ -952,8 +931,8 @@ LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo
     return sb_ptr;
 }
 
-SWIGEXPORT bool
-LLDBSwigPythonCallCommand
+bool
+lldb_private::LLDBSwigPythonCallCommand
 (
     const char *python_function_name,
     const char *session_dictionary_name,
@@ -991,8 +970,8 @@ LLDBSwigPythonCallCommand
     return true;
 }
 
-SWIGEXPORT bool
-LLDBSwigPythonCallCommandObject
+bool
+lldb_private::LLDBSwigPythonCallCommandObject
 (
     PyObject *implementor,
     lldb::DebuggerSP& debugger,
@@ -1022,8 +1001,8 @@ LLDBSwigPythonCallCommandObject
     return true;
 }
 
-SWIGEXPORT void*
-LLDBSWIGPythonCreateOSPlugin
+void*
+lldb_private::LLDBSWIGPythonCreateOSPlugin
 (
     const char *python_class_name,
     const char *session_dictionary_name,
@@ -1049,8 +1028,8 @@ LLDBSWIGPythonCreateOSPlugin
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT void*
-LLDBSWIGPython_CreateFrameRecognizer
+void*
+lldb_private::LLDBSWIGPython_CreateFrameRecognizer
 (
     const char *python_class_name,
     const char *session_dictionary_name
@@ -1075,8 +1054,8 @@ LLDBSWIGPython_CreateFrameRecognizer
     Py_RETURN_NONE;
 }
 
-SWIGEXPORT PyObject*
-LLDBSwigPython_GetRecognizedArguments
+PyObject*
+lldb_private::LLDBSwigPython_GetRecognizedArguments
 (
     PyObject *implementor,
     const lldb::StackFrameSP& frame_sp
@@ -1093,8 +1072,8 @@ LLDBSwigPython_GetRecognizedArguments
     return result;
 }
 
-SWIGEXPORT void*
-LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb::TargetSP& target_sp)
+void*
+lldb_private::LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb::TargetSP& target_sp)
 {
     if (!module || !setting)
         Py_RETURN_NONE;
@@ -1111,7 +1090,7 @@ LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb:
     return result.release();
 }
 
-SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordProcess(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::ProcessSP &process, std::string &output) {
 
@@ -1133,8 +1112,8 @@ SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordProcess(
     return true;
 }
 
-SWIGEXPORT bool
-LLDBSWIGPythonRunScriptKeywordThread
+bool
+lldb_private::LLDBSWIGPythonRunScriptKeywordThread
 (const char* python_function_name,
 const char* session_dictionary_name,
 lldb::ThreadSP& thread,
@@ -1161,7 +1140,7 @@ std::string& output)
     return true;
 }
 
-SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordTarget(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::TargetSP &target, std::string &output) {
 
@@ -1183,8 +1162,8 @@ SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordTarget(
     return true;
 }
 
-SWIGEXPORT bool
-LLDBSWIGPythonRunScriptKeywordFrame
+bool
+lldb_private::LLDBSWIGPythonRunScriptKeywordFrame
 (const char* python_function_name,
 const char* session_dictionary_name,
 lldb::StackFrameSP& frame,
@@ -1211,7 +1190,7 @@ std::string& output)
     return true;
 }
 
-SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordValue(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::ValueObjectSP &value, std::string &output) {
 
@@ -1233,8 +1212,8 @@ SWIGEXPORT bool LLDBSWIGPythonRunScriptKeywordValue(
     return true;
 }
 
-SWIGEXPORT bool
-LLDBSwigPythonCallModuleInit
+bool
+lldb_private::LLDBSwigPythonCallModuleInit
 (
     const char *python_module_name,
     const char *session_dictionary_name,
@@ -1261,16 +1240,9 @@ LLDBSwigPythonCallModuleInit
 
     return true;
 }
-%}
-
-
-%runtime %{
-// Forward declaration to be inserted at the start of LLDBWrapPython.h
-#include "lldb/API/SBDebugger.h"
-#include "lldb/API/SBValue.h"
 
-SWIGEXPORT lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data)
+lldb::ValueObjectSP
+lldb_private::LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data)
 {
     lldb::ValueObjectSP valobj_sp;
     if (data)
@@ -1281,22 +1253,8 @@ LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data)
     return valobj_sp;
 }
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton);
-
-#ifdef __cplusplus
-}
-#endif
-%}
-
-%wrapper %{
-
-
 // For the LogOutputCallback functions
-void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) {
+static void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) {
     if (baton != Py_None) {
       SWIG_PYTHON_THREAD_BEGIN_BLOCK;
       PyObject *result = PyObject_CallFunction(reinterpret_cast<PyObject*>(baton), const_cast<char*>("s"), str);

diff  --git a/lldb/bindings/python/python.swig b/lldb/bindings/python/python.swig
index 9dc4ab87a4bd9..5dcbd68d85447 100644
--- a/lldb/bindings/python/python.swig
+++ b/lldb/bindings/python/python.swig
@@ -121,6 +121,7 @@ def lldb_iter(obj, getsize, getelem):
 
 %{
 #include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
+#include "../source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
 #include "../bindings/python/python-swigsafecast.swig"
 using namespace lldb_private;
 using namespace lldb_private::python;

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 798d947a0a7dc..c7af135988433 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -15,8 +15,12 @@
 
 #if LLDB_ENABLE_PYTHON
 
+// LLDB Python header must be included first
+#include "lldb-python.h"
+
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
+#include "llvm/Support/Error.h"
 
 namespace lldb_private {
 
@@ -41,20 +45,148 @@ template <> const char *GetPythonValueFormatString(unsigned long long);
 template <> const char *GetPythonValueFormatString(float t);
 template <> const char *GetPythonValueFormatString(double t);
 
-extern "C" void *LLDBSwigPythonCreateScriptedProcess(
+void *LLDBSWIGPython_CastPyObjectToSBData(PyObject *data);
+void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data);
+void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data);
+void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data);
+
+// These prototypes are the Pythonic implementations of the required callbacks.
+// Although these are scripting-language specific, their definition depends on
+// the public API.
+
+void *LLDBSwigPythonCreateScriptedProcess(const char *python_class_name,
+                                          const char *session_dictionary_name,
+                                          const lldb::TargetSP &target_sp,
+                                          StructuredDataImpl *args_impl,
+                                          std::string &error_string);
+
+void *LLDBSwigPythonCreateScriptedThread(const char *python_class_name,
+                                         const char *session_dictionary_name,
+                                         const lldb::ProcessSP &process_sp,
+                                         StructuredDataImpl *args_impl,
+                                         std::string &error_string);
+
+llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
+    const char *python_function_name, const char *session_dictionary_name,
+    const lldb::StackFrameSP &sb_frame,
+    const lldb::BreakpointLocationSP &sb_bp_loc,
+    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 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 *
+LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
+                                      const char *session_dictionary_name,
+                                      const lldb::ValueObjectSP &valobj_sp);
+
+void *LLDBSwigPythonCreateCommandObject(const char *python_class_name,
+                                        const char *session_dictionary_name,
+                                        const lldb::DebuggerSP debugger_sp);
+
+void *LLDBSwigPythonCreateScriptedThreadPlan(
     const char *python_class_name, const char *session_dictionary_name,
-    const lldb::TargetSP &target_sp, StructuredDataImpl *args_impl,
-    std::string &error_string);
+    lldb_private::StructuredDataImpl *args_data, std::string &error_string,
+    const lldb::ThreadPlanSP &thread_plan_sp);
 
-extern "C" void *LLDBSwigPythonCreateScriptedThread(
+bool LLDBSWIGPythonCallThreadPlan(void *implementor, const char *method_name,
+                                  lldb_private::Event *event_sp,
+                                  bool &got_error);
+
+void *LLDBSwigPythonCreateScriptedBreakpointResolver(
     const char *python_class_name, const char *session_dictionary_name,
-    const lldb::ProcessSP &process_sp, StructuredDataImpl *args_impl,
-    std::string &error_string);
+    lldb_private::StructuredDataImpl *args, const lldb::BreakpointSP &bkpt_sp);
+
+unsigned int
+LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name,
+                                     lldb_private::SymbolContext *sym_ctx);
+
+void *LLDBSwigPythonCreateScriptedStopHook(
+    lldb::TargetSP target_sp, const char *python_class_name,
+    const char *session_dictionary_name, lldb_private::StructuredDataImpl *args,
+    lldb_private::Status &error);
+
+bool LLDBSwigPythonStopHookCallHandleStop(void *implementor,
+                                          lldb::ExecutionContextRefSP exc_ctx,
+                                          lldb::StreamSP stream);
+
+size_t LLDBSwigPython_CalculateNumChildren(PyObject *implementor, uint32_t max);
+
+PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor, uint32_t idx);
+
+int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor,
+                                           const char *child_name);
+
+lldb::ValueObjectSP LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
+
+bool LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor);
+
+bool LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
+    PyObject *implementor);
+
+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);
+
+bool LLDBSwigPythonCallCommandObject(
+    PyObject *implementor, lldb::DebuggerSP &debugger, const char *args,
+    lldb_private::CommandReturnObject &cmd_retobj,
+    lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+bool LLDBSwigPythonCallModuleInit(const char *python_module_name,
+                                  const char *session_dictionary_name,
+                                  lldb::DebuggerSP &debugger);
+
+void *LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
+                                   const char *session_dictionary_name,
+                                   const lldb::ProcessSP &process_sp);
+
+void *LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
+                                           const char *session_dictionary_name);
+
+PyObject *
+LLDBSwigPython_GetRecognizedArguments(PyObject *implementor,
+                                      const lldb::StackFrameSP &frame_sp);
+
+bool LLDBSWIGPythonRunScriptKeywordProcess(const char *python_function_name,
+                                           const char *session_dictionary_name,
+                                           const lldb::ProcessSP &process,
+                                           std::string &output);
+
+bool LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name,
+                                          const char *session_dictionary_name,
+                                          lldb::ThreadSP &thread,
+                                          std::string &output);
+
+bool LLDBSWIGPythonRunScriptKeywordTarget(const char *python_function_name,
+                                          const char *session_dictionary_name,
+                                          const lldb::TargetSP &target,
+                                          std::string &output);
+
+bool LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name,
+                                         const char *session_dictionary_name,
+                                         lldb::StackFrameSP &frame,
+                                         std::string &output);
+
+bool LLDBSWIGPythonRunScriptKeywordValue(const char *python_function_name,
+                                         const char *session_dictionary_name,
+                                         const lldb::ValueObjectSP &value,
+                                         std::string &output);
 
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data);
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data);
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(void *data);
+void *LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
+                                       const lldb::TargetSP &target_sp);
 
 } // namespace lldb_private
 

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index e8b1ad7c6c693..5f282d74e3649 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -70,153 +70,6 @@ extern "C" void init_lldb(void);
 #define LLDBSwigPyInit init_lldb
 #endif
 
-// These prototypes are the Pythonic implementations of the required callbacks.
-// Although these are scripting-language specific, their definition depends on
-// the public API.
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
-
-// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
-// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
-// incompatible with C
-#if _MSC_VER
-#pragma warning (push)
-#pragma warning (disable : 4190)
-#endif
-
-extern "C" llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
-    const char *python_function_name, const char *session_dictionary_name,
-    const lldb::StackFrameSP &sb_frame,
-    const lldb::BreakpointLocationSP &sb_bp_loc, StructuredDataImpl *args_impl);
-
-#if _MSC_VER
-#pragma warning (pop)
-#endif
-
-#pragma clang diagnostic pop
-
-extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
-    const char *python_function_name, const char *session_dictionary_name,
-    const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp);
-
-extern "C" bool LLDBSwigPythonCallTypeScript(
-    const char *python_function_name, void *session_dictionary,
-    const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
-    const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval);
-
-extern "C" void *
-LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
-                                      const char *session_dictionary_name,
-                                      const lldb::ValueObjectSP &valobj_sp);
-
-extern "C" void *
-LLDBSwigPythonCreateCommandObject(const char *python_class_name,
-                                  const char *session_dictionary_name,
-                                  const lldb::DebuggerSP debugger_sp);
-
-extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
-    const char *python_class_name, const char *session_dictionary_name,
-    StructuredDataImpl *args_data,
-    std::string &error_string,
-    const lldb::ThreadPlanSP &thread_plan_sp);
-
-extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
-                                             const char *method_name,
-                                             Event *event_sp, bool &got_error);
-
-extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
-    const char *python_class_name, const char *session_dictionary_name,
-    lldb_private::StructuredDataImpl *args, const lldb::BreakpointSP &bkpt_sp);
-
-extern "C" unsigned int
-LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name,
-                                     lldb_private::SymbolContext *sym_ctx);
-
-extern "C" void *LLDBSwigPythonCreateScriptedStopHook(
-    TargetSP target_sp, const char *python_class_name,
-    const char *session_dictionary_name, lldb_private::StructuredDataImpl *args,
-    lldb_private::Status &error);
-
-extern "C" bool
-LLDBSwigPythonStopHookCallHandleStop(void *implementor,
-                                     lldb::ExecutionContextRefSP exc_ctx,
-                                     lldb::StreamSP stream);
-
-extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
-                                                      uint32_t max);
-
-extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
-                                                uint32_t idx);
-
-extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
-                                                      const char *child_name);
-
-extern lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
-
-extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor);
-
-extern "C" bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor);
-
-extern "C" void *
-LLDBSwigPython_GetValueSynthProviderInstance(void *implementor);
-
-extern "C" 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);
-
-extern "C" bool
-LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
-                                const char *args,
-                                lldb_private::CommandReturnObject &cmd_retobj,
-                                lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-extern "C" bool
-LLDBSwigPythonCallModuleInit(const char *python_module_name,
-                             const char *session_dictionary_name,
-                             lldb::DebuggerSP &debugger);
-
-extern "C" void *
-LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
-                             const char *session_dictionary_name,
-                             const lldb::ProcessSP &process_sp);
-
-extern "C" void *
-LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
-                                     const char *session_dictionary_name);
-
-extern "C" void *
-LLDBSwigPython_GetRecognizedArguments(void *implementor,
-                                      const lldb::StackFrameSP &frame_sp);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
-    const char *python_function_name, const char *session_dictionary_name,
-    const lldb::ProcessSP &process, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
-    const char *python_function_name, const char *session_dictionary_name,
-    lldb::ThreadSP &thread, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
-    const char *python_function_name, const char *session_dictionary_name,
-    const lldb::TargetSP &target, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
-    const char *python_function_name, const char *session_dictionary_name,
-    lldb::StackFrameSP &frame, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
-    const char *python_function_name, const char *session_dictionary_name,
-    const lldb::ValueObjectSP &value, std::string &output);
-
-extern "C" void *
-LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
-                                 const lldb::TargetSP &target_sp);
 
 static ScriptInterpreterPythonImpl *GetPythonInterpreter(Debugger &debugger) {
   ScriptInterpreter *script_interpreter =
@@ -1591,9 +1444,9 @@ lldb::ValueObjectListSP ScriptInterpreterPythonImpl::GetRecognizedArguments(
   if (!implementor.IsAllocated())
     return ValueObjectListSP();
 
-  PythonObject py_return(PyRefType::Owned,
-                         (PyObject *)LLDBSwigPython_GetRecognizedArguments(
-                             implementor.get(), frame_sp));
+  PythonObject py_return(
+      PyRefType::Owned,
+      LLDBSwigPython_GetRecognizedArguments(implementor.get(), frame_sp));
 
   // if it fails, print the error but otherwise go on
   if (PyErr_Occurred()) {
@@ -2423,7 +2276,7 @@ size_t ScriptInterpreterPythonImpl::CalculateNumChildren(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return 0;
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return 0;
 
@@ -2446,7 +2299,7 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return lldb::ValueObjectSP();
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return lldb::ValueObjectSP();
 
@@ -2454,7 +2307,7 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
   {
     Locker py_lock(this,
                    Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-    void *child_ptr = LLDBSwigPython_GetChildAtIndex(implementor, idx);
+    PyObject *child_ptr = LLDBSwigPython_GetChildAtIndex(implementor, idx);
     if (child_ptr != nullptr && child_ptr != Py_None) {
       lldb::SBValue *sb_value_ptr =
           (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
@@ -2478,7 +2331,7 @@ int ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return UINT32_MAX;
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return UINT32_MAX;
 
@@ -2503,7 +2356,7 @@ bool ScriptInterpreterPythonImpl::UpdateSynthProviderInstance(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return ret_val;
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return ret_val;
 
@@ -2526,7 +2379,7 @@ bool ScriptInterpreterPythonImpl::MightHaveChildrenSynthProviderInstance(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return ret_val;
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return ret_val;
 
@@ -2550,14 +2403,15 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetSyntheticValue(
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
     return ret_val;
-  void *implementor = generic->GetValue();
+  auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
     return ret_val;
 
   {
     Locker py_lock(this,
                    Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-    void *child_ptr = LLDBSwigPython_GetValueSynthProviderInstance(implementor);
+    PyObject *child_ptr =
+        LLDBSwigPython_GetValueSynthProviderInstance(implementor);
     if (child_ptr != nullptr && child_ptr != Py_None) {
       lldb::SBValue *sb_value_ptr =
           (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
@@ -3075,9 +2929,9 @@ bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
     SynchronicityHandler synch_handler(debugger_sp, synchronicity);
 
     std::string args_str = args.str();
-    ret_val = LLDBSwigPythonCallCommandObject(impl_obj_sp->GetValue(),
-                                              debugger_sp, args_str.c_str(),
-                                              cmd_retobj, exe_ctx_ref_sp);
+    ret_val = LLDBSwigPythonCallCommandObject(
+        static_cast<PyObject *>(impl_obj_sp->GetValue()), debugger_sp,
+        args_str.c_str(), cmd_retobj, exe_ctx_ref_sp);
   }
 
   if (!ret_val)

diff  --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index 230fcf7ba38af..1295ab2a7b78b 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -8,10 +8,10 @@
 
 #include "gtest/gtest.h"
 
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
-
+#include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h"
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
 
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
@@ -55,24 +55,11 @@ void PythonTestSuite::TearDown() {
 
 #if PY_MAJOR_VERSION >= 3
 extern "C" PyObject *PyInit__lldb(void) { return nullptr; }
-#define LLDBSwigPyInit PyInit__lldb
 #else
 extern "C" void init_lldb(void) {}
-#define LLDBSwigPyInit init_lldb
-#endif
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
-
-// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
-// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
-// incompatible with C
-#if _MSC_VER
-#pragma warning (push)
-#pragma warning (disable : 4190)
 #endif
 
-extern "C" llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
+llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::StackFrameSP &sb_frame,
     const lldb::BreakpointLocationSP &sb_bp_loc,
@@ -80,218 +67,205 @@ extern "C" llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction(
   return false;
 }
 
-#if _MSC_VER
-#pragma warning (pop)
-#endif
-
-#pragma clang diagnostic pop
-
-extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
+bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) {
   return false;
 }
 
-extern "C" bool LLDBSwigPythonCallTypeScript(
-    const char *python_function_name, void *session_dictionary,
+bool lldb_private::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;
 }
 
-extern "C" void *
-LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
-                                      const char *session_dictionary_name,
-                                      const lldb::ValueObjectSP &valobj_sp) {
+void *lldb_private::LLDBSwigPythonCreateSyntheticProvider(
+    const char *python_class_name, const char *session_dictionary_name,
+    const lldb::ValueObjectSP &valobj_sp) {
   return nullptr;
 }
 
-extern "C" void *
-LLDBSwigPythonCreateCommandObject(const char *python_class_name,
-                                  const char *session_dictionary_name,
-                                  const lldb::DebuggerSP debugger_sp) {
+void *lldb_private::LLDBSwigPythonCreateCommandObject(
+    const char *python_class_name, const char *session_dictionary_name,
+    const lldb::DebuggerSP debugger_sp) {
   return nullptr;
 }
 
-extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
+void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
     const char *python_class_name, const char *session_dictionary_name,
-    StructuredDataImpl *args_data,
-    std::string &error_string,
+    StructuredDataImpl *args_data, std::string &error_string,
     const lldb::ThreadPlanSP &thread_plan_sp) {
   return nullptr;
 }
 
-extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
-                                             const char *method_name,
-                                             Event *event_sp, bool &got_error) {
+bool lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor,
+                                                const char *method_name,
+                                                Event *event_sp,
+                                                bool &got_error) {
   return false;
 }
 
-extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
+void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
     const char *python_class_name, const char *session_dictionary_name,
     lldb_private::StructuredDataImpl *args, const lldb::BreakpointSP &bkpt_sp) {
   return nullptr;
 }
 
-extern "C" unsigned int
-LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name,
-                                     lldb_private::SymbolContext *sym_ctx) {
+unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver(
+    void *implementor, const char *method_name,
+    lldb_private::SymbolContext *sym_ctx) {
   return 0;
 }
 
-extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
-                                                      uint32_t max) {
+size_t lldb_private::LLDBSwigPython_CalculateNumChildren(PyObject *implementor,
+                                                         uint32_t max) {
   return 0;
 }
 
-extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
-                                                uint32_t idx) {
+PyObject *lldb_private::LLDBSwigPython_GetChildAtIndex(PyObject *implementor,
+                                                       uint32_t idx) {
   return nullptr;
 }
 
-extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
-                                                      const char *child_name) {
+int lldb_private::LLDBSwigPython_GetIndexOfChildWithName(
+    PyObject *implementor, const char *child_name) {
   return 0;
 }
 
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data) {
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBData(PyObject *data) {
   return nullptr;
 }
 
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data) {
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBError(PyObject *data) {
   return nullptr;
 }
 
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data) {
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data) {
   return nullptr;
 }
 
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(void *data) {
+void *
+lldb_private::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data) {
   return nullptr;
 }
 
-extern lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data) {
+lldb::ValueObjectSP
+lldb_private::LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data) {
   return nullptr;
 }
 
-extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor) {
+bool lldb_private::LLDBSwigPython_UpdateSynthProviderInstance(
+    PyObject *implementor) {
   return false;
 }
 
-extern "C" bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor) {
+bool lldb_private::LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
+    PyObject *implementor) {
   return false;
 }
 
-extern "C" void *
-LLDBSwigPython_GetValueSynthProviderInstance(void *implementor) {
+PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance(
+    PyObject *implementor) {
   return nullptr;
 }
 
-extern "C" 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) {
+bool lldb_private::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) {
   return false;
 }
 
-extern "C" bool
-LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
-                                const char *args,
-                                lldb_private::CommandReturnObject &cmd_retobj,
-                                lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+bool lldb_private::LLDBSwigPythonCallCommandObject(
+    PyObject *implementor, lldb::DebuggerSP &debugger, const char *args,
+    lldb_private::CommandReturnObject &cmd_retobj,
+    lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
   return false;
 }
 
-extern "C" bool
-LLDBSwigPythonCallModuleInit(const char *python_module_name,
-                             const char *session_dictionary_name,
-                             lldb::DebuggerSP &debugger) {
+bool lldb_private::LLDBSwigPythonCallModuleInit(
+    const char *python_module_name, const char *session_dictionary_name,
+    lldb::DebuggerSP &debugger) {
   return false;
 }
 
-extern "C" void *
-LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
-                             const char *session_dictionary_name,
-                             const lldb::ProcessSP &process_sp) {
+void *
+lldb_private::LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
+                                           const char *session_dictionary_name,
+                                           const lldb::ProcessSP &process_sp) {
   return nullptr;
 }
 
-extern "C" void *LLDBSwigPythonCreateScriptedProcess(
+void *lldb_private::LLDBSwigPythonCreateScriptedProcess(
     const char *python_class_name, const char *session_dictionary_name,
     const lldb::TargetSP &target_sp, StructuredDataImpl *args_impl,
     std::string &error_string) {
   return nullptr;
 }
 
-extern "C" void *LLDBSwigPythonCreateScriptedThread(
+void *lldb_private::LLDBSwigPythonCreateScriptedThread(
     const char *python_class_name, const char *session_dictionary_name,
     const lldb::ProcessSP &process_sp, StructuredDataImpl *args_impl,
     std::string &error_string) {
   return nullptr;
 }
 
-extern "C" void *
-LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
-                                     const char *session_dictionary_name) {
+void *lldb_private::LLDBSWIGPython_CreateFrameRecognizer(
+    const char *python_class_name, const char *session_dictionary_name) {
   return nullptr;
 }
 
-extern "C" void *
-LLDBSwigPython_GetRecognizedArguments(void *implementor,
-                                      const lldb::StackFrameSP &frame_sp) {
+PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments(
+    PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
   return nullptr;
 }
 
-extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::ProcessSP &process, std::string &output) {
   return false;
 }
 
-extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
     const char *python_function_name, const char *session_dictionary_name,
     lldb::ThreadSP &thread, std::string &output) {
   return false;
 }
 
-extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::TargetSP &target, std::string &output) {
   return false;
 }
 
-extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
     const char *python_function_name, const char *session_dictionary_name,
     lldb::StackFrameSP &frame, std::string &output) {
   return false;
 }
 
-extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
+bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::ValueObjectSP &value, std::string &output) {
   return false;
 }
 
-extern "C" void *
-LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
-                                 const lldb::TargetSP &target_sp) {
+void *lldb_private::LLDBSWIGPython_GetDynamicSetting(
+    void *module, const char *setting, const lldb::TargetSP &target_sp) {
   return nullptr;
 }
 
-extern "C" void *LLDBSwigPythonCreateScriptedStopHook(
+void *lldb_private::LLDBSwigPythonCreateScriptedStopHook(
     lldb::TargetSP target_sp, const char *python_class_name,
     const char *session_dictionary_name,
     lldb_private::StructuredDataImpl *args_impl, Status &error) {
   return nullptr;
 }
 
-extern "C" bool
-LLDBSwigPythonStopHookCallHandleStop(void *implementor,
-                                     lldb::ExecutionContextRefSP exc_ctx_sp,
-                                     lldb::StreamSP stream) {
+bool lldb_private::LLDBSwigPythonStopHookCallHandleStop(
+    void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp,
+    lldb::StreamSP stream) {
   return false;
 }


        


More information about the lldb-commits mailing list