This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[6/6] make catchpoints a bit more OO: finish construction vs installation/broadcasting split
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 20 Jun 2011 21:25:23 +0100
- Subject: [6/6] make catchpoints a bit more OO: finish construction vs installation/broadcasting split
And this finishes the split between breakpoint construction
and new breakpoint installation/broadcasting. The init_...
routines no longer touch the global breakpoint chain after this.
(install_catchpoint is the function to make public to be able
to create catchpoints outside breakpoint.c)
Pedro Alves
2011-06-20 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.c (init_raw_breakpoint_without_location): Don't add
the breakpoint to the breakpoint chain here.
(set_raw_breakpoint_without_location): Add the breakpoint to the
breakpoint chain here.
(init_raw_breakpoint): Adjust comments.
(set_raw_breakpoint): Add the breakpoint to the breakpoint chain
here.
(init_catchpoint): Don't set the catchpoint's breakpoint number
here.
(install_catchpoint): New function.
(create_fork_vfork_event_catchpoint)
(create_syscall_event_catchpoint, catch_exec_command_1): Adjust to
use install_catchpoint.
---
gdb/breakpoint.c | 47 +++++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 26 deletions(-)
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2011-06-20 21:03:16.000000000 +0100
+++ src/gdb/breakpoint.c 2011-06-20 21:03:47.135403785 +0100
@@ -5830,8 +5830,6 @@ init_raw_breakpoint_without_location (st
b->condition_not_parsed = 0;
b->py_bp_object = NULL;
b->related_breakpoint = b;
-
- add_to_breakpoint_chain (b);
}
/* Helper to set_raw_breakpoint below. Creates a breakpoint
@@ -5846,7 +5844,7 @@ set_raw_breakpoint_without_location (str
struct breakpoint *b = XNEW (struct breakpoint);
init_raw_breakpoint_without_location (b, gdbarch, bptype);
-
+ add_to_breakpoint_chain (b);
return b;
}
@@ -5909,17 +5907,11 @@ get_sal_arch (struct symtab_and_line sal
/* Low level routine for partially initializing a breakpoint of type
BPTYPE. The newly created breakpoint's address, section, source
- file name, and line number are provided by SAL. The newly created
- and partially initialized breakpoint is added to the breakpoint
- chain.
+ file name, and line number are provided by SAL.
It is expected that the caller will complete the initialization of
the newly created breakpoint struct as well as output any status
- information regarding the creation of a new breakpoint. In
- particular, init_raw_breakpoint does NOT set the breakpoint number!
- Care should be taken to not allow an error to occur prior to
- completing the initialization of the breakpoint. If this should
- happen, a bogus breakpoint will be left on the chain. */
+ information regarding the creation of a new breakpoint. */
static void
init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch,
@@ -5991,6 +5983,7 @@ set_raw_breakpoint (struct gdbarch *gdba
struct breakpoint *b = XNEW (struct breakpoint);
init_raw_breakpoint (b, gdbarch, sal, bptype);
+ add_to_breakpoint_chain (b);
return b;
}
@@ -6862,8 +6855,6 @@ init_catchpoint (struct breakpoint *b,
sal.pspace = current_program_space;
init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint);
- set_breakpoint_count (breakpoint_count + 1);
- b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
b->thread = -1;
@@ -6873,6 +6864,20 @@ init_catchpoint (struct breakpoint *b,
b->ops = ops;
}
+/* Add breakpoint B on the breakpoint list, and notify the user, the
+ target and breakpoint_created observers of its existence. */
+
+static void
+install_catchpoint (struct breakpoint *b)
+{
+ add_to_breakpoint_chain (b);
+ set_breakpoint_count (breakpoint_count + 1);
+ b->number = breakpoint_count;
+ mention (b);
+ observer_notify_breakpoint_created (b);
+ update_global_location_list (1);
+}
+
static void
create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
int tempflag, char *cond_string,
@@ -6884,9 +6889,7 @@ create_fork_vfork_event_catchpoint (stru
c->forked_inferior_pid = null_ptid;
- mention (&c->base);
- observer_notify_breakpoint_created (&c->base);
- update_global_location_list (1);
+ install_catchpoint (&c->base);
}
/* Exec catchpoints. */
@@ -7020,11 +7023,7 @@ create_syscall_event_catchpoint (int tem
init_catchpoint (&c->base, gdbarch, tempflag, NULL, ops);
c->syscalls_to_be_caught = filter;
- /* Now, we have to mention the breakpoint and update the global
- location list. */
- mention (&c->base);
- observer_notify_breakpoint_created (&c->base);
- update_global_location_list (1);
+ install_catchpoint (&c->base);
}
static int
@@ -9855,11 +9854,7 @@ catch_exec_command_1 (char *arg, int fro
&catch_exec_breakpoint_ops);
c->exec_pathname = NULL;
- /* Now, we have to mention the breakpoint and update the global
- location list. */
- mention (&c->base);
- observer_notify_breakpoint_created (&c->base);
- update_global_location_list (1);
+ install_catchpoint (&c->base);
}
static enum print_stop_action