From d80102e4203691c31314fb3f65c5f91d86dbf06e Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 2 Apr 2014 01:04:55 +0000 Subject: Add the ability to set python breakpoint commands from the SBBreakpoint & SBBreakpointLocation API's. You can either provide the function name, or function body text. Also propagate the compilation error up from where it is checked so we can report compilation errors. llvm-svn: 205380 --- lldb/scripts/Python/interface/SBBreakpoint.i | 22 ++++++++++++++++++++- .../Python/interface/SBBreakpointLocation.i | 23 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'lldb/scripts/Python/interface') diff --git a/lldb/scripts/Python/interface/SBBreakpoint.i b/lldb/scripts/Python/interface/SBBreakpoint.i index 34274dda8b0..190c9b90dd6 100644 --- a/lldb/scripts/Python/interface/SBBreakpoint.i +++ b/lldb/scripts/Python/interface/SBBreakpoint.i @@ -177,9 +177,29 @@ public: const char * GetQueueName () const; + %feature("docstring", " + //------------------------------------------------------------------ + /// Set the name of the script function to be called when the breakpoint is hit. + //------------------------------------------------------------------ + ") SetScriptCallbackFunction; void - SetCallback (BreakpointHitCallback callback, void *baton); + SetScriptCallbackFunction (const char *callback_function_name); + %feature("docstring", " + //------------------------------------------------------------------ + /// Provide the body for the script function to be called when the breakpoint is hit. + /// The body will be wrapped in a function, which be passed two arguments: + /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + /// + /// The error parameter is currently ignored, but will at some point hold the Python + /// compilation diagnostics. + /// Returns true if the body compiles successfully, false if not. + //------------------------------------------------------------------ + ") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + size_t GetNumResolvedLocations() const; diff --git a/lldb/scripts/Python/interface/SBBreakpointLocation.i b/lldb/scripts/Python/interface/SBBreakpointLocation.i index 8c9b9c78246..a3073538e67 100644 --- a/lldb/scripts/Python/interface/SBBreakpointLocation.i +++ b/lldb/scripts/Python/interface/SBBreakpointLocation.i @@ -70,6 +70,29 @@ public: const char * GetCondition (); + %feature("docstring", " + //------------------------------------------------------------------ + /// Set the callback to the given Python function name. + //------------------------------------------------------------------ + ") SetScriptCallbackFunction; + void + SetScriptCallbackFunction (const char *callback_function_name); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Provide the body for the script function to be called when the breakpoint location is hit. + /// The body will be wrapped in a function, which be passed two arguments: + /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + /// + /// The error parameter is currently ignored, but will at some point hold the Python + /// compilation diagnostics. + /// Returns true if the body compiles successfully, false if not. + //------------------------------------------------------------------ + ") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + void SetThreadID (lldb::tid_t sb_thread_id); -- cgit v1.2.3