This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Eliminate user_settable_breakpoint, simplify breakpoint.c a bit (was: Re: [PATCH] Remove same-pc breakpoint notification for internal BPs)
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>, Kevin Pouget <kevin dot pouget at gmail dot com>
- Date: Thu, 21 Apr 2011 16:57:05 +0100
- Subject: Eliminate user_settable_breakpoint, simplify breakpoint.c a bit (was: Re: [PATCH] Remove same-pc breakpoint notification for internal BPs)
On Thursday 21 April 2011 16:27:20, Pedro Alves wrote:
> On Thursday 21 April 2011 16:05:30, Tom Tromey wrote:
> > >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
> >
> > Pedro> I never understood why we need that function (as is implemented) though.
> >
> > IIRC I added it to pull common code out of a few spots, and at the same
> > time regularize it. I think different spots were using slightly
> > different checks.
> >
> > I don't object to the current patch.
> >
> > Pedro> What could be !user_settable_breakpoint whose b->number is > 0?
> > Pedro> IOW, why isn't that just :
> > [...]
> >
> > I don't know; I think the change to introduce the function just
> > commonized pre-existing code.
>
> Yeah, user_settable_p, but I'm thinking further back than that.
>
> user_settable_breakpoint was introduced here:
>
> <http://sourceware.org/ml/gdb-patches/2001-06/msg00321.html>
>
> but it was a refactor. I looked at the sources of a gdb
> of around that time, and internal breakpoints with negative
> numbers already existed then.
>
> I looked further back. Looking at gdb 4.6's (1992) sources, gdb
> already had breakpoint types (bp_until, etc.) by then, but there's no
> decrementing `internal_breakpoint_number' yet, and the code
> Cagney's patch is refactoring out appears to be there already,
> in a more primitive form. `internal_breakpoint_number' appears to
> have been added circa 1996 (from ChangeLog).
>
> breakpoint_1, gdb 4.2:
>
> /* We only print out user settable breakpoints unless the allflag is set. */
> if (!allflag
> && b->type != bp_breakpoint
> && b->type != bp_watchpoint)
> continue;
>
> It looks like this grew as breakpoint types were added, but when
> `internal_breakpoint_number' was added, it was kept.
>
>
I'm giving this a test run. I think the b->number >= 0 checks
in e.g., "delete", were wrong in non-stop, as they could delete
momentary breakpoints behind infrun's/users' backs, as not
all momentary breakpoint types were being checked.
--
Pedro Alves
2011-04-21 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.c (user_settable_breakpoint): Delete.
(user_breakpoint_p): Remove check on user_settable_breakpoint.
(delete_command): Check user_breakpoint_p instead of looking at
the breakpoint's type.
(disable_command): Ditto.
(enable_command): Ditto.
(delete_trace_command): Use user_breakpoint_p instead of looking
at the breakpoint number directly. When checking if there are
user visible tracepoints, in order to know whether to ask the user
for confirmation, check whether the breakpoint is actually a
tracepoint.
---
gdb/breakpoint.c | 119 ++++++++++---------------------------------------------
1 file changed, 22 insertions(+), 97 deletions(-)
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2011-04-20 16:22:35.000000000 +0100
+++ src/gdb/breakpoint.c 2011-04-21 16:46:28.652163001 +0100
@@ -5150,27 +5150,13 @@ gdb_breakpoint_query (struct ui_out *uio
return GDB_RC_OK;
}
-/* Return non-zero if B is user settable (breakpoints, watchpoints,
- catchpoints, et.al.). */
-
-static int
-user_settable_breakpoint (const struct breakpoint *b)
-{
- return (b->type == bp_breakpoint
- || b->type == bp_catchpoint
- || b->type == bp_hardware_breakpoint
- || is_tracepoint (b)
- || is_watchpoint (b)
- || b->type == bp_gnu_ifunc_resolver);
-}
-
/* 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;
+ return b->number > 0;
}
/* Print information on user settable breakpoint (watchpoint, etc)
@@ -10582,45 +10568,23 @@ delete_command (char *arg, int from_tty)
{
int breaks_to_delete = 0;
- /* Delete all breakpoints if no argument.
- Do not delete internal or call-dummy breakpoints, these have
- to be deleted with an explicit breakpoint number argument. */
+ /* Delete all breakpoints if no argument. Do not delete
+ internal breakpoints, these have to be deleted with an
+ explicit breakpoint number argument. */
ALL_BREAKPOINTS (b)
- {
- if (b->type != bp_call_dummy
- && b->type != bp_std_terminate
- && b->type != bp_shlib_event
- && b->type != bp_jit_event
- && b->type != bp_thread_event
- && b->type != bp_overlay_event
- && b->type != bp_longjmp_master
- && b->type != bp_std_terminate_master
- && b->type != bp_exception_master
- && b->number >= 0)
+ if (user_breakpoint_p (b))
{
breaks_to_delete = 1;
break;
}
- }
/* Ask user only if there are some breakpoints to delete. */
if (!from_tty
|| (breaks_to_delete && query (_("Delete all breakpoints? "))))
{
ALL_BREAKPOINTS_SAFE (b, b_tmp)
- {
- if (b->type != bp_call_dummy
- && b->type != bp_std_terminate
- && b->type != bp_shlib_event
- && b->type != bp_thread_event
- && b->type != bp_jit_event
- && b->type != bp_overlay_event
- && b->type != bp_longjmp_master
- && b->type != bp_std_terminate_master
- && b->type != bp_exception_master
- && b->number >= 0)
+ if (user_breakpoint_p (b))
delete_breakpoint (b);
- }
}
}
else
@@ -11434,31 +11398,14 @@ do_map_disable_breakpoint (struct breakp
static void
disable_command (char *args, int from_tty)
{
- struct breakpoint *bpt;
-
if (args == 0)
- ALL_BREAKPOINTS (bpt)
- switch (bpt->type)
- {
- case bp_none:
- warning (_("attempted to disable apparently deleted breakpoint #%d?"),
- bpt->number);
- break;
- case bp_breakpoint:
- case bp_tracepoint:
- case bp_fast_tracepoint:
- case bp_static_tracepoint:
- case bp_catchpoint:
- case bp_hardware_breakpoint:
- case bp_watchpoint:
- case bp_hardware_watchpoint:
- case bp_read_watchpoint:
- case bp_access_watchpoint:
- disable_breakpoint (bpt);
- break;
- default:
- break;
- }
+ {
+ struct breakpoint *bpt;
+
+ ALL_BREAKPOINTS (bpt)
+ if (user_breakpoint_p (bpt))
+ disable_breakpoint (bpt);
+ }
else if (strchr (args, '.'))
{
struct bp_location *loc = find_location_by_number (args);
@@ -11536,31 +11483,14 @@ do_map_enable_breakpoint (struct breakpo
static void
enable_command (char *args, int from_tty)
{
- struct breakpoint *bpt;
-
if (args == 0)
- ALL_BREAKPOINTS (bpt)
- switch (bpt->type)
- {
- case bp_none:
- warning (_("attempted to enable apparently deleted breakpoint #%d?"),
- bpt->number);
- break;
- case bp_breakpoint:
- case bp_tracepoint:
- case bp_fast_tracepoint:
- case bp_static_tracepoint:
- case bp_catchpoint:
- case bp_hardware_breakpoint:
- case bp_watchpoint:
- case bp_hardware_watchpoint:
- case bp_read_watchpoint:
- case bp_access_watchpoint:
- enable_breakpoint (bpt);
- break;
- default:
- break;
- }
+ {
+ struct breakpoint *bpt;
+
+ ALL_BREAKPOINTS (bpt)
+ if (user_breakpoint_p (bpt))
+ enable_breakpoint (bpt);
+ }
else if (strchr (args, '.'))
{
struct bp_location *loc = find_location_by_number (args);
@@ -12103,24 +12033,19 @@ delete_trace_command (char *arg, int fro
have to be deleted with an explicit breakpoint number
argument. */
ALL_TRACEPOINTS (b)
- {
- if (b->number >= 0)
+ if (is_tracepoint (b) && user_breakpoint_p (b))
{
breaks_to_delete = 1;
break;
}
- }
/* Ask user only if there are some breakpoints to delete. */
if (!from_tty
|| (breaks_to_delete && query (_("Delete all tracepoints? "))))
{
ALL_BREAKPOINTS_SAFE (b, b_tmp)
- {
- if (is_tracepoint (b)
- && b->number >= 0)
+ if (is_tracepoint (b) && user_breakpoint_p (b))
delete_breakpoint (b);
- }
}
}
else