public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: add user_breakpoint_p
@ 2011-01-28  5:52 Tom Tromey
  2011-01-31  2:10 ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2011-01-28  5:52 UTC (permalink / raw)
  To: gdb-patches

I am planning to check this in.

I needed a `user_breakpoint_p' function for async breakpoint
notifications in MI.  While writing this, I noticed similar code in
breakpoint.c, so this patch introduces the function and changes
everyplace to use it.

There was some inconsistency about whether the test should be ">= 0"
or "> 0".  The latter seems more correct to me, since I think user
breakpoints always begin with 1.

Built and regtested on x86-64 (compile farm).

Tom

2011-01-27  Tom Tromey  <tromey@redhat.com>

	* breakpoint.h (user_breakpoint_p): Declare.
	* breakpoint.c (user_breakpoint_p): New function.
	(breakpoint_1): Use it.
	(save_breakpoints): Likewise.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8d0692b..c7a6484 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5064,6 +5064,15 @@ user_settable_breakpoint (const struct breakpoint *b)
 	  || is_watchpoint (b));
 }
 
+/* Return true if this breakpoint was set by the user, false if it is
+   internal or momentary.  */
+
+int
+user_breakpoint_p (struct breakpoint *b)
+{
+  return user_settable_breakpoint (b) && b->number > 0;
+}
+
 /* Print information on user settable breakpoint (watchpoint, etc)
    number BNUM.  If BNUM is -1 print all user-settable breakpoints.
    If ALLFLAG is non-zero, include non-user-settable breakpoints.  If
@@ -5096,8 +5105,7 @@ breakpoint_1 (int bnum, int allflag,
 	if (filter && !filter (b))
 	  continue;
 	
-	if (allflag || (user_settable_breakpoint (b)
-			&& b->number > 0))
+	if (allflag || user_breakpoint_p (b))
 	  {
 	    int addr_bit, type_len;
 
@@ -5169,8 +5177,7 @@ breakpoint_1 (int bnum, int allflag,
 	
 	/* We only print out user settable breakpoints unless the
 	   allflag is set.  */
-	if (allflag || (user_settable_breakpoint (b)
-			&& b->number > 0))
+	if (allflag || user_breakpoint_p (b))
 	  print_one_breakpoint (b, &last_loc, print_address_bits, allflag);
       }
   }
@@ -11727,7 +11734,7 @@ save_breakpoints (char *filename, int from_tty,
   ALL_BREAKPOINTS (tp)
   {
     /* Skip internal and momentary breakpoints.  */
-    if (!user_settable_breakpoint (tp) || tp->number < 0)
+    if (! user_breakpoint_p (tp))
       continue;
 
     /* If we have a filter, only save the breakpoints it accepts.  */
@@ -11765,7 +11772,7 @@ save_breakpoints (char *filename, int from_tty,
   ALL_BREAKPOINTS (tp)
   {
     /* Skip internal and momentary breakpoints.  */
-    if (!user_settable_breakpoint (tp) || tp->number < 0)
+    if (! user_breakpoint_p (tp))
       continue;
 
     /* If we have a filter, only save the breakpoints it accepts.  */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 69598a7..6eed2cd 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1184,4 +1184,6 @@ extern void end_rbreak_breakpoints (void);
 extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint *,
 							     void *), void *);
 
+extern int user_breakpoint_p (struct breakpoint *);
+
 #endif /* !defined (BREAKPOINT_H) */

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

* Re: FYI: add user_breakpoint_p
  2011-01-28  5:52 FYI: add user_breakpoint_p Tom Tromey
@ 2011-01-31  2:10 ` Joel Brobecker
  2011-01-31 15:11   ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2011-01-31  2:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> 2011-01-27  Tom Tromey  <tromey@redhat.com>
> 
> 	* breakpoint.h (user_breakpoint_p): Declare.
> 	* breakpoint.c (user_breakpoint_p): New function.
> 	(breakpoint_1): Use it.
> 	(save_breakpoints): Likewise.

I love these little cleanups :-).

Just one question about style:

> -    if (!user_settable_breakpoint (tp) || tp->number < 0)
> +    if (! user_breakpoint_p (tp))

Do we agree on whether to write this as the above, or whether we should
not have a space between the '!' and the expression being negated:

   if (! user_breakpoint_p (tp))

?

I did a rough count, and currently we have a bout 500 instance with the
space, and 2800 without...

-- 
Joel

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

* Re: FYI: add user_breakpoint_p
  2011-01-31  2:10 ` Joel Brobecker
@ 2011-01-31 15:11   ` Tom Tromey
  2011-02-01  3:05     ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2011-01-31 15:11 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> Just one question about style:

