From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 552 invoked by alias); 23 Nov 2010 23:19:30 -0000 Received: (qmail 542 invoked by uid 22791); 23 Nov 2010 23:19:29 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Nov 2010 23:19:14 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id oANNJBxQ026759 for ; Tue, 23 Nov 2010 15:19:11 -0800 Received: from qyk10 (qyk10.prod.google.com [10.241.83.138]) by wpaz5.hot.corp.google.com with ESMTP id oANNIeNX002127 for ; Tue, 23 Nov 2010 15:19:10 -0800 Received: by qyk10 with SMTP id 10so2822411qyk.0 for ; Tue, 23 Nov 2010 15:19:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.11.74 with SMTP id s10mr7013818qas.48.1290554350496; Tue, 23 Nov 2010 15:19:10 -0800 (PST) Received: by 10.220.185.203 with HTTP; Tue, 23 Nov 2010 15:19:10 -0800 (PST) In-Reply-To: References: Date: Tue, 23 Nov 2010 23:19:00 -0000 Message-ID: Subject: Re: Python PR/12199 From: Doug Evans To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00382.txt.bz2 On Mon, Nov 15, 2010 at 9:27 AM, Phil Muldoon wrote: > > Hi, > > This patch allows users to delete a breakpoint from the Python API > (assuming that breakpoint type is tracked by the API). > > OK? Hi. This patch looks good to me. > > Cheers > > Phil > > -- > > 2010-11-15 =A0Phil Muldoon =A0 > > =A0 =A0 =A0 =A0PR python/12199 > > =A0 =A0 =A0 =A0* python/py-breakpoint.c (bppy_delete_breakpoint): New fun= ction. > > 2010-11-15 =A0Phil Muldoon =A0 > > =A0 =A0 =A0 =A0PR python/12199 > > =A0 =A0 =A0 =A0* gdb.python/py-breakpoint.exp: Test the delete method. > > 2010-11-15 =A0Phil Muldoon =A0 > > =A0 =A0 =A0 =A0PR python/12199 > > =A0 =A0 =A0 =A0* gdb.texinfo (Breakpoints In Python): Document "delete" m= ethod. > > -- > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index ddc711b..5ffbcb7 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -22887,6 +22887,12 @@ watchpoint scope, the watchpoint remains valid e= ven if execution of the > =A0inferior leaves the scope of that watchpoint. > =A0@end defmethod > > +@defmethod Breakpoint delete > +Permanently deletes the @value{GDBN} breakpoint. =A0This also > +invalidates the Python @code{Breakpoint} object. =A0Any further access > +to this object's attributes or methods will raise an error. > +@end defmethod > + > =A0@defivar Breakpoint enabled > =A0This attribute is @code{True} if the breakpoint is enabled, and > =A0@code{False} otherwise. =A0This attribute is writable. > diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c > index 8afa414..742c702 100644 > --- a/gdb/python/py-breakpoint.c > +++ b/gdb/python/py-breakpoint.c > @@ -630,6 +630,22 @@ bppy_new (PyTypeObject *subtype, PyObject *args, PyO= bject *kwargs) > =A0 return result; > =A0} > > +/* Python function which deletes the underlying GDB breakpoint. =A0This > + =A0 triggers the breakpoint_deleted observer which will call > + =A0 gdbpy_breakpoint_deleted; that function cleans up the Python > + =A0 sections. =A0*/ > + > +static PyObject * > +bppy_delete_breakpoint (PyObject *self, PyObject *args) > +{ > + =A0breakpoint_object *self_bp =3D (breakpoint_object *) self; > + > + =A0BPPY_REQUIRE_VALID (self_bp); > + > + =A0delete_breakpoint (self_bp->bp); > + > + =A0Py_RETURN_NONE; > +} > + > > =A0static int > @@ -843,6 +859,8 @@ static PyMethodDef breakpoint_object_methods[] =3D > =A0{ > =A0 { "is_valid", bppy_is_valid, METH_NOARGS, > =A0 =A0 "Return true if this breakpoint is valid, false if not." }, > + =A0{ "delete", bppy_delete_breakpoint, METH_NOARGS, > + =A0 =A0"Delete the underlying GDB breakpoint." }, > =A0 { NULL } /* Sentinel. =A0*/ > =A0}; > > diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/g= db.python/py-breakpoint.exp > index d030b55..34a64a3 100644 > --- a/gdb/testsuite/gdb.python/py-breakpoint.exp > +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp > @@ -91,6 +91,29 @@ if ![runto_main] then { > =A0 =A0 return 0 > =A0} > > +# 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 =A0"python dp1 =3D gdb.Breakpoint (\"$deltst_loca= tion\")" "Set breakpoint" 0 > +gdb_breakpoint [gdb_get_line_number "Break at end."] > +gdb_py_test_silent_cmd "python del_list =3D gdb.breakpoints()" "Get Brea= kpoint List" 0 > +gdb_test "python print len(del_list)" "3" "Number of breakpoints before = delete" > +gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$deltst_loc= ation.*" > +gdb_py_test_silent_cmd =A0"python dp1.delete()" "Delete Breakpoint" 0 > +gdb_test "python print dp1.number" "RuntimeError: Breakpoint 2 is invali= d.*" "Check breakpoint invalidated" > +gdb_py_test_silent_cmd "python del_list =3D gdb.breakpoints()" "Get Brea= kpoint List" 0 > +gdb_test "python print len(del_list)" "2" "Number of breakpoints after d= elete" > +gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*" > + > + > +# Start with a fresh gdb. > +clean_restart ${testfile} > + > +if ![runto_main] then { > + =A0 =A0fail "Cannot run to main." > + =A0 =A0return 0 > +} > + > =A0# Test conditional setting. > =A0set bp_location1 [gdb_get_line_number "Break at multiply."] > =A0gdb_py_test_silent_cmd =A0"python bp1 =3D gdb.Breakpoint (\"$bp_locati= on1\")" "Set breakpoint" 0 >