Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Python PR/12199
@ 2010-11-15 17:27 Phil Muldoon
  2010-11-23 23:19 ` Doug Evans
  0 siblings, 1 reply; 5+ messages in thread
From: Phil Muldoon @ 2010-11-15 17:27 UTC (permalink / raw)
  To: gdb-patches


Hi,

This patch allows users to delete a breakpoint from the Python API
(assuming that breakpoint type is tracked by the API).

OK?

Cheers

Phil

--

2010-11-15  Phil Muldoon  <pmuldoon@redhat.com>

        PR python/12199

	* python/py-breakpoint.c (bppy_delete_breakpoint): New function.

2010-11-15  Phil Muldoon  <pmuldoon@redhat.com>

        PR python/12199

	* gdb.python/py-breakpoint.exp: Test the delete method.

2010-11-15  Phil Muldoon  <pmuldoon@redhat.com>

        PR python/12199

	* gdb.texinfo (Breakpoints In Python): Document "delete" method.

--

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 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 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, PyObject *kwargs)
   return result;
 }
 
+/* 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;
+}
+
 
 static int
@@ -843,6 +859,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/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.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 {
     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}
+
+if ![runto_main] then {
+    fail "Cannot run to main."
+    return 0
+}
+
 # Test conditional setting.
 set bp_location1 [gdb_get_line_number "Break at multiply."]
 gdb_py_test_silent_cmd  "python bp1 = gdb.Breakpoint (\"$bp_location1\")" "Set breakpoint" 0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python PR/12199
  2010-11-15 17:27 Python PR/12199 Phil Muldoon
@ 2010-11-23 23:19 ` Doug Evans
  2010-11-24 10:10   ` Phil Muldoon
  2010-11-29 15:55   ` Phil Muldoon
  0 siblings, 2 replies; 5+ messages in thread
From: Doug Evans @ 2010-11-23 23:19 UTC (permalink / raw)
  To: pmuldoon; +Cc: gdb-patches

On Mon, Nov 15, 2010 at 9:27 AM, Phil Muldoon <pmuldoon@redhat.com> 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  Phil Muldoon  <pmuldoon@redhat.com>
>
>        PR python/12199
>
>        * python/py-breakpoint.c (bppy_delete_breakpoint): New function.
>
> 2010-11-15  Phil Muldoon  <pmuldoon@redhat.com>
>
>        PR python/12199
>
>        * gdb.python/py-breakpoint.exp: Test the delete method.
>
> 2010-11-15  Phil Muldoon  <pmuldoon@redhat.com>
>
>        PR python/12199
>
>        * gdb.texinfo (Breakpoints In Python): Document "delete" method.
>
> --
>
> 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 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 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, PyObject *kwargs)
>   return result;
>  }
>
> +/* 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;
> +}
> +
>
>  static int
> @@ -843,6 +859,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/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.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 {
>     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}
> +
> +if ![runto_main] then {
> +    fail "Cannot run to main."
> +    return 0
> +}
> +
>  # Test conditional setting.
>  set bp_location1 [gdb_get_line_number "Break at multiply."]
>  gdb_py_test_silent_cmd  "python bp1 = gdb.Breakpoint (\"$bp_location1\")" "Set breakpoint" 0
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python PR/12199
  2010-11-23 23:19 ` Doug Evans
@ 2010-11-24 10:10   ` Phil Muldoon
  2010-11-24 11:30     ` Eli Zaretskii
  2010-11-29 15:55   ` Phil Muldoon
  1 sibling, 1 reply; 5+ messages in thread
From: Phil Muldoon @ 2010-11-24 10:10 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches, eliz

Doug Evans <dje@google.com> writes:

> On Mon, Nov 15, 2010 at 9:27 AM, Phil Muldoon <pmuldoon@redhat.com> 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.
>

Oops I forgot about this one.  Doco review ping.

Cheers,

Phil


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python PR/12199
  2010-11-24 10:10   ` Phil Muldoon
@ 2010-11-24 11:30     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2010-11-24 11:30 UTC (permalink / raw)
  To: pmuldoon; +Cc: dje, gdb-patches

> From: Phil Muldoon <pmuldoon@redhat.com>
> Cc: gdb-patches@sourceware.org, eliz@gnu.org
> Reply-to: pmuldoon@redhat.com
> Date: Wed, 24 Nov 2010 10:09:49 +0000
> 
> Doug Evans <dje@google.com> writes:
> 
> > On Mon, Nov 15, 2010 at 9:27 AM, Phil Muldoon <pmuldoon@redhat.com> 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.
> >
> 
> Oops I forgot about this one.  Doco review ping.

Perhaps in the future patches that introduce new features could have
somewhat more descriptive Subject lines. ;-)  This one tells me that
some obscure Python related bug is being fixed.  It is easy to skip
such messages, especially when you are in a hurry.  Sorry.

Anyway, the doco patch is OK.  Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python PR/12199
  2010-11-23 23:19 ` Doug Evans
  2010-11-24 10:10   ` Phil Muldoon
@ 2010-11-29 15:55   ` Phil Muldoon
  1 sibling, 0 replies; 5+ messages in thread
From: Phil Muldoon @ 2010-11-29 15:55 UTC (permalink / raw)
  To: Doug Evans, eliz; +Cc: gdb-patches

Doug Evans <dje@google.com> writes:

> On Mon, Nov 15, 2010 at 9:27 AM, Phil Muldoon <pmuldoon@redhat.com> wrote:
>>
>> Hi,
>>
>> This patch allows users to delete a breakpoint from the Python API
>> (assuming that breakpoint type is tracked by the API).
>>
>> OK?

Doug Evans <dje@google.com> writes:

> This patch looks good to me.

Eli Zaretskii <eliz@gnu.org> writes:


> Anyway, the doco patch is OK.  Thanks.

So committed, thanks.

Cheers,

Phil


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-29 15:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-15 17:27 Python PR/12199 Phil Muldoon
2010-11-23 23:19 ` Doug Evans
2010-11-24 10:10   ` Phil Muldoon
2010-11-24 11:30     ` Eli Zaretskii
2010-11-29 15:55   ` Phil Muldoon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox