diff options
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index a7e34d28414..42d2ef46438 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/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 @@ ScriptInterpreterPython::InputReaderCallback ( void *baton, InputReader &reader, - lldb::InputReaderAction notification, + InputReaderAction notification, const char *bytes, size_t bytes_len ) @@ -565,7 +576,7 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback ( void *baton, InputReader &reader, - lldb::InputReaderAction notification, + InputReaderAction notification, const char *bytes, size_t bytes_len ) @@ -764,3 +775,34 @@ ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user 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; +} |