From: Phil Muldoon Date: Mon, 29 Nov 2010 13:49:05 +0000 (+0000) Subject: 2010-11-29 Phil Muldoon X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=94b6973efeb6d14a07e90ef5013c506efec59320;hp=950386c651f7a852fe7e1215d7481caf7f2c91d0;p=deliverable%2Fbinutils-gdb.git 2010-11-29 Phil Muldoon PR python/12199 * python/py-breakpoint.c (bppy_delete_breakpoint): New function. 2010-11-29 Phil Muldoon PR python/12199 * gdb.python/py-breakpoint.exp: Test the delete method. 2010-11-29 Phil Muldoon PR python/12199 * gdb.texinfo (Breakpoints In Python): Document "delete" method. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a7aa825bf8..51961a3952 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2010-11-29 Phil Muldoon + + PR python/12199 + + * python/py-breakpoint.c (bppy_delete_breakpoint): New function. + 2010-11-28 Jan Kratochvil Fix step_resume_breakpoint unsaved during an infcall. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index dd00d1a9ab..df2449a87f 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2010-11-29 Phil Muldoon + + PR python/12199 + + * gdb.texinfo (Breakpoints In Python): Document "delete" method. + 2010-11-23 Tom Tromey * gdb.texinfo (Top): Check SYSTEM_READLINE. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5550f516ce..28ea55d645 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22911,6 +22911,12 @@ watchpoint scope, the watchpoint remains valid even if execution of the inferior leaves the scope of that watchpoint. @end defmethod +@defmethod Breakpoint delete +Permanently deletes the @value{GDBN} breakpoint. This also +invalidates the Python @code{Breakpoint} object. Any further access +to this object's attributes or methods will raise an error. +@end defmethod + @defivar Breakpoint enabled This attribute is @code{True} if the breakpoint is enabled, and @code{False} otherwise. This attribute is writable. diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 64e30ef0ea..88d99306dd 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -283,6 +283,23 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) return 0; } +/* Python function which deletes the underlying GDB breakpoint. This + triggers the breakpoint_deleted observer which will call + gdbpy_breakpoint_deleted; that function cleans up the Python + sections. */ + +static PyObject * +bppy_delete_breakpoint (PyObject *self, PyObject *args) +{ + breakpoint_object *self_bp = (breakpoint_object *) self; + + BPPY_REQUIRE_VALID (self_bp); + + delete_breakpoint (self_bp->bp); + + Py_RETURN_NONE; +} + /* Python function to set the ignore count of a breakpoint. */ static int @@ -843,6 +860,8 @@ static PyMethodDef breakpoint_object_methods[] = { { "is_valid", bppy_is_valid, METH_NOARGS, "Return true if this breakpoint is valid, false if not." }, + { "delete", bppy_delete_breakpoint, METH_NOARGS, + "Delete the underlying GDB breakpoint." }, { NULL } /* Sentinel. */ }; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e1cd9bb518..22c34768c1 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-11-29 Phil Muldoon + + PR python/12199 + + * gdb.python/py-breakpoint.exp: Test the delete method. + 2010-11-28 Jan Kratochvil Fix step_resume_breakpoint unsaved during an infcall. diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index d030b550ed..34a64a3706 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -83,6 +83,29 @@ gdb_test "python print blist\[0\].number" "1" "Check breakpoint number" gdb_test "python print blist\[1\].number" "2" "Check breakpoint number" gdb_test "python print blist\[2\].number" "3" "Check breakpoint number" +# Start with a fresh gdb. +clean_restart ${testfile} + +if ![runto_main] then { + fail "Cannot run to main." + return 0 +} + +# Test breakpoints are deleted correctly. +set deltst_location [gdb_get_line_number "Break at multiply."] +set end_location [gdb_get_line_number "Break at end."] +gdb_py_test_silent_cmd "python dp1 = gdb.Breakpoint (\"$deltst_location\")" "Set breakpoint" 0 +gdb_breakpoint [gdb_get_line_number "Break at end."] +gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" "Get Breakpoint List" 0 +gdb_test "python print len(del_list)" "3" "Number of breakpoints before delete" +gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$deltst_location.*" +gdb_py_test_silent_cmd "python dp1.delete()" "Delete Breakpoint" 0 +gdb_test "python print dp1.number" "RuntimeError: Breakpoint 2 is invalid.*" "Check breakpoint invalidated" +gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" "Get Breakpoint List" 0 +gdb_test "python print len(del_list)" "2" "Number of breakpoints after delete" +gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*" + + # Start with a fresh gdb. clean_restart ${testfile}