2011-03-14 Phil Muldoon <pmuldoon@redhat.com>

* gdb.texinfo (Breakpoints In Python): Add description and
              example
	      of Python stop function operation.

2010-03-14  Phil Muldoon  <pmuldoon@redhat.com>

	    * gdb.python/py-breakpoint.exp: Add Python stop operations
              tests.

2011-03-14  Phil Muldoon  <pmuldoon@redhat.com>

	    * python/python.h: Declare gdbpy_should_stop and
	    gdbpy_breakpoint_has_py_cond.
	    * python/python.c: Add python.h to includes.  Remove
	    python.h from
	    HAVE_PYTHON definition
	    (gdbpy_should_stop): New dummy function.
	    (gdbpy_breakpoint_has_py_cond): New dummy function.
	    * python/py-breakpoint.c (bppy_init): Rewrite to allow
	    sub-classing capabilities.
	    (gdbpy_should_stop): New function.
	    (gdbpy_breakpoint_has_py_cond): New function.
	    (local_setattro): New function.
	    * breakpoint.c (condition_command): Add check for Python
	    'stop'
	    operation.
	    (bpstat_check_breakpoint_conditions): Execute Python
	    'stop'
	    operation function as part of stop/continue tests.
This commit is contained in:
Phil Muldoon
2011-03-14 16:09:55 +00:00
parent 34e77a920a
commit 7371cf6d8d
9 changed files with 312 additions and 20 deletions

View File

@@ -1,3 +1,9 @@
2011-03-14 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Breakpoints In Python): Add description and example
of Python stop function operation.
2011-03-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Parameters In Python): Document get_set_string and

View File

@@ -23115,6 +23115,34 @@ argument defines the class of watchpoint to create, if @var{type} is
assumed to be a @var{WP_WRITE} class.
@end defmethod
@defop Operation {gdb.Breakpoint} stop (self)
The @code{gdb.Breakpoint} class can be sub-classed and, in
particular, you may choose to implement the @code{stop} method.
If this method is defined as a sub-class of @code{gdb.Breakpoint},
it will be called when the inferior reaches any location of a
breakpoint which instantiates that sub-class. If the method returns
@code{True}, the inferior will be stopped at the location of the
breakpoint, otherwise the inferior will continue.
If there are multiple breakpoints at the same location with a
@code{stop} method, each one will be called regardless of the
return status of the previous. This ensures that all @code{stop}
methods have a chance to execute at that location. In this scenario
if one of the methods returns @code{True} but the others return
@code{False}, the inferior will still be stopped.
Example @code{stop} implementation:
@smallexample
class MyBreakpoint (gdb.Breakpoint):
def stop (self):
inf_val = gdb.parse_and_eval("foo")
if inf_val == 3:
return True
return False
@end smallexample
@end defop
The available watchpoint types represented by constants are defined in the
@code{gdb} module: