diff mbox

[RFA,2/3] use user_breakpoint_p in python code

Message ID 1463695563-4130-3-git-send-email-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey May 19, 2016, 10:06 p.m. UTC
I noticed that bppy_get_visibility and gdbpy_breakpoint_created
implemented their own visibility checks, but subtly different from
user_breakpoint_p.  I think the latter is more correct, and so changed
the Python code to use it.

I suspect there isn't a decent way to test this, so no new test.

Built and regtested on x86-64 Fedora 23.

2016-05-19  Tom Tromey  <tom@tromey.com>

	* python/py-breakpoint.c (bppy_get_visibility)
	(gdbpy_breakpoint_created): Use user_breakpoint_p.
---
 gdb/ChangeLog              | 5 +++++
 gdb/python/py-breakpoint.c | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Phil Muldoon May 20, 2016, 2:30 p.m. UTC | #1
On 19/05/16 23:06, Tom Tromey wrote:
> I noticed that bppy_get_visibility and gdbpy_breakpoint_created
> implemented their own visibility checks, but subtly different from
> user_breakpoint_p.  I think the latter is more correct, and so changed
> the Python code to use it.
> 
> I suspect there isn't a decent way to test this, so no new test.
> 
> Built and regtested on x86-64 Fedora 23.
> 
> 2016-05-19  Tom Tromey  <tom@tromey.com>
> 
> 	* python/py-breakpoint.c (bppy_get_visibility)
> 	(gdbpy_breakpoint_created): Use user_breakpoint_p.
> ---
>  gdb/ChangeLog              | 5 +++++
>  gdb/python/py-breakpoint.c | 8 ++++----
>  2 files changed, 9 insertions(+), 4 deletions(-)

Looks good to me!

Cheers

Phil
Yao Qi July 13, 2016, 8:09 a.m. UTC | #2
Tom Tromey <tom@tromey.com> writes:

> 2016-05-19  Tom Tromey  <tom@tromey.com>
>
> 	* python/py-breakpoint.c (bppy_get_visibility)
> 	(gdbpy_breakpoint_created): Use user_breakpoint_p.

It is OK.
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0968b85..a03d290 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2016-05-19  Tom Tromey  <tom@tromey.com>
+
+	* python/py-breakpoint.c (bppy_get_visibility)
+	(gdbpy_breakpoint_created): Use user_breakpoint_p.
+
 2016-05-19  Andreas Schwab  <schwab@suse.de>
 
 	* ia64-libunwind-tdep.c (libunwind_descr): Add cast from void *.
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 611a41e..f86da8d 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -540,10 +540,10 @@  bppy_get_visibility (PyObject *self, void *closure)
 
   BPPY_REQUIRE_VALID (self_bp);
 
-  if (self_bp->bp->number < 0)
-    Py_RETURN_FALSE;
+  if (user_breakpoint_p (self_bp->bp))
+    Py_RETURN_TRUE;
 
-  Py_RETURN_TRUE;
+  Py_RETURN_FALSE;
 }
 
 /* Python function to determine if the breakpoint is a temporary
@@ -862,7 +862,7 @@  gdbpy_breakpoint_created (struct breakpoint *bp)
   gdbpy_breakpoint_object *newbp;
   PyGILState_STATE state;
 
-  if (bp->number < 0 && bppy_pending_object == NULL)
+  if (!user_breakpoint_p (bp) && bppy_pending_object == NULL)
     return;
 
   if (bp->type != bp_breakpoint