2011-06-22 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 5fc45621fb1327710463c9855fa5e0dc9a9dd31d..a3e89c2039b9e9ddb8d77fcaa745e4080c9a08d1 100644 (file)
@@ -5830,8 +5830,6 @@ init_raw_breakpoint_without_location (struct breakpoint *b,
   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 (struct gdbarch *gdbarch,
   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 *gdbarch,
   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,46 +6864,18 @@ init_catchpoint (struct breakpoint *b,
   b->ops = ops;
 }
 
-/* Create a new breakpoint of the bp_catchpoint kind and return it,
-   but does NOT mention it nor update the global location list.
-   This is useful if you need to fill more fields in the
-   struct breakpoint before calling mention.
+/* Add breakpoint B on the breakpoint list, and notify the user, the
+   target and breakpoint_created observers of its existence.  */
 
-   If TEMPFLAG is non-zero, then make the breakpoint temporary.
-   If COND_STRING is not NULL, then store it in the breakpoint.
-   OPS, if not NULL, is the breakpoint_ops structure associated
-   to the catchpoint.  */
-
-static struct breakpoint *
-create_catchpoint_without_mention (struct gdbarch *gdbarch, int tempflag,
-                                  char *cond_string,
-                                  struct breakpoint_ops *ops)
-{
-  struct breakpoint *b = XNEW (struct breakpoint);
-
-  init_catchpoint (b, gdbarch, tempflag, cond_string, ops);
-  return b;
-}
-
-/* Create a new breakpoint of the bp_catchpoint kind and return it.
-   If TEMPFLAG is non-zero, then make the breakpoint temporary.
-   If COND_STRING is not NULL, then store it in the breakpoint.
-   OPS, if not NULL, is the breakpoint_ops structure associated
-   to the catchpoint.  */
-
-static struct breakpoint *
-create_catchpoint (struct gdbarch *gdbarch, int tempflag,
-                  char *cond_string, struct breakpoint_ops *ops)
+static void
+install_catchpoint (struct breakpoint *b)
 {
-  struct breakpoint *b =
-    create_catchpoint_without_mention (gdbarch, tempflag, cond_string, ops);
-
+  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);
-
-  return b;
 }
 
 static void
@@ -6926,9 +6889,7 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
 
   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.  */
@@ -7057,11 +7018,7 @@ create_syscall_event_catchpoint (int tempflag, VEC(int) *filter,
   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
@@ -9892,11 +9849,7 @@ catch_exec_command_1 (char *arg, int from_tty,
                   &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
This page took 0.029674 seconds and 4 git commands to generate.