>> -    if (!user_settable_breakpoint (tp) || tp->number < 0)
>> +    if (! user_breakpoint_p (tp))

Joel> Do we agree on whether to write this as the above, or whether we should
Joel> not have a space between the '!' and the expression being negated:

I have trouble remembering whether we have a rule here.
I will remove the space.  It doesn't matter to me either way if we have
it or not.

Tom

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

* Re: FYI: add user_breakpoint_p
  2011-01-31 15:11   ` Tom Tromey
@ 2011-02-01  3:05     ` Joel Brobecker
  2011-02-01 14:31       ` Tom Tromey
  2011-02-01 15:21       ` Pedro Alves
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2011-02-01  3:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> >> -    if (!user_settable_breakpoint (tp) || tp->number < 0)
> >> +    if (! user_breakpoint_p (tp))
> 
> Joel> Do we agree on whether to write this as the above, or whether we should
> Joel> not have a space between the '!' and the expression being negated:
> 
> I have trouble remembering whether we have a rule here.
> I will remove the space.  It doesn't matter to me either way if we have
> it or not.

It doesn't matter to me either way, althought I have a slight preference
for no space.  I'd like us to agree and make a "soft" recommendation on
my wiki page about the GDB Coding Style.

-- 
Joel

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

* Re: FYI: add user_breakpoint_p
  2011-02-01  3:05     ` Joel Brobecker
@ 2011-02-01 14:31       ` Tom Tromey
  2011-02-01 15:21       ` Pedro Alves
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2011-02-01 14:31 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> It doesn't matter to me either way, althought I have a slight preference
Joel> for no space.  I'd like us to agree and make a "soft" recommendation on
Joel> my wiki page about the GDB Coding Style.

Go for it.

Tom

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

* Re: FYI: add user_breakpoint_p
  2011-02-01  3:05     ` Joel Brobecker
  2011-02-01 14:31       ` Tom Tromey
@ 2011-02-01 15:21       ` Pedro Alves
  2011-02-02 14:42         ` Tom Tromey
  1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2011-02-01 15:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker, Tom Tromey

On Tuesday 01 February 2011 03:05:44, Joel Brobecker wrote:
> > >> -    if (!user_settable_breakpoint (tp) || tp->number < 0)
> > >> +    if (! user_breakpoint_p (tp))
> > 
> > Joel> Do we agree on whether to write this as the above, or whether we should
> > Joel> not have a space between the '!' and the expression being negated:
> > 
> > I have trouble remembering whether we have a rule here.
> > I will remove the space.  It doesn't matter to me either way if we have
> > it or not.
> 
> It doesn't matter to me either way, althought I have a slight preference
> for no space.  I'd like us to agree and make a "soft" recommendation on
> my wiki page about the GDB Coding Style.

I still have in my queue to post a patch per:

 <http://sourceware.org/ml/gdb-patches/2010-11/msg00121.html>

If you guys are still okay with it, I'll bump it close to the
the top of my today's TODO.  (I'm okay with having this in
the wiki as well).

-- 
Pedro Alves

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

* Re: FYI: add user_breakpoint_p
  2011-02-01 15:21       ` Pedro Alves
@ 2011-02-02 14:42         ` Tom Tromey
  2011-02-03  4:59           ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2011-02-02 14:42 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker

Pedro> I still have in my queue to post a patch per:
Pedro>  <http://sourceware.org/ml/gdb-patches/2010-11/msg00121.html>
Pedro> If you guys are still okay with it, I'll bump it close to the
Pedro> the top of my today's TODO.  (I'm okay with having this in
Pedro> the wiki as well).

It seems like a good idea to me.

Tom

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

* Re: FYI: add user_breakpoint_p
  2011-02-02 14:42         ` Tom Tromey
@ 2011-02-03  4:59           ` Joel Brobecker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2011-02-03  4:59 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

> Pedro> I still have in my queue to post a patch per:
> Pedro>  <http://sourceware.org/ml/gdb-patches/2010-11/msg00121.html>
> Pedro> If you guys are still okay with it, I'll bump it close to the
> Pedro> the top of my today's TODO.  (I'm okay with having this in
> Pedro> the wiki as well).
> 
> It seems like a good idea to me.

Me too.

-- 
Joel

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

end of thread, other threads:[~2011-02-03  4:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28  5:52 FYI: add user_breakpoint_p Tom Tromey
2011-01-31  2:10 ` Joel Brobecker
2011-01-31 15:11   ` Tom Tromey
2011-02-01  3:05     ` Joel Brobecker
2011-02-01 14:31       ` Tom Tromey
2011-02-01 15:21       ` Pedro Alves
2011-02-02 14:42         ` Tom Tromey
2011-02-03  4:59           ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).