gdb:
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 3020de2114524110337a0eda1d9647c9591f0d50..3324f20761c64f75f33cae4a035b6999b2bd3ad5 100644 (file)
 #include "top.h"
 #include "wrapper.h"
 
-#include "gdb-events.h"
 #include "mi/mi-common.h"
 
 /* Prototypes for local functions. */
 
-static void until_break_command_continuation (struct continuation_arg *arg, 
-                                             int error);
-
 static void catch_command_1 (char *, int, int);
 
 static void enable_delete_command (char *, int);
@@ -622,7 +618,7 @@ condition_command (char *arg, int from_tty)
              }
          }
        breakpoints_changed ();
-       breakpoint_modify_event (b->number);
+       observer_notify_breakpoint_modified (b->number);
        return;
       }
 
@@ -661,7 +657,7 @@ commands_command (char *arg, int from_tty)
        free_command_lines (&b->commands);
        b->commands = l;
        breakpoints_changed ();
-       breakpoint_modify_event (b->number);
+       observer_notify_breakpoint_modified (b->number);
        return;
     }
   error (_("No breakpoint number %d."), bnum);
@@ -707,7 +703,7 @@ commands_from_control_command (char *arg, struct command_line *cmd)
           list after it finishes execution.  */
        b->commands = copy_command_lines (cmd->body_list[0]);
        breakpoints_changed ();
-       breakpoint_modify_event (b->number);
+       observer_notify_breakpoint_modified (b->number);
        return simple_control;
       }
   error (_("No breakpoint number %d."), bnum);
@@ -2654,7 +2650,8 @@ watchpoint_check (void *p)
       /* If we've gotten confused in the unwinder, we might have
         returned a frame that can't describe this variable.  */
       if (within_current_scope
-         && block_function (b->exp_valid_block) != get_frame_function (fr))
+         && (block_linkage_function (b->exp_valid_block)
+             != get_frame_function (fr)))
        within_current_scope = 0;
 
       /* in_function_epilogue_p() returns a non-zero value if we're still
@@ -4897,7 +4894,7 @@ mention (struct breakpoint *b)
      been done for deprecated_delete_breakpoint_hook and so on.  */
   if (deprecated_create_breakpoint_hook)
     deprecated_create_breakpoint_hook (b);
-  breakpoint_create_event (b->number);
+  observer_notify_breakpoint_created (b->number);
 
   if (b->ops != NULL && b->ops->print_mention != NULL)
     b->ops->print_mention (b);
