[Lldb-commits] [lldb] r181866 - <rdar://problem/13883385>

Enrico Granata egranata at apple.com
Tue May 14 19:46:08 PDT 2013


Author: enrico
Date: Tue May 14 21:46:08 2013
New Revision: 181866

URL: http://llvm.org/viewvc/llvm-project?rev=181866&view=rev
Log:
<rdar://problem/13883385>

Python breakpoint actions can return False to say that they don't want to stop at the breakpoint to which they are associated
Almost all of the work to support this notion of a breakpoint callback was in place, but two small moving parts were missing:
a) the SWIG wrapper was not checking the return value of the script
b) when passing a Python function by name, the call statement was dropping the return value of the function
This checkin addresses both concerns and makes this work
Care has been taken that you only keep running when an actual value of False has been returned, and that any other value (None included) means Stop!


Modified:
    lldb/trunk/scripts/Python/python-wrapper.swig
    lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp

Modified: lldb/trunk/scripts/Python/python-wrapper.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=181866&r1=181865&r2=181866&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-wrapper.swig (original)
+++ lldb/trunk/scripts/Python/python-wrapper.swig Tue May 14 21:46:08 2013
@@ -151,6 +151,10 @@ LLDBSwigPythonBreakpointCallbackFunction
                 
                 if (pvalue != NULL)
                 {
+                    // be very conservative here and only refuse to stop if the user
+                    // actually returned False - anything else, just stop
+                    if (pvalue == Py_False)
+                        stop_at_breakpoint = false;
                     Py_DECREF (pvalue);
                 }
                 else if (PyErr_Occurred ())

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=181866&r1=181865&r2=181866&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue May 14 21:46:08 2013
@@ -581,7 +581,8 @@ protected:
                         // what the user would do manually: make their breakpoint command be a function call
                         else if (m_options.m_function_name.size())
                         {
-                            std::string oneliner(m_options.m_function_name);
+                            std::string oneliner("return ");
+                            oneliner += m_options.m_function_name;
                             oneliner += "(frame, bp_loc, internal_dict)";
                             m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
                                                                                                 oneliner.c_str());





More information about the lldb-commits mailing list