More SWIG cleanup. Moved the breakpoint callback function back to the
ScriptInterpreterPython class and made a simple callback function that
ScriptInterpreterPython::BreakpointCallbackFunction() now calls so we don't
include any internal API stuff into the cpp file that is generated by SWIG.

Fixed a few build warnings in debugserver.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115926 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index a7e34d2..42d2ef4 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -22,6 +22,8 @@
 
 #include <string>
 
+#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/Breakpoint/Breakpoint.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -36,11 +38,20 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/Thread.h"
 
 // This function is in the C++ output file generated by SWIG after it is 
 // run on all of the headers in "lldb/API/SB*.h"
 extern "C" void init_lldb (void);
 
+extern "C" bool
+LLDBSWIGPythonBreakpointCallbackFunction 
+(
+    const char *python_function_name,
+    lldb::SBFrame& sb_frame, 
+    lldb::SBBreakpointLocation& sb_bp_loc
+);
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -282,7 +293,7 @@
 (
     void *baton, 
     InputReader &reader, 
-    lldb::InputReaderAction notification,
+    InputReaderAction notification,
     const char *bytes, 
     size_t bytes_len
 )
@@ -565,7 +576,7 @@
 (
     void *baton, 
     InputReader &reader, 
-    lldb::InputReaderAction notification,
+    InputReaderAction notification,
     const char *bytes, 
     size_t bytes_len
 )
@@ -764,3 +775,34 @@
     return true;
 }
 
+bool
+ScriptInterpreterPython::BreakpointCallbackFunction 
+(
+    void *baton,
+    StoppointCallbackContext *context,
+    user_id_t break_id,
+    user_id_t break_loc_id
+)
+{
+    BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton;
+    const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0);
+    
+    if (python_function_name != NULL 
+        && python_function_name[0] != '\0')
+    {
+        Thread *thread = context->exe_ctx.thread;
+        Target *target = context->exe_ctx.target;
+        const StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame);
+        BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id);
+        const BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id);
+        
+        SBFrame sb_frame (stop_frame_sp);
+        SBBreakpointLocation sb_bp_loc (bp_loc_sp);
+        
+        if (sb_bp_loc.IsValid() || sb_frame.IsValid())
+            return LLDBSWIGPythonBreakpointCallbackFunction (python_function_name, sb_frame, sb_bp_loc);
+    }
+    // We currently always true so we stop in case anything goes wrong when
+    // trying to call the script function
+    return true;
+}