@@ -5703,7 +5700,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
       bv = blockvector_for_pc_sect (sal->pc, 0, &b, sal->symtab);
       if (bv != NULL)
        {
-         sym = block_function (b);
+         sym = block_linkage_function (b);
          if (sym != NULL)
            {
              fixup_symbol_section (sym, sal->symtab->objfile);
@@ -6151,16 +6148,24 @@ awatch_command (char *arg, int from_tty)
 /* Helper routines for the until_command routine in infcmd.c.  Here
    because it uses the mechanisms of breakpoints.  */
 
+struct until_break_command_continuation_args
+{
+  struct breakpoint *breakpoint;
+  struct breakpoint *breakpoint2;
+};
+
 /* This function is called by fetch_inferior_event via the
    cmd_continuation pointer, to complete the until command. It takes
    care of cleaning up the temporary breakpoints set up by the until
    command. */
 static void
-until_break_command_continuation (struct continuation_arg *arg, int error)
+until_break_command_continuation (void *arg)
 {
-  delete_breakpoint ((struct breakpoint *)(arg->data.pointer));
-  if (arg->next)
-    delete_breakpoint ((struct breakpoint *)(arg->next->data.pointer));
+  struct until_break_command_continuation_args *a = arg;
+
+  delete_breakpoint (a->breakpoint);
+  if (a->breakpoint2)
+    delete_breakpoint (a->breakpoint2);
 }
 
 void
@@ -6173,9 +6178,6 @@ until_break_command (char *arg, int from_tty, int anywhere)
   struct breakpoint *breakpoint;
   struct breakpoint *breakpoint2 = NULL;
   struct cleanup *old_chain;
-  struct continuation_arg *arg1;
-  struct continuation_arg *arg2;
-
 
   clear_proceed_status ();
 
@@ -6232,22 +6234,15 @@ until_break_command (char *arg, int from_tty, int anywhere)
 
   if (target_can_async_p () && is_running (inferior_ptid))
     {
-      arg1 =
-       (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
-      arg1->next         = NULL;
-      arg1->data.pointer = breakpoint;
+      struct until_break_command_continuation_args *args;
+      args = xmalloc (sizeof (*args));
 
-      if (breakpoint2)
-       {
-         arg2 = (struct continuation_arg *)
-           xmalloc ( sizeof (struct continuation_arg));
-         arg2->next         = NULL;
-         arg2->data.pointer = breakpoint2;
-         arg1->next = arg2;       
-       }
+      args->breakpoint = breakpoint;
+      args->breakpoint2 = breakpoint2;
 
       discard_cleanups (old_chain);
-      add_continuation (until_break_command_continuation, arg1);
+      add_continuation (until_break_command_continuation, args,
+                       xfree);
     }
   else
     do_cleanups (old_chain);
@@ -7168,6 +7163,29 @@ update_global_location_list_nothrow (int inserting)
     update_global_location_list (inserting);
 }
 
+/* Clear BPT from a BPS.  */
+static void
+bpstat_remove_breakpoint (bpstat bps, struct breakpoint *bpt)
+{
+  bpstat bs;
+  for (bs = bps; bs; bs = bs->next)
+    if (bs->breakpoint_at && bs->breakpoint_at->owner == bpt)
+      {
+       bs->breakpoint_at = NULL;
+       bs->old_val = NULL;
+       /* bs->commands will be freed later.  */
+      }
+}
+
+/* Callback for iterate_over_threads.  */
+static int
+bpstat_remove_breakpoint_callback (struct thread_info *th, void *data)
+{
+  struct breakpoint *bpt = data;
+  bpstat_remove_breakpoint (th->stop_bpstat, bpt);
+  return 0;
+}
+
 /* Delete a breakpoint and clean up all traces of it in the data
    structures. */
 
@@ -7175,7 +7193,6 @@ void
 delete_breakpoint (struct breakpoint *bpt)
 {
   struct breakpoint *b;
-  bpstat bs;
   struct bp_location *loc, *next;
 
   gdb_assert (bpt != NULL);
@@ -7198,7 +7215,7 @@ delete_breakpoint (struct breakpoint *bpt)
 
   if (deprecated_delete_breakpoint_hook)
     deprecated_delete_breakpoint_hook (bpt);
-  breakpoint_delete_event (bpt->number);
+  observer_notify_breakpoint_deleted (bpt->number);
 
   if (breakpoint_chain == bpt)
     breakpoint_chain = bpt->next;
@@ -7239,13 +7256,11 @@ delete_breakpoint (struct breakpoint *bpt)
          bpstat_do_actions (&stop_bpstat);
      in event-top.c won't do anything, and temporary breakpoints
      with commands won't work.  */
-  for (bs = stop_bpstat; bs; bs = bs->next)
-    if (bs->breakpoint_at && bs->breakpoint_at->owner == bpt)
-      {
-       bs->breakpoint_at = NULL;
-       bs->old_val = NULL;
-       /* bs->commands will be freed later.  */
-      }
+
+  /* Clear the current context.  */
+  bpstat_remove_breakpoint (stop_bpstat, bpt);
+  /* And from all threads.  */
+  iterate_over_threads (bpstat_remove_breakpoint_callback, bpt);
 
   /* Now that breakpoint is removed from breakpoint
      list, update the global location list.  This
@@ -7705,7 +7720,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
                             count, bptnum);
        }
       breakpoints_changed ();
-      breakpoint_modify_event (b->number);
+      observer_notify_breakpoint_modified (b->number);
       return;
     }
 
@@ -7855,7 +7870,7 @@ disable_breakpoint (struct breakpoint *bpt)
 
   if (deprecated_modify_breakpoint_hook)
     deprecated_modify_breakpoint_hook (bpt);
-  breakpoint_modify_event (bpt->number);
+  observer_notify_breakpoint_modified (bpt->number);
 }
 
 static void
@@ -7980,7 +7995,7 @@ have been allocated for other watchpoints.\n"), bpt->number);
   
   if (deprecated_modify_breakpoint_hook)
     deprecated_modify_breakpoint_hook (bpt);
-  breakpoint_modify_event (bpt->number);
+  observer_notify_breakpoint_modified (bpt->number);
 }
 
 
This page took 0.027425 seconds and 4 git commands to generate.