2003-02-04 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 310d2d6f4f77bb520770d5db6d210871727df397..5327d7a9d42ecd266bfdad463f4f54e92845f188 100644 (file)
@@ -1,6 +1,8 @@
 /* Everything about breakpoints, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
 #include "annotate.h"
 #include "symfile.h"
 #include "objfiles.h"
+#include "source.h"
 #include "linespec.h"
 #include "completer.h"
 #include "gdb.h"
-#ifdef UI_OUT
 #include "ui-out.h"
-#endif
+#include "cli/cli-script.h"
+#include "gdb_assert.h"
 
 #include "gdb-events.h"
 
@@ -70,7 +73,7 @@ static void map_breakpoint_numbers (char *, void (*)(struct breakpoint *));
 
 static void ignore_command (char *, int);
 
-static int breakpoint_re_set_one (PTR);
+static int breakpoint_re_set_one (void *);
 
 static void clear_command (char *, int);
 
@@ -84,10 +87,10 @@ static void watch_command (char *, int);
 
 static int can_use_hardware_watchpoint (struct value *);
 
-static void break_at_finish_command (char *, int);
-static void break_at_finish_at_depth_command (char *, int);
+extern void break_at_finish_command (char *, int);
+extern void break_at_finish_at_depth_command (char *, int);
 
-static void tbreak_at_finish_command (char *, int);
+extern void tbreak_at_finish_command (char *, int);
 
 static void break_command_1 (char *, int, int);
 
@@ -105,9 +108,9 @@ static void breakpoint_1 (int, int);
 
 static bpstat bpstat_alloc (struct breakpoint *, bpstat);
 
-static int breakpoint_cond_eval (PTR);
+static int breakpoint_cond_eval (void *);
 
-static void cleanup_executing_breakpoints (PTR);
+static void cleanup_executing_breakpoints (void *);
 
 static void commands_command (char *, int);
 
@@ -117,10 +120,6 @@ static int get_number_trailer (char **, int);
 
 void set_breakpoint_count (int);
 
-#if 0
-static struct breakpoint *create_temp_exception_breakpoint (CORE_ADDR);
-#endif
-
 typedef enum
   {
     mark_inserted,
@@ -141,15 +140,15 @@ typedef struct
   }
 args_for_catchpoint_enable;
 
-static int watchpoint_check (PTR);
+static int watchpoint_check (void *);
 
-static int cover_target_enable_exception_callback (PTR);
+static int cover_target_enable_exception_callback (void *);
 
 static void maintenance_info_breakpoints (char *, int);
 
-#ifdef GET_LONGJMP_TARGET
 static void create_longjmp_breakpoint (char *);
-#endif
+
+static void create_overlay_event_breakpoint (char *);
 
 static int hw_breakpoint_used_count (void);
 
@@ -218,11 +217,12 @@ void _initialize_breakpoint (void);
 
 extern int addressprint;       /* Print machine addresses? */
 
-static int internal_breakpoint_number = -1;
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
+/* Are overlay event breakpoints enabled? */
+static int overlay_events_enabled;
+
 /* Walk the following statement or block through all breakpoints.
    ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
    breakpoint.  */
@@ -556,6 +556,7 @@ condition_command (char *arg, int from_tty)
            error ("Junk at end of expression");
        }
       breakpoints_changed ();
+      breakpoint_modify_event (b->number);
       return;
     }
 
@@ -595,6 +596,7 @@ commands_command (char *arg, int from_tty)
       free_command_lines (&b->commands);
       b->commands = l;
       breakpoints_changed ();
+      breakpoint_modify_event (b->number);
       return;
     }
   error ("No breakpoint number %d.", bnum);
@@ -716,17 +718,41 @@ insert_breakpoints (void)
   int return_val = 0;  /* return success code. */
   int val = 0;
   int disabled_breaks = 0;
+  int hw_breakpoint_error = 0;
+#ifdef ONE_PROCESS_WRITETEXT
+  int process_warning = 0;
+#endif
 
   static char message1[] = "Error inserting catchpoint %d:\n";
   static char message[sizeof (message1) + 30];
 
+  struct ui_file *tmp_error_stream = mem_fileopen ();
+  make_cleanup_ui_file_delete (tmp_error_stream);
+
+  /* Explicitly mark the warning -- this will only be printed if
+     there was an error.  */
+  fprintf_unfiltered (tmp_error_stream, "Warning:\n");
 
   ALL_BREAKPOINTS_SAFE (b, temp)
   {
-    if (b->enable_state == bp_permanent)
-      /* Permanent breakpoints cannot be inserted or removed.  */
+    /* Permanent breakpoints cannot be inserted or removed.  Disabled
+       breakpoints should not be inserted.  */
+    if (b->enable_state != bp_enabled)
       continue;
-    else if (b->type != bp_watchpoint
+
+    if ((b->type == bp_watchpoint
+        || b->type == bp_hardware_watchpoint
+        || b->type == bp_read_watchpoint
+        || b->type == bp_access_watchpoint) && (!b->val))
+      {
+       struct value *val;
+       val = evaluate_expression (b->exp);
+       release_value (val);
+       if (VALUE_LAZY (val))
+         value_fetch_lazy (val);
+       b->val = val;
+      } 
+    if (b->type != bp_watchpoint
        && b->type != bp_hardware_watchpoint
        && b->type != bp_read_watchpoint
        && b->type != bp_access_watchpoint
@@ -735,39 +761,69 @@ insert_breakpoints (void)
        && b->type != bp_catch_exec
        && b->type != bp_catch_throw
        && b->type != bp_catch_catch
-       && b->enable_state != bp_disabled
-       && b->enable_state != bp_shlib_disabled
-       && b->enable_state != bp_call_disabled
        && !b->inserted
        && !b->duplicate)
       {
-       if (b->type == bp_hardware_breakpoint)
-         val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
+       /* "Normal" instruction breakpoint: either the standard
+          trap-instruction bp (bp_breakpoint), or a
+          bp_hardware_breakpoint.  */
+
+       /* First check to see if we have to handle an overlay.  */
+       if (overlay_debugging == ovly_off
+           || b->section == NULL
+           || !(section_is_overlay (b->section)))
+         {
+           /* No overlay handling: just set the breakpoint.  */
+
+           if (b->type == bp_hardware_breakpoint)
+             val = target_insert_hw_breakpoint (b->address, 
+                                                b->shadow_contents);
+           else
+             val = target_insert_breakpoint (b->address, b->shadow_contents);
+         }
        else
          {
-           /* Check to see if breakpoint is in an overlay section;
-              if so, we should set the breakpoint at the LMA address.
-              Only if the section is currently mapped should we ALSO
-              set a break at the VMA address. */
-           if (overlay_debugging && b->section &&
-               section_is_overlay (b->section))
+           /* This breakpoint is in an overlay section.  
+              Shall we set a breakpoint at the LMA?  */
+           if (!overlay_events_enabled)
+             {
+               /* Yes -- overlay event support is not active, 
+                  so we must try to set a breakpoint at the LMA.
+                  This will not work for a hardware breakpoint.  */
+               if (b->type == bp_hardware_breakpoint)
+                 warning ("hardware breakpoint %d not supported in overlay!\n",
+                          b->number);
+               else
+                 {
+                   CORE_ADDR addr = overlay_unmapped_address (b->address, 
+                                                              b->section);
+                   /* Set a software (trap) breakpoint at the LMA.  */
+                   val = target_insert_breakpoint (addr, b->shadow_contents);
+                   if (val != 0)
+                     fprintf_unfiltered (tmp_error_stream, 
+                                         "Overlay breakpoint %d failed: in ROM?", 
+                                         b->number);
+                 }
+             }
+           /* Shall we set a breakpoint at the VMA? */
+           if (section_is_mapped (b->section))
              {
-               CORE_ADDR addr;
-
-               addr = overlay_unmapped_address (b->address, b->section);
-               val = target_insert_breakpoint (addr, b->shadow_contents);
-               /* This would be the time to check val, to see if the
-                  breakpoint write to the load address succeeded.  
-                  However, this might be an ordinary occurrance, eg. if 
-                  the unmapped overlay is in ROM.  */
-               val = 0;        /* in case unmapped address failed */
-               if (section_is_mapped (b->section))
+               /* Yes.  This overlay section is mapped into memory.  */
+               if (b->type == bp_hardware_breakpoint)
+                 val = target_insert_hw_breakpoint (b->address, 
+                                                    b->shadow_contents);
+               else
                  val = target_insert_breakpoint (b->address,
                                                  b->shadow_contents);
              }
-           else                /* ordinary (non-overlay) address */
-             val = target_insert_breakpoint (b->address, b->shadow_contents);
+           else
+             {
+               /* No.  This breakpoint will not be inserted.  
+                  No error, but do not mark the bp as 'inserted'.  */
+               continue;
+             }
          }
+
        if (val)
          {
            /* Can't set the breakpoint.  */
@@ -779,22 +835,41 @@ insert_breakpoints (void)
                b->enable_state = bp_shlib_disabled;
                if (!disabled_breaks)
                  {
-                   target_terminal_ours_for_output ();
-                   warning ("Cannot insert breakpoint %d:", b->number);
-                   warning ("Temporarily disabling shared library breakpoints:");
+                   fprintf_unfiltered (tmp_error_stream, 
+                                       "Cannot insert breakpoint %d.\n", 
+                                       b->number);
+                   fprintf_unfiltered (tmp_error_stream, 
+                                       "Temporarily disabling shared library breakpoints:\n");
                  }
                disabled_breaks = 1;
-               warning ("breakpoint #%d ", b->number);
+               fprintf_unfiltered (tmp_error_stream, 
+                                   "breakpoint #%d\n", b->number);
              }
            else
 #endif
              {
-               target_terminal_ours_for_output ();
-               warning ("Cannot insert breakpoint %d:", b->number);
 #ifdef ONE_PROCESS_WRITETEXT
-               warning ("The same program may be running in another process.");
+               process_warning = 1;
 #endif
-               memory_error (val, b->address);    /* which bombs us out */
+               if (b->type == bp_hardware_breakpoint)
+                 {
+                   hw_breakpoint_error = 1;
+                   fprintf_unfiltered (tmp_error_stream, 
+                                       "Cannot insert hardware breakpoint %d.\n",
+                                       b->number);
+                 }
+               else
+                 {
+                   fprintf_unfiltered (tmp_error_stream, 
+                                       "Cannot insert breakpoint %d.\n", 
+                                       b->number);
+                   fprintf_filtered (tmp_error_stream, 
+                                     "Error accessing memory address ");
+                   print_address_numeric (b->address, 1, tmp_error_stream);
+                   fprintf_filtered (tmp_error_stream, ": %s.\n",
+                                     safe_strerror (val));
+                 }
+
              }
          }
        else
@@ -804,9 +879,6 @@ insert_breakpoints (void)
          return_val = val;     /* remember failure */
       }
     else if (ep_is_exception_catchpoint (b)
-            && b->enable_state != bp_disabled
-            && b->enable_state != bp_shlib_disabled
-            && b->enable_state != bp_call_disabled
             && !b->inserted
             && !b->duplicate)
 
@@ -821,9 +893,14 @@ insert_breakpoints (void)
        if (val)
          {
            /* Couldn't set breakpoint for some reason */
-           target_terminal_ours_for_output ();
-           warning ("Cannot insert catchpoint %d; disabling it.",
-                    b->number);
+           fprintf_unfiltered (tmp_error_stream, 
+                               "Cannot insert catchpoint %d; disabling it.\n",
+                               b->number);
+           fprintf_filtered (tmp_error_stream, 
+                             "Error accessing memory address ");
+           print_address_numeric (b->address, 1, tmp_error_stream);
+           fprintf_filtered (tmp_error_stream, ": %s.\n",
+                             safe_strerror (val));
            b->enable_state = bp_disabled;
          }
        else
@@ -845,9 +922,9 @@ insert_breakpoints (void)
            if (val == -1)
              {
                /* something went wrong */
-               target_terminal_ours_for_output ();
-               warning ("Cannot insert catchpoint %d; disabling it.",
-                        b->number);
+               fprintf_unfiltered (tmp_error_stream, 
+                                   "Cannot insert catchpoint %d; disabling it.\n",
+                                   b->number);
                b->enable_state = bp_disabled;
              }
          }
@@ -859,7 +936,6 @@ insert_breakpoints (void)
     else if ((b->type == bp_hardware_watchpoint ||
              b->type == bp_read_watchpoint ||
              b->type == bp_access_watchpoint)
-            && b->enable_state == bp_enabled
             && b->disposition != disp_del_at_next_stop
             && !b->inserted
             && !b->duplicate)
@@ -871,8 +947,8 @@ insert_breakpoints (void)
 
        /* Save the current frame and level so we can restore it after
           evaluating the watchpoint expression on its own frame.  */
-       saved_frame = selected_frame;
-       saved_level = selected_frame_level;
+       saved_frame = deprecated_selected_frame;
+       saved_level = frame_relative_level (deprecated_selected_frame);
 
        /* Determine if the watchpoint is within scope.  */
        if (b->exp_valid_block == NULL)
@@ -880,16 +956,10 @@ insert_breakpoints (void)
        else
          {
            struct frame_info *fi;
-
-           /* There might be no current frame at this moment if we are
-              resuming from a step over a breakpoint.
-              Set up current frame before trying to find the watchpoint
-              frame.  */
-           get_current_frame ();
-           fi = find_frame_addr_in_frame_chain (b->watchpoint_frame);
+           fi = frame_find_by_id (b->watchpoint_frame);
            within_current_scope = (fi != NULL);
            if (within_current_scope)
-             select_frame (fi, -1);
+             select_frame (fi);
          }
 
        if (within_current_scope)
@@ -930,7 +1000,7 @@ insert_breakpoints (void)
 
                        addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
                        len = TYPE_LENGTH (VALUE_TYPE (v));
-                       type   = hw_write;
+                       type = hw_write;
                        if (b->type == bp_read_watchpoint)
                          type = hw_read;
                        else if (b->type == bp_access_watchpoint)
@@ -956,8 +1026,10 @@ insert_breakpoints (void)
            if (!b->inserted)
              {
                remove_breakpoint (b, mark_uninserted);
-               warning ("Could not insert hardware watchpoint %d.",
-                        b->number);
+               hw_breakpoint_error = 1;
+               fprintf_unfiltered (tmp_error_stream,
+                                   "Could not insert hardware watchpoint %d.\n", 
+                                   b->number);
                val = -1;
              }               
          }
@@ -972,9 +1044,9 @@ insert_breakpoints (void)
          }
 
        /* Restore the frame and level.  */
-       if ((saved_frame != selected_frame) ||
-           (saved_level != selected_frame_level))
-         select_frame (saved_frame, saved_level);
+       if ((saved_frame != deprecated_selected_frame) ||
+           (saved_level != frame_relative_level (deprecated_selected_frame)))
+         select_frame (saved_frame);
 
        if (val)
          return_val = val;     /* remember failure */
@@ -982,7 +1054,6 @@ insert_breakpoints (void)
     else if ((b->type == bp_catch_fork
              || b->type == bp_catch_vfork
              || b->type == bp_catch_exec)
-            && b->enable_state == bp_enabled
             && !b->inserted
             && !b->duplicate)
       {
@@ -1004,8 +1075,8 @@ insert_breakpoints (void)
          }
        if (val < 0)
          {
-           target_terminal_ours_for_output ();
-           warning ("Cannot insert catchpoint %d.", b->number);
+           fprintf_unfiltered (tmp_error_stream, 
+                               "Cannot insert catchpoint %d.", b->number);
          }
        else
          b->inserted = 1;
@@ -1014,11 +1085,28 @@ insert_breakpoints (void)
          return_val = val;     /* remember failure */
       }
   }
-
+  
+  if (return_val) 
+    {
+      /* If a hardware breakpoint or watchpoint was inserted, add a
+         message about possibly exhausted resources.  */
+      if (hw_breakpoint_error)  
+       {
+         fprintf_unfiltered (tmp_error_stream, 
+                             "Could not insert hardware breakpoints:\n\
+You may have requested too many hardware breakpoints/watchpoints.\n");
+       }
+#ifdef ONE_PROCESS_WRITETEXT
+      if (process_warning)
+       fprintf_unfiltered (tmp_error_stream,
+                           "The same program may be running in another process.");
+#endif
+      target_terminal_ours_for_output ();
+      error_stream (tmp_error_stream);
+    }
   return return_val;
 }
 
-
 int
 remove_breakpoints (void)
 {
@@ -1107,8 +1195,9 @@ update_breakpoints_after_exec (void)
        continue;
       }
 
-    /* Thread event breakpoints must be set anew after an exec().  */
-    if (b->type == bp_thread_event)
+    /* Thread event breakpoints must be set anew after an exec(),
+       as must overlay event breakpoints.  */
+    if (b->type == bp_thread_event || b->type == bp_overlay_event)
       {
        delete_breakpoint (b);
        continue;
@@ -1149,8 +1238,8 @@ update_breakpoints_after_exec (void)
        automagically.  Certainly on HP-UX that's true.
 
        Jim Blandy <jimb@redhat.com>: Actually, zero is a perfectly
-       valid code address on some platforms (like the mn10200 and
-       mn10300 simulators).  We shouldn't assign any special
+       valid code address on some platforms (like the OBSOLETE mn10200
+       and mn10300 simulators).  We shouldn't assign any special
        interpretation to a breakpoint with a zero address.  And in
        fact, GDB doesn't --- I can't see what that comment above is
        talking about.  As far as I can tell, setting the address of a
@@ -1216,6 +1305,8 @@ update_breakpoints_after_exec (void)
        So I think this assignment could be deleted without effect.  */
     b->address = (CORE_ADDR) NULL;
   }
+  /* FIXME what about longjmp breakpoints?  Re-create them here?  */
+  create_overlay_event_breakpoint ("_ovly_debug_event");
 }
 
 int
@@ -1269,32 +1360,61 @@ remove_breakpoint (struct breakpoint *b, insertion_state_t is)
       && b->type != bp_catch_catch
       && b->type != bp_catch_throw)
     {
-      if (b->type == bp_hardware_breakpoint)
-       val = target_remove_hw_breakpoint (b->address, b->shadow_contents);
+      /* "Normal" instruction breakpoint: either the standard
+        trap-instruction bp (bp_breakpoint), or a
+        bp_hardware_breakpoint.  */
+
+      /* First check to see if we have to handle an overlay.  */
+      if (overlay_debugging == ovly_off
+         || b->section == NULL
+         || !(section_is_overlay (b->section)))
+       {
+         /* No overlay handling: just remove the breakpoint.  */
+
+         if (b->type == bp_hardware_breakpoint)
+           val = target_remove_hw_breakpoint (b->address, 
+                                              b->shadow_contents);
+         else
+           val = target_remove_breakpoint (b->address, b->shadow_contents);
+       }
       else
        {
-         /* Check to see if breakpoint is in an overlay section;
-            if so, we should remove the breakpoint at the LMA address.
-            If that is not equal to the raw address, then we should 
-            presumably remove the breakpoint there as well.  */
-         if (overlay_debugging && b->section &&
-             section_is_overlay (b->section))
+         /* This breakpoint is in an overlay section.  
+            Did we set a breakpoint at the LMA?  */
+         if (!overlay_events_enabled)
+             {
+               /* Yes -- overlay event support is not active, so we
+                  should have set a breakpoint at the LMA.  Remove it.  
+               */
+               CORE_ADDR addr = overlay_unmapped_address (b->address, 
+                                                          b->section);
+               /* Ignore any failures: if the LMA is in ROM, we will
+                  have already warned when we failed to insert it.  */
+               if (b->type != bp_hardware_breakpoint)
+                 target_remove_hw_breakpoint (addr, b->shadow_contents);
+               else
+                 target_remove_breakpoint (addr, b->shadow_contents);
+             }
+         /* Did we set a breakpoint at the VMA? 
+            If so, we will have marked the breakpoint 'inserted'.  */
+         if (b->inserted)
            {
-             CORE_ADDR addr;
-
-             addr = overlay_unmapped_address (b->address, b->section);
-             val = target_remove_breakpoint (addr, b->shadow_contents);
-             /* This would be the time to check val, to see if the
-                shadow breakpoint write to the load address succeeded.  
-                However, this might be an ordinary occurrance, eg. if 
-                the unmapped overlay is in ROM.  */
-             val = 0;          /* in case unmapped address failed */
-             if (section_is_mapped (b->section))
+             /* Yes -- remove it.  Previously we did not bother to
+                remove the breakpoint if the section had been
+                unmapped, but let's not rely on that being safe.  We
+                don't know what the overlay manager might do.  */
+             if (b->type == bp_hardware_breakpoint)
+               val = target_remove_hw_breakpoint (b->address, 
+                                                  b->shadow_contents);
+             else
                val = target_remove_breakpoint (b->address,
                                                b->shadow_contents);
            }
-         else                  /* ordinary (non-overlay) address */
-           val = target_remove_breakpoint (b->address, b->shadow_contents);
+         else
+           {
+             /* No -- not inserted, so no need to remove.  No error.  */
+             val = 0;
+           }
        }
       if (val)
        return val;
@@ -1463,6 +1583,14 @@ breakpoint_init_inferior (enum inf_context context)
        /* Likewise for watchpoints on local expressions.  */
        if (b->exp_valid_block != NULL)
          delete_breakpoint (b);
+       if (context == inf_starting) 
+         {
+           /* Reset val field to force reread of starting value
+              in insert_breakpoints.  */
+           if (b->val)
+             value_free (b->val);
+           b->val = NULL;
+         }
        break;
       default:
        /* Likewise for exception catchpoints in dynamic-linked
@@ -1510,9 +1638,9 @@ breakpoint_here_p (CORE_ADDR pc)
         || b->enable_state == bp_permanent)
        && b->address == pc)    /* bp is enabled and matches pc */
       {
-       if (overlay_debugging &&
-           section_is_overlay (b->section) &&
-           !section_is_mapped (b->section))
+       if (overlay_debugging 
+           && section_is_overlay (b->section) 
+           && !section_is_mapped (b->section))
          continue;             /* unmapped overlay -- can't be a match */
        else if (b->enable_state == bp_permanent)
          return permanent_breakpoint_here;
@@ -1537,9 +1665,9 @@ breakpoint_inserted_here_p (CORE_ADDR pc)
     if (b->inserted
        && b->address == pc)    /* bp is inserted and matches pc */
     {
-      if (overlay_debugging &&
-         section_is_overlay (b->section) &&
-         !section_is_mapped (b->section))
+      if (overlay_debugging 
+         && section_is_overlay (b->section) 
+         && !section_is_mapped (b->section))
        continue;               /* unmapped overlay -- can't be a match */
       else
        return 1;
@@ -1549,32 +1677,34 @@ breakpoint_inserted_here_p (CORE_ADDR pc)
 }
 
 /* Return nonzero if FRAME is a dummy frame.  We can't use
-   PC_IN_CALL_DUMMY because figuring out the saved SP would take too
-   much time, at least using get_saved_register on the 68k.  This
-   means that for this function to work right a port must use the
+   DEPRECATED_PC_IN_CALL_DUMMY because figuring out the saved SP would
+   take too much time, at least using get_saved_register on the 68k.
+   This means that for this function to work right a port must use the
    bp_call_dummy breakpoint.  */
 
 int
-frame_in_dummy (struct frame_info *frame)
+deprecated_frame_in_dummy (struct frame_info *frame)
 {
   struct breakpoint *b;
 
   if (!CALL_DUMMY_P)
     return 0;
 
-  if (USE_GENERIC_DUMMY_FRAMES)
-    return generic_pc_in_call_dummy (frame->pc, frame->frame, frame->frame);
+  /* This function is used by two files: get_frame_type(), after first
+     checking that !DEPRECATED_USE_GENERIC_DUMMY_FRAMES; and
+     sparc-tdep.c, which doesn't yet use generic dummy frames anyway.  */
+  gdb_assert (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES);
 
   ALL_BREAKPOINTS (b)
   {
     if (b->type == bp_call_dummy
-       && b->frame == frame->frame
+       && frame_id_eq (b->frame_id, get_frame_id (frame))
     /* We need to check the PC as well as the frame on the sparc,
        for signals.exp in the testsuite.  */
-       && (frame->pc
+       && (get_frame_pc (frame)
            >= (b->address
-             - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
-       && frame->pc <= b->address)
+               - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
+       && get_frame_pc (frame) <= b->address)
       return 1;
   }
   return 0;
@@ -1598,9 +1728,9 @@ breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
        && b->address == pc
        && (b->thread == -1 || b->thread == thread))
     {
-      if (overlay_debugging &&
-         section_is_overlay (b->section) &&
-         !section_is_mapped (b->section))
+      if (overlay_debugging 
+         && section_is_overlay (b->section) 
+         && !section_is_mapped (b->section))
        continue;               /* unmapped overlay -- can't be a match */
       else
        return 1;
@@ -1661,6 +1791,7 @@ bpstat_clear (bpstat *bsp)
       q = p->next;
       if (p->old_val != NULL)
        value_free (p->old_val);
+      free_command_lines (&p->commands);
       xfree (p);
       p = q;
     }
@@ -1773,7 +1904,7 @@ bpstat_clear_actions (bpstat bs)
 {
   for (; bs != NULL; bs = bs->next)
     {
-      bs->commands = NULL;
+      free_command_lines (&bs->commands);
       if (bs->old_val != NULL)
        {
          value_free (bs->old_val);
@@ -1785,7 +1916,7 @@ bpstat_clear_actions (bpstat bs)
 /* Stub for cleaning up our state if we error-out of a breakpoint command */
 /* ARGSUSED */
 static void
-cleanup_executing_breakpoints (PTR ignore)
+cleanup_executing_breakpoints (void *ignore)
 {
   executing_breakpoint_commands = 0;
 }
@@ -1842,11 +1973,9 @@ top:
           to look at, so start over.  */
        goto top;
       else
-       bs->commands = NULL;
+       free_command_lines (&bs->commands);
     }
-
-  executing_breakpoint_commands = 0;
-  discard_cleanups (old_chain);
+  do_cleanups (old_chain);
 }
 
 /* This is the normal print function for a bpstat.  In the future,
@@ -1873,12 +2002,10 @@ top:
 static enum print_stop_action
 print_it_typical (bpstat bs)
 {
-#ifdef UI_OUT
-  struct cleanup *old_chain;
+  struct cleanup *old_chain, *ui_out_chain;
   struct ui_stream *stb;
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
-#endif /* UI_OUT */
   /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
      which has since been deleted.  */
   if (bs->breakpoint_at == NULL)
@@ -1888,7 +2015,6 @@ print_it_typical (bpstat bs)
     {
     case bp_breakpoint:
     case bp_hardware_breakpoint:
-#ifdef UI_OUT
       annotate_breakpoint (bs->breakpoint_at->number);
       ui_out_text (uiout, "\nBreakpoint ");
       if (ui_out_is_mi_like_p (uiout))
@@ -1896,13 +2022,6 @@ print_it_typical (bpstat bs)
       ui_out_field_int (uiout, "bkptno", bs->breakpoint_at->number);
       ui_out_text (uiout, ", ");
       return PRINT_SRC_AND_LOC;
-#else
-      /* I think the user probably only wants to see one breakpoint
-         number, not all of them.  */
-      annotate_breakpoint (bs->breakpoint_at->number);
-      printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
-      return PRINT_SRC_AND_LOC;
-#endif
       break;
 
     case bp_shlib_event:
@@ -1920,6 +2039,12 @@ print_it_typical (bpstat bs)
       return PRINT_NOTHING;
       break;
 
+    case bp_overlay_event:
+      /* By analogy with the thread event, GDB should not stop for these. */
+      printf_filtered ("Overlay Event Breakpoint: gdb should not stop!\n");
+      return PRINT_NOTHING;
+      break;
+
     case bp_catch_load:
       annotate_catchpoint (bs->breakpoint_at->number);
       printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
@@ -2035,28 +2160,18 @@ print_it_typical (bpstat bs)
       if (bs->old_val != NULL)
        {
          annotate_watchpoint (bs->breakpoint_at->number);
-#ifdef UI_OUT
          if (ui_out_is_mi_like_p (uiout))
            ui_out_field_string (uiout, "reason", "watchpoint-trigger");
          mention (bs->breakpoint_at);
-         ui_out_tuple_begin (uiout, "value");
+         ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
          ui_out_text (uiout, "\nOld value = ");
          value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
          ui_out_field_stream (uiout, "old", stb);
          ui_out_text (uiout, "\nNew value = ");
          value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default);
          ui_out_field_stream (uiout, "new", stb);
-         ui_out_tuple_end (uiout);
+         do_cleanups (ui_out_chain);
          ui_out_text (uiout, "\n");
-#else
-         mention (bs->breakpoint_at);
-         printf_filtered ("\nOld value = ");
-         value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
-         printf_filtered ("\nNew value = ");
-         value_print (bs->breakpoint_at->val, gdb_stdout, 0,
-                      Val_pretty_default);
-         printf_filtered ("\n");
-#endif
          value_free (bs->old_val);
          bs->old_val = NULL;
        }
@@ -2065,35 +2180,26 @@ print_it_typical (bpstat bs)
       break;
 
     case bp_read_watchpoint:
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", "read-watchpoint-trigger");
       mention (bs->breakpoint_at);
-      ui_out_tuple_begin (uiout, "value");
+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
       ui_out_text (uiout, "\nValue = ");
       value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default);
       ui_out_field_stream (uiout, "value", stb);
-      ui_out_tuple_end (uiout);
+      do_cleanups (ui_out_chain);
       ui_out_text (uiout, "\n");
-#else
-      mention (bs->breakpoint_at);
-      printf_filtered ("\nValue = ");
-      value_print (bs->breakpoint_at->val, gdb_stdout, 0,
-                  Val_pretty_default);
-      printf_filtered ("\n");
-#endif
       return PRINT_UNKNOWN;
       break;
 
     case bp_access_watchpoint:
-#ifdef UI_OUT
       if (bs->old_val != NULL)     
        {
          annotate_watchpoint (bs->breakpoint_at->number);
          if (ui_out_is_mi_like_p (uiout))
            ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
          mention (bs->breakpoint_at);
-         ui_out_tuple_begin (uiout, "value");
+         ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
          ui_out_text (uiout, "\nOld value = ");
          value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
          ui_out_field_stream (uiout, "old", stb);
@@ -2106,33 +2212,13 @@ print_it_typical (bpstat bs)
          mention (bs->breakpoint_at);
          if (ui_out_is_mi_like_p (uiout))
            ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
-         ui_out_tuple_begin (uiout, "value");
+         ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
          ui_out_text (uiout, "\nValue = ");
        }
       value_print (bs->breakpoint_at->val, stb->stream, 0,Val_pretty_default);
       ui_out_field_stream (uiout, "new", stb);
-      ui_out_tuple_end (uiout);
+      do_cleanups (ui_out_chain);
       ui_out_text (uiout, "\n");
-#else
-      if (bs->old_val != NULL)     
-       {
-         annotate_watchpoint (bs->breakpoint_at->number);
-         mention (bs->breakpoint_at);
-         printf_filtered ("\nOld value = ");
-         value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
-         value_free (bs->old_val);
-         bs->old_val = NULL;
-         printf_filtered ("\nNew value = ");
-       }
-      else 
-       {
-         mention (bs->breakpoint_at);
-         printf_filtered ("\nValue = ");
-       }
-      value_print (bs->breakpoint_at->val, gdb_stdout, 0,
-                  Val_pretty_default);
-      printf_filtered ("\n");
-#endif
       return PRINT_UNKNOWN;
       break;
 
@@ -2140,18 +2226,14 @@ print_it_typical (bpstat bs)
        here. */
 
     case bp_finish:
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", "function-finished");
-#endif
       return PRINT_UNKNOWN;
       break;
 
     case bp_until:
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", "location-reached");
-#endif
       return PRINT_UNKNOWN;
       break;
 
@@ -2249,7 +2331,7 @@ bpstat_print (bpstat bs)
    make it pass through catch_errors.  */
 
 static int
-breakpoint_cond_eval (PTR exp)
+breakpoint_cond_eval (void *exp)
 {
   struct value *mark = value_mark ();
   int i = !value_true (evaluate_expression ((struct expression *) exp));
@@ -2289,7 +2371,7 @@ bpstat_alloc (struct breakpoint *b, bpstat cbs /* Current "bs" value */ )
 /* Check watchpoint condition.  */
 
 static int
-watchpoint_check (PTR p)
+watchpoint_check (void *p)
 {
   bpstat bs = (bpstat) p;
   struct breakpoint *b;
@@ -2306,13 +2388,21 @@ watchpoint_check (PTR p)
          any chance of handling watchpoints on local variables, we'll need
          the frame chain (so we can determine if we're in scope).  */
       reinit_frame_cache ();
-      fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
+      fr = frame_find_by_id (b->watchpoint_frame);
       within_current_scope = (fr != NULL);
+      /* in_function_epilogue_p() returns a non-zero value if we're still
+        in the function but the stack frame has already been invalidated.
+        Since we can't rely on the values of local variables after the
+        stack has been destroyed, we are treating the watchpoint in that
+        state as `not changed' without further checking. */
+      if (within_current_scope && fr == get_current_frame ()
+          && gdbarch_in_function_epilogue_p (current_gdbarch, read_pc ()))
+       return WP_VALUE_NOT_CHANGED;
       if (within_current_scope)
        /* If we end up stopping, the current frame will get selected
           in normal_stop.  So this call to select_frame won't affect
           the user.  */
-       select_frame (fr, -1);
+       select_frame (fr);
     }
 
   if (within_current_scope)
@@ -2355,18 +2445,12 @@ watchpoint_check (PTR p)
         in this case, by the time we call print_it_typical() this bp
         will be deleted already. So we have no choice but print the
         information here. */
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", "watchpoint-scope");
       ui_out_text (uiout, "\nWatchpoint ");
       ui_out_field_int (uiout, "wpnum", bs->breakpoint_at->number);
       ui_out_text (uiout, " deleted because the program has left the block in\n\
 which its expression is valid.\n");     
-#else
-      printf_filtered ("\
-Watchpoint %d deleted because the program has left the block in\n\
-which its expression is valid.\n", bs->breakpoint_at->number);
-#endif 
 
       if (b->related_breakpoint)
        b->related_breakpoint->disposition = disp_del_at_next_stop;
@@ -2378,7 +2462,7 @@ which its expression is valid.\n", bs->breakpoint_at->number);
 
 /* Get a bpstat associated with having just stopped at address *PC
    and frame address CORE_ADDRESS.  Update *PC to point at the
-   breakpoint (if we hit a breakpoint).  NOT_A_BREAKPOINT is nonzero
+   breakpoint (if we hit a breakpoint).  NOT_A_SW_BREAKPOINT is nonzero
    if this is known to not be a real breakpoint (it could still be a
    watchpoint, though).  */
 
@@ -2397,7 +2481,7 @@ which its expression is valid.\n", bs->breakpoint_at->number);
    commands, FIXME??? fields.  */
 
 bpstat
-bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
+bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
 {
   register struct breakpoint *b, *temp;
   CORE_ADDR bp_addr;
@@ -2411,14 +2495,13 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
   "Error evaluating expression for watchpoint %d\n";
   char message[sizeof (message1) + 30 /* slop */ ];
 
-  /* Get the address where the breakpoint would have been.  
-     The "not_a_breakpoint" argument is meant to distinguish 
-     between a breakpoint trap event and a trace/singlestep
-     trap event.  For a trace/singlestep trap event, we would
-     not want to subtract DECR_PC_AFTER_BREAK from the PC. */
+  /* Get the address where the breakpoint would have been.  The
+     "not_a_sw_breakpoint" argument is meant to distinguish between a
+     breakpoint trap event and a trace/singlestep trap event.  For a
+     trace/singlestep trap event, we would not want to subtract
+     DECR_PC_AFTER_BREAK from the PC. */
 
-  bp_addr = *pc - (not_a_breakpoint && !SOFTWARE_SINGLE_STEP_P () ? 
-                   0 : DECR_PC_AFTER_BREAK);
+  bp_addr = *pc - (not_a_sw_breakpoint ? 0 : DECR_PC_AFTER_BREAK);
 
   ALL_BREAKPOINTS_SAFE (b, temp)
   {
@@ -2437,15 +2520,24 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
        && b->type != bp_catch_exec
        && b->type != bp_catch_catch
        && b->type != bp_catch_throw)   /* a non-watchpoint bp */
-      if (b->address != bp_addr ||     /* address doesn't match or */
-         (overlay_debugging && /* overlay doesn't match */
-          section_is_overlay (b->section) &&
-          !section_is_mapped (b->section)))
-       continue;
+      {
+       if (b->address != bp_addr)      /* address doesn't match */
+         continue;
+       if (overlay_debugging           /* unmapped overlay section */
+           && section_is_overlay (b->section) 
+           && !section_is_mapped (b->section))
+         continue;
+      }
 
-    if (b->type == bp_hardware_breakpoint
-       && b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
-      continue;
+    if (b->type == bp_hardware_breakpoint)
+      {
+       if (b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
+         continue;
+       if (overlay_debugging           /* unmapped overlay section */
+           && section_is_overlay (b->section) 
+           && !section_is_mapped (b->section))
+         continue;
+      }
 
     /* Is this a catchpoint of a load or unload?  If so, did we
        get a load or unload of the specified library?  If not,
@@ -2475,17 +2567,17 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
       continue;
 
     if ((b->type == bp_catch_fork)
-       && !target_has_forked (PIDGET (inferior_ptid),
-                              &b->forked_inferior_pid))
+       && !inferior_has_forked (PIDGET (inferior_ptid),
+                                &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_vfork)
-       && !target_has_vforked (PIDGET (inferior_ptid),
-                               &b->forked_inferior_pid))
+       && !inferior_has_vforked (PIDGET (inferior_ptid),
+                                 &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_exec)
-       && !target_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
+       && !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
       continue;
 
     if (ep_is_exception_catchpoint (b) &&
@@ -2629,8 +2721,8 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
        real_breakpoint = 1;
       }
 
-    if (b->frame &&
-       b->frame != (get_current_frame ())->frame)
+    if (frame_id_p (b->frame_id)
+       && !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
       bs->stop = 0;
     else
       {
@@ -2640,7 +2732,7 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
          {
            /* Need to select the frame, with all that implies
               so that the conditions will have the right context.  */
-           select_frame (get_current_frame (), 0);
+           select_frame (get_current_frame ());
            value_is_zero
              = catch_errors (breakpoint_cond_eval, (b->cond),
                              "Error in testing breakpoint condition:\n",
@@ -2665,7 +2757,7 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
            /* We will stop here */
            if (b->disposition == disp_disable)
              b->enable_state = bp_disabled;
-           bs->commands = b->commands;
+           bs->commands = copy_command_lines (b->commands);
            if (b->silent)
              bs->print = 0;
            if (bs->commands &&
@@ -2825,7 +2917,7 @@ bpstat_what (bpstat bs)
 
   /* step_resume entries: a step resume breakpoint overrides another
      breakpoint of signal handling (see comment in wait_for_inferior
-     at first IN_SIGTRAMP where we set the step_resume breakpoint).  */
+     at first PC_IN_SIGTRAMP where we set the step_resume breakpoint).  */
   /* We handle the through_sigtramp_breakpoint the same way; having both
      one of those and a step_resume_breakpoint is probably very rare (?).  */
 
@@ -2944,6 +3036,7 @@ bpstat_what (bpstat bs)
          bs_class = shlib_event;
          break;
        case bp_thread_event:
+       case bp_overlay_event:
          bs_class = bp_nostop;
          break;
        case bp_catch_load:
@@ -3120,6 +3213,7 @@ print_one_breakpoint (struct breakpoint *b,
     {bp_call_dummy, "call dummy"},
     {bp_shlib_event, "shlib events"},
     {bp_thread_event, "thread events"},
+    {bp_overlay_event, "overlay events"},
     {bp_catch_load, "catch load"},
     {bp_catch_unload, "catch unload"},
     {bp_catch_fork, "catch fork"},
@@ -3133,23 +3227,16 @@ print_one_breakpoint (struct breakpoint *b,
   {"del", "dstp", "dis", "keep"};
   static char bpenables[] = "nynny";
   char wrap_indent[80];
-#ifdef UI_OUT
   struct ui_stream *stb = ui_out_stream_new (uiout);
   struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
-#endif
+  struct cleanup *bkpt_chain;
 
   annotate_record ();
-#ifdef UI_OUT
-  ui_out_tuple_begin (uiout, "bkpt");
-#endif
+  bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
 
   /* 1 */
   annotate_field (0);
-#ifdef UI_OUT
   ui_out_field_int (uiout, "number", b->number);
-#else
-  printf_filtered ("%-3d ", b->number);
-#endif
 
   /* 2 */
   annotate_field (1);
@@ -3158,28 +3245,16 @@ print_one_breakpoint (struct breakpoint *b,
     internal_error (__FILE__, __LINE__,
                    "bptypes table does not describe type #%d.",
                    (int) b->type);
-#ifdef UI_OUT
   ui_out_field_string (uiout, "type", bptypes[(int) b->type].description);
-#else
-  printf_filtered ("%-14s ", bptypes[(int) b->type].description);
-#endif
 
   /* 3 */
   annotate_field (2);
-#ifdef UI_OUT
   ui_out_field_string (uiout, "disp", bpdisps[(int) b->disposition]);
-#else
-  printf_filtered ("%-4s ", bpdisps[(int) b->disposition]);
-#endif
 
   /* 4 */
   annotate_field (3);
-#ifdef UI_OUT
   ui_out_field_fmt (uiout, "enabled", "%c", bpenables[(int) b->enable_state]);
   ui_out_spaces (uiout, 2);
-#else
-  printf_filtered ("%-3c ", bpenables[(int) b->enable_state]);
-#endif
   
   /* 5 and 6 */
   strcpy (wrap_indent, "                           ");
@@ -3204,16 +3279,11 @@ print_one_breakpoint (struct breakpoint *b,
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
       print_expression (b->exp, stb->stream);
       ui_out_field_stream (uiout, "what", stb);
-#else
-      annotate_field (5);
-      print_expression (b->exp, gdb_stdout);
-#endif
       break;
       
     case bp_catch_load:
@@ -3221,7 +3291,6 @@ print_one_breakpoint (struct breakpoint *b,
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
@@ -3236,13 +3305,6 @@ print_one_breakpoint (struct breakpoint *b,
          ui_out_field_string (uiout, "what", b->dll_pathname);
          ui_out_text (uiout, "\" ");
        }
-#else
-      annotate_field (5);
-      if (b->dll_pathname == NULL)
-       printf_filtered ("<any library> ");
-      else
-       printf_filtered ("library \"%s\" ", b->dll_pathname);
-#endif
       break;
       
     case bp_catch_fork:
@@ -3250,7 +3312,6 @@ print_one_breakpoint (struct breakpoint *b,
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
@@ -3260,18 +3321,11 @@ print_one_breakpoint (struct breakpoint *b,
          ui_out_field_int (uiout, "what", b->forked_inferior_pid);
          ui_out_spaces (uiout, 1);
        }
-#else
-      annotate_field (5);
-      if (b->forked_inferior_pid != 0)
-       printf_filtered ("process %d ", b->forked_inferior_pid);
-      break;
-#endif
       
     case bp_catch_exec:
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
@@ -3281,43 +3335,28 @@ print_one_breakpoint (struct breakpoint *b,
          ui_out_field_string (uiout, "what", b->exec_pathname);
          ui_out_text (uiout, "\" ");
        }
-#else
-      annotate_field (5);
-      if (b->exec_pathname != NULL)
-       printf_filtered ("program \"%s\" ", b->exec_pathname);
-#endif
       break;
 
     case bp_catch_catch:
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
       ui_out_field_string (uiout, "what", "exception catch");
       ui_out_spaces (uiout, 1);
-#else
-      annotate_field (5);
-      printf_filtered ("exception catch ");
-#endif
       break;
 
     case bp_catch_throw:
       /* Field 4, the address, is omitted (which makes the columns
         not line up too nicely with the headers, but the effect
         is relatively readable).  */
-#ifdef UI_OUT
       if (addressprint)
        ui_out_field_skip (uiout, "addr");
       annotate_field (5);
       ui_out_field_string (uiout, "what", "exception throw");
       ui_out_spaces (uiout, 1);
-#else
-      annotate_field (5);
-      printf_filtered ("exception throw ");
-#endif
       break;
       
     case bp_breakpoint:
@@ -3332,7 +3371,7 @@ print_one_breakpoint (struct breakpoint *b,
     case bp_call_dummy:
     case bp_shlib_event:
     case bp_thread_event:
-#ifdef UI_OUT
+    case bp_overlay_event:
       if (addressprint)
        {
          annotate_field (4);
@@ -3360,106 +3399,49 @@ print_one_breakpoint (struct breakpoint *b,
          print_address_symbolic (b->address, stb->stream, demangle, "");
          ui_out_field_stream (uiout, "at", stb);
        }
-#else
-      if (addressprint)
-       {
-         char *tmp;
-
-         annotate_field (4);
-
-         if (TARGET_ADDR_BIT <= 32)
-           tmp = longest_local_hex_string_custom (b->address
-                                                  & (CORE_ADDR) 0xffffffff, 
-                                                  "08l");
-         else
-           tmp = longest_local_hex_string_custom (b->address, "016l");
-
-         printf_filtered ("%s ", tmp);
-       }
-      annotate_field (5);
-      *last_addr = b->address;
-      if (b->source_file)
-       {
-         sym = find_pc_sect_function (b->address, b->section);
-         if (sym)
-           {
-             fputs_filtered ("in ", gdb_stdout);
-             fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
-             wrap_here (wrap_indent);
-             fputs_filtered (" at ", gdb_stdout);
-           }
-         fputs_filtered (b->source_file, gdb_stdout);
-         printf_filtered (":%d", b->line_number);
-       }
-      else
-       print_address_symbolic (b->address, gdb_stdout, demangle, " ");
-#endif
       break;
     }
   
   if (b->thread != -1)
     {
-#ifdef UI_OUT
       /* FIXME: This seems to be redundant and lost here; see the
         "stop only in" line a little further down. */
       ui_out_text (uiout, " thread ");
       ui_out_field_int (uiout, "thread", b->thread);
-#else
-      printf_filtered (" thread %d", b->thread);
-#endif
     }
   
-#ifdef UI_OUT
   ui_out_text (uiout, "\n");
-#else
-  printf_filtered ("\n");
-#endif
   
-  if (b->frame)
+  if (frame_id_p (b->frame_id))
     {
       annotate_field (6);
-#ifdef UI_OUT
       ui_out_text (uiout, "\tstop only in stack frame at ");
-      ui_out_field_core_addr (uiout, "frame", b->frame);
+      /* FIXME: cagney/2002-12-01: Shouldn't be poeking around inside
+         the frame ID.  */
+      ui_out_field_core_addr (uiout, "frame", b->frame_id.base);
       ui_out_text (uiout, "\n");
-#else
-      printf_filtered ("\tstop only in stack frame at ");
-      print_address_numeric (b->frame, 1, gdb_stdout);
-      printf_filtered ("\n");
-#endif
     }
   
   if (b->cond)
     {
       annotate_field (7);
-#ifdef UI_OUT
       ui_out_text (uiout, "\tstop only if ");
       print_expression (b->cond, stb->stream);
       ui_out_field_stream (uiout, "cond", stb);
       ui_out_text (uiout, "\n");
-#else
-      printf_filtered ("\tstop only if ");
-      print_expression (b->cond, gdb_stdout);
-      printf_filtered ("\n");
-#endif
     }
   
   if (b->thread != -1)
     {
       /* FIXME should make an annotation for this */
-#ifdef UI_OUT
       ui_out_text (uiout, "\tstop only in thread ");
       ui_out_field_int (uiout, "thread", b->thread);
       ui_out_text (uiout, "\n");
-#else
-      printf_filtered ("\tstop only in thread %d\n", b->thread);
-#endif
     }
   
   if (show_breakpoint_hit_counts && b->hit_count)
     {
       /* FIXME should make an annotation for this */
-#ifdef UI_OUT
       if (ep_is_catchpoint (b))
        ui_out_text (uiout, "\tcatchpoint");
       else
@@ -3470,55 +3452,33 @@ print_one_breakpoint (struct breakpoint *b,
        ui_out_text (uiout, " time\n");
       else
        ui_out_text (uiout, " times\n");
-#else
-      if (ep_is_catchpoint (b))
-       printf_filtered ("\tcatchpoint");
-      else
-       printf_filtered ("\tbreakpoint");
-      printf_filtered (" already hit %d time%s\n",
-                      b->hit_count, (b->hit_count == 1 ? "" : "s"));
-#endif
     }
   
-#ifdef UI_OUT
   /* Output the count also if it is zero, but only if this is
      mi. FIXME: Should have a better test for this. */
   if (ui_out_is_mi_like_p (uiout))
     if (show_breakpoint_hit_counts && b->hit_count == 0)
       ui_out_field_int (uiout, "times", b->hit_count);
-#endif
 
   if (b->ignore_count)
     {
       annotate_field (8);
-#ifdef UI_OUT
       ui_out_text (uiout, "\tignore next ");
       ui_out_field_int (uiout, "ignore", b->ignore_count);
       ui_out_text (uiout, " hits\n");
-#else
-      printf_filtered ("\tignore next %d hits\n", b->ignore_count);
-#endif
     }
   
   if ((l = b->commands))
     {
+      struct cleanup *script_chain;
+
       annotate_field (9);
-#ifdef UI_OUT
-      ui_out_tuple_begin (uiout, "script");
+      script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script");
       print_command_lines (uiout, l, 4);
-      ui_out_tuple_end (uiout);
-#else
-      while (l)
-       {
-         print_command_line (l, 4, gdb_stdout);
-         l = l->next;
-       }
-#endif
+      do_cleanups (script_chain);
     }
-#ifdef UI_OUT
-  ui_out_tuple_end (uiout);
+  do_cleanups (bkpt_chain);
   do_cleanups (old_chain);
-#endif
 }
 
 struct captured_breakpoint_query_args
@@ -3585,6 +3545,7 @@ breakpoint_1 (int bnum, int allflag)
   register struct breakpoint *b;
   CORE_ADDR last_addr = (CORE_ADDR) -1;
   int nr_printable_breakpoints;
+  struct cleanup *bkpttbl_chain;
   
   /* Compute the number of rows in the table. */
   nr_printable_breakpoints = 0;
@@ -3596,14 +3557,15 @@ breakpoint_1 (int bnum, int allflag)
          nr_printable_breakpoints++;
       }
 
-#ifdef UI_OUT
   if (addressprint)
-    ui_out_table_begin (uiout, 6, nr_printable_breakpoints, "BreakpointTable");
+    bkpttbl_chain 
+      = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
+                                             "BreakpointTable");
   else
-    ui_out_table_begin (uiout, 5, nr_printable_breakpoints, "BreakpointTable");
-#endif /* UI_OUT */
+    bkpttbl_chain 
+      = make_cleanup_ui_out_table_begin_end (uiout, 5, nr_printable_breakpoints,
+                                             "BreakpointTable");
 
-#ifdef UI_OUT
   if (nr_printable_breakpoints > 0)
     annotate_breakpoints_headers ();
   if (nr_printable_breakpoints > 0)
@@ -3633,31 +3595,6 @@ breakpoint_1 (int bnum, int allflag)
   ui_out_table_body (uiout);
   if (nr_printable_breakpoints > 0)
     annotate_breakpoints_table ();
-#else
-  if (nr_printable_breakpoints > 0)
-    {
-      annotate_breakpoints_headers ();
-      annotate_field (0);
-      printf_filtered ("Num ");
-      annotate_field (1);
-      printf_filtered ("Type           ");
-      annotate_field (2);
-      printf_filtered ("Disp ");
-      annotate_field (3);
-      printf_filtered ("Enb ");
-      if (addressprint)
-       {
-         annotate_field (4);
-         if (TARGET_ADDR_BIT <= 32)
-           printf_filtered ("Address    ");
-         else
-           printf_filtered ("Address            ");
-       }
-      annotate_field (5);
-      printf_filtered ("What\n");
-      annotate_breakpoints_table ();
-    }
-#endif /* UI_OUT */
 
   ALL_BREAKPOINTS (b)
     if (bnum == -1
@@ -3669,25 +3606,15 @@ breakpoint_1 (int bnum, int allflag)
          print_one_breakpoint (b, &last_addr);
       }
   
-
-#ifdef UI_OUT
-  ui_out_table_end (uiout);
-#endif /* UI_OUT */
+  do_cleanups (bkpttbl_chain);
 
   if (nr_printable_breakpoints == 0)
     {
-#ifdef UI_OUT
       if (bnum == -1)
        ui_out_message (uiout, 0, "No breakpoints or watchpoints.\n");
       else
        ui_out_message (uiout, 0, "No breakpoint or watchpoint number %d.\n",
                        bnum);
-#else
-      if (bnum == -1)
-       printf_filtered ("No breakpoints or watchpoints.\n");
-      else
-       printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
-#endif /* UI_OUT */
     }
   else
     {
@@ -3735,29 +3662,29 @@ describe_other_breakpoints (CORE_ADDR pc, asection *section)
   register struct breakpoint *b;
 
   ALL_BREAKPOINTS (b)
-    if (b->address == pc)
-    if (overlay_debugging == 0 ||
-       b->section == section)
-      others++;
+    if (b->address == pc)      /* address match / overlay match */
+      if (!overlay_debugging || b->section == section)
+       others++;
   if (others > 0)
     {
       printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
       ALL_BREAKPOINTS (b)
-       if (b->address == pc)
-       if (overlay_debugging == 0 ||
-           b->section == section)
-         {
-           others--;
-           printf_filtered ("%d%s%s ",
-                            b->number,
-                            ((b->enable_state == bp_disabled || 
-                              b->enable_state == bp_shlib_disabled || 
-                              b->enable_state == bp_call_disabled) ? " (disabled)" 
-                             : b->enable_state == bp_permanent ? " (permanent)"
-                             : ""),
-                            (others > 1) ? "," 
-                            : ((others == 1) ? " and" : ""));
-         }
+       if (b->address == pc)   /* address match / overlay match */
+         if (!overlay_debugging || b->section == section)
+           {
+             others--;
+             printf_filtered ("%d%s%s ",
+                              b->number,
+                              ((b->enable_state == bp_disabled || 
+                                b->enable_state == bp_shlib_disabled || 
+                                b->enable_state == bp_call_disabled) 
+                               ? " (disabled)" 
+                               : b->enable_state == bp_permanent 
+                               ? " (permanent)"
+                               : ""),
+                              (others > 1) ? "," 
+                              : ((others == 1) ? " and" : ""));
+           }
       printf_filtered ("also set at pc ");
       print_address_numeric (pc, 1, gdb_stdout);
       printf_filtered (".\n");
@@ -3833,8 +3760,8 @@ check_duplicates (struct breakpoint *bpt)
     if (b->enable_state != bp_disabled
        && b->enable_state != bp_shlib_disabled
        && b->enable_state != bp_call_disabled
-       && b->address == address
-       && (overlay_debugging == 0 || b->section == section)
+       && b->address == address        /* address / overlay match */
+       && (!overlay_debugging || b->section == section)
        && breakpoint_address_is_meaningful (b))
     {
       /* Have we found a permanent breakpoint?  */
@@ -3872,8 +3799,8 @@ check_duplicates (struct breakpoint *bpt)
            if (b->enable_state != bp_disabled
                && b->enable_state != bp_shlib_disabled
                && b->enable_state != bp_call_disabled
-               && b->address == address
-               && (overlay_debugging == 0 || b->section == section)
+               && b->address == address        /* address / overlay match */
+               && (!overlay_debugging || b->section == section)
                && breakpoint_address_is_meaningful (b))
              b->duplicate = 1;
          }
@@ -3919,7 +3846,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
   b->silent = 0;
   b->ignore_count = 0;
   b->commands = NULL;
-  b->frame = 0;
+  b->frame_id = null_frame_id;
   b->dll_pathname = NULL;
   b->triggered_dll_pathname = NULL;
   b->forked_inferior_pid = 0;
@@ -3957,40 +3884,48 @@ make_breakpoint_permanent (struct breakpoint *b)
   b->inserted = 1;
 }
 
-#ifdef GET_LONGJMP_TARGET
+static struct breakpoint *
+create_internal_breakpoint (CORE_ADDR address, enum bptype type)
+{
+  static int internal_breakpoint_number = -1;
+  struct symtab_and_line sal;
+  struct breakpoint *b;
+
+  init_sal (&sal);             /* initialize to zeroes */
+
+  sal.pc = address;
+  sal.section = find_pc_overlay (sal.pc);
+
+  b = set_raw_breakpoint (sal, type);
+  b->number = internal_breakpoint_number--;
+  b->disposition = disp_donttouch;
+
+  return b;
+}
+
 
 static void
 create_longjmp_breakpoint (char *func_name)
 {
-  struct symtab_and_line sal;
   struct breakpoint *b;
+  struct minimal_symbol *m;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
-  if (func_name != NULL)
+  if (func_name == NULL)
+    b = create_internal_breakpoint (0, bp_longjmp_resume);
+  else
     {
-      struct minimal_symbol *m;
-
-      m = lookup_minimal_symbol_text (func_name, NULL, 
-                                     (struct objfile *) NULL);
-      if (m)
-       sal.pc = SYMBOL_VALUE_ADDRESS (m);
-      else
+      if ((m = lookup_minimal_symbol_text (func_name, NULL, NULL)) == NULL)
        return;
+      b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m), bp_longjmp);
     }
-  sal.section = find_pc_overlay (sal.pc);
-  b = set_raw_breakpoint (sal,
-                          func_name != NULL ? bp_longjmp : bp_longjmp_resume);
 
-  b->disposition = disp_donttouch;
   b->enable_state = bp_disabled;
   b->silent = 1;
   if (func_name)
     b->addr_string = xstrdup (func_name);
-  b->number = internal_breakpoint_number--;
 }
 
-#endif /* #ifdef GET_LONGJMP_TARGET */
-
 /* Call this routine when stepping and nexting to enable a breakpoint
    if we do a longjmp().  When we hit that breakpoint, call
    set_longjmp_resume_breakpoint() to figure out where we are going. */
@@ -4022,24 +3957,69 @@ disable_longjmp_breakpoint (void)
     }
 }
 
+static void
+create_overlay_event_breakpoint (char *func_name)
+{
+  struct breakpoint *b;
+  struct minimal_symbol *m;
+
+  if ((m = lookup_minimal_symbol_text (func_name, NULL, NULL)) == NULL)
+    return;
+  b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m), 
+                                 bp_overlay_event);
+  b->addr_string = xstrdup (func_name);
+
+  if (overlay_debugging == ovly_auto)
+    {
+      b->enable_state = bp_enabled;
+      overlay_events_enabled = 1;
+    }
+  else 
+    {
+      b->enable_state = bp_disabled;
+      overlay_events_enabled = 0;
+    }
+}
+
+void
+enable_overlay_breakpoints (void)
+{
+  register struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (b->type == bp_overlay_event)
+    {
+      b->enable_state = bp_enabled;
+      check_duplicates (b);
+      overlay_events_enabled = 1;
+    }
+}
+
+void
+disable_overlay_breakpoints (void)
+{
+  register struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (b->type == bp_overlay_event)
+    {
+      b->enable_state = bp_disabled;
+      check_duplicates (b);
+      overlay_events_enabled = 0;
+    }
+}
+
 struct breakpoint *
 create_thread_event_breakpoint (CORE_ADDR address)
 {
   struct breakpoint *b;
-  struct symtab_and_line sal;
-  char addr_string[80];                /* Surely an addr can't be longer than that. */
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
-  sal.pc = address;
-  sal.section = find_pc_overlay (sal.pc);
-  b = set_raw_breakpoint (sal, bp_thread_event);
+  b = create_internal_breakpoint (address, bp_thread_event);
   
-  b->number = internal_breakpoint_number--;
-  b->disposition = disp_donttouch;
   b->enable_state = bp_enabled;
   /* addr_string has to be used or breakpoint_re_set will delete me.  */
-  sprintf (addr_string, "*0x%s", paddr (b->address));
-  b->addr_string = xstrdup (addr_string);
+  xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
 
   return b;
 }
@@ -4069,15 +4049,8 @@ struct breakpoint *
 create_solib_event_breakpoint (CORE_ADDR address)
 {
   struct breakpoint *b;
-  struct symtab_and_line sal;
-
-  INIT_SAL (&sal);             /* initialize to zeroes */
-  sal.pc = address;
-  sal.section = find_pc_overlay (sal.pc);
-  b = set_raw_breakpoint (sal, bp_shlib_event);
-  b->number = internal_breakpoint_number--;
-  b->disposition = disp_donttouch;
 
+  b = create_internal_breakpoint (address, bp_shlib_event);
   return b;
 }
 
@@ -4236,7 +4209,7 @@ create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
   struct breakpoint *b;
   int thread = -1;             /* All threads. */
 
-  INIT_SAL (&sal);
+  init_sal (&sal);
   sal.pc = 0;
   sal.symtab = NULL;
   sal.line = 0;
@@ -4275,7 +4248,7 @@ create_exec_event_catchpoint (int tempflag, char *cond_string)
   struct breakpoint *b;
   int thread = -1;             /* All threads. */
 
-  INIT_SAL (&sal);
+  init_sal (&sal);
   sal.pc = 0;
   sal.symtab = NULL;
   sal.line = 0;
@@ -4339,7 +4312,7 @@ hw_watchpoint_used_count (enum bptype type, int *other_type_used)
    that gets deleted automatically... */
 
 void
-set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_info *frame)
+set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_id frame_id)
 {
   register struct breakpoint *b;
 
@@ -4348,10 +4321,7 @@ set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_info *frame)
     {
       b->address = pc;
       b->enable_state = bp_enabled;
-      if (frame != NULL)
-       b->frame = frame->frame;
-      else
-       b->frame = 0;
+      b->frame_id = frame_id;
       check_duplicates (b);
       return;
     }
@@ -4403,14 +4373,14 @@ enable_watchpoints_after_interactive_call_stop (void)
    Restrict it to frame FRAME if FRAME is nonzero.  */
 
 struct breakpoint *
-set_momentary_breakpoint (struct symtab_and_line sal, struct frame_info *frame,
+set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
                          enum bptype type)
 {
   register struct breakpoint *b;
   b = set_raw_breakpoint (sal, type);
   b->enable_state = bp_enabled;
   b->disposition = disp_donttouch;
-  b->frame = (frame ? frame->frame : 0);
+  b->frame_id = frame_id;
 
   /* If we're debugging a multi-threaded program, then we
      want momentary breakpoints to be active in only a 
@@ -4428,13 +4398,11 @@ static void
 mention (struct breakpoint *b)
 {
   int say_where = 0;
-#ifdef UI_OUT
-  struct cleanup *old_chain;
+  struct cleanup *old_chain, *ui_out_chain;
   struct ui_stream *stb;
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
-#endif /* UI_OUT */
 
   /* FIXME: This is misplaced; mention() is called by things (like hitting a
      watchpoint) other than breakpoint creation.  It should be possible to
@@ -4450,84 +4418,57 @@ mention (struct breakpoint *b)
     case bp_none:
       printf_filtered ("(apparently deleted?) Eventpoint %d: ", b->number);
       break;
-#ifdef UI_OUT
     case bp_watchpoint:
       ui_out_text (uiout, "Watchpoint ");
-      ui_out_tuple_begin (uiout, "wpt");
+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
       ui_out_field_int (uiout, "number", b->number);
       ui_out_text (uiout, ": ");
       print_expression (b->exp, stb->stream);
       ui_out_field_stream (uiout, "exp", stb);
-      ui_out_tuple_end (uiout);
+      do_cleanups (ui_out_chain);
       break;
     case bp_hardware_watchpoint:
       ui_out_text (uiout, "Hardware watchpoint ");
-      ui_out_tuple_begin (uiout, "wpt");
+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
       ui_out_field_int (uiout, "number", b->number);
       ui_out_text (uiout, ": ");
       print_expression (b->exp, stb->stream);
       ui_out_field_stream (uiout, "exp", stb);
-      ui_out_tuple_end (uiout);
-      break;
-#else
-    case bp_watchpoint:
-      printf_filtered ("Watchpoint %d: ", b->number);
-      print_expression (b->exp, gdb_stdout);
-      break;
-    case bp_hardware_watchpoint:
-      printf_filtered ("Hardware watchpoint %d: ", b->number);
-      print_expression (b->exp, gdb_stdout);
+      do_cleanups (ui_out_chain);
       break;
-#endif
-#ifdef UI_OUT
     case bp_read_watchpoint:
       ui_out_text (uiout, "Hardware read watchpoint ");
-      ui_out_tuple_begin (uiout, "hw-rwpt");
+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt");
       ui_out_field_int (uiout, "number", b->number);
       ui_out_text (uiout, ": ");
       print_expression (b->exp, stb->stream);
       ui_out_field_stream (uiout, "exp", stb);
-      ui_out_tuple_end (uiout);
+      do_cleanups (ui_out_chain);
       break;
     case bp_access_watchpoint:
       ui_out_text (uiout, "Hardware access (read/write) watchpoint ");
-      ui_out_tuple_begin (uiout, "hw-awpt");
+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt");
       ui_out_field_int (uiout, "number", b->number);
       ui_out_text (uiout, ": ");
       print_expression (b->exp, stb->stream);
       ui_out_field_stream (uiout, "exp", stb);
-      ui_out_tuple_end (uiout);
-      break;
-#else
-    case bp_read_watchpoint:
-      printf_filtered ("Hardware read watchpoint %d: ", b->number);
-      print_expression (b->exp, gdb_stdout);
-      break;
-    case bp_access_watchpoint:
-      printf_filtered ("Hardware access (read/write) watchpoint %d: ", 
-                      b->number);
-      print_expression (b->exp, gdb_stdout);
+      do_cleanups (ui_out_chain);
       break;
-#endif
     case bp_breakpoint:
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        {
          say_where = 0;
          break;
        }
-#endif
       printf_filtered ("Breakpoint %d", b->number);
       say_where = 1;
       break;
     case bp_hardware_breakpoint:
-#ifdef UI_OUT
       if (ui_out_is_mi_like_p (uiout))
        {
          say_where = 0;
          break;
        }
-#endif
       printf_filtered ("Hardware assisted breakpoint %d", b->number);
       say_where = 1;
       break;
@@ -4566,6 +4507,7 @@ mention (struct breakpoint *b)
     case bp_watchpoint_scope:
     case bp_shlib_event:
     case bp_thread_event:
+    case bp_overlay_event:
       break;
     }
   if (say_where)
@@ -4579,13 +4521,9 @@ mention (struct breakpoint *b)
        printf_filtered (": file %s, line %d.",
                         b->source_file, b->line_number);
     }
-#ifdef UI_OUT
   do_cleanups (old_chain);
-#endif
-#ifdef UI_OUT
   if (ui_out_is_mi_like_p (uiout))
     return;
-#endif
   printf_filtered ("\n");
 }
 \f
@@ -4634,7 +4572,12 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
        b->number = breakpoint_count;
        b->cond = cond[i];
        b->thread = thread;
-       b->addr_string = addr_string[i];
+       if (addr_string[i])
+         b->addr_string = addr_string[i];
+       else
+         /* addr_string has to be used or breakpoint_re_set will delete
+            me.  */
+         xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
        b->cond_string = cond_string[i];
        b->ignore_count = ignore_count;
        b->enable_state = bp_enabled;
@@ -4664,7 +4607,7 @@ parse_breakpoint_sals (char **address,
       if (default_breakpoint_valid)
        {
          struct symtab_and_line sal;
-         INIT_SAL (&sal);              /* initialize to zeroes */
+         init_sal (&sal);              /* initialize to zeroes */
          sals->sals = (struct symtab_and_line *)
            xmalloc (sizeof (struct symtab_and_line));
          sal.pc = default_breakpoint_address;
@@ -4682,10 +4625,16 @@ parse_breakpoint_sals (char **address,
       /* Force almost all breakpoints to be in terms of the
          current_source_symtab (which is decode_line_1's default).  This
          should produce the results we want almost all of the time while
-         leaving default_breakpoint_* alone.  */
+         leaving default_breakpoint_* alone.  
+         ObjC: However, don't match an Objective-C method name which
+         may have a '+' or '-' succeeded by a '[' */
+        
+      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+                       
       if (default_breakpoint_valid
-         && (!current_source_symtab
-             || (strchr ("+-", (*address)[0]) != NULL)))
+         && (!cursal.symtab
+             || ((strchr ("+-", (*address)[0]) != NULL)
+                 && ((*address)[1] != '['))))
        *sals = decode_line_1 (address, 1, default_breakpoint_symtab,
                               default_breakpoint_line, addr_string);
       else
@@ -5018,9 +4967,9 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
 
       if (default_breakpoint_valid)
        {
-         if (selected_frame)
+         if (deprecated_selected_frame)
            {
-             selected_pc = selected_frame->pc;
+             selected_pc = get_frame_pc (deprecated_selected_frame);
              if (arg)
                if_arg = 1;
            }
@@ -5049,7 +4998,7 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
 
       frame = parse_frame_specification (level_arg);
       if (frame)
-       selected_pc = frame->pc;
+       selected_pc = get_frame_pc (frame);
       else
        selected_pc = 0;
     }
@@ -5096,10 +5045,11 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
     {
       if (default_breakpoint_valid)
        {
-         if (selected_frame)
+         if (deprecated_selected_frame)
            {
              addr_string = (char *) xmalloc (15);
-             sprintf (addr_string, "*0x%s", paddr_nz (selected_frame->pc));
+             sprintf (addr_string, "*0x%s",
+                      paddr_nz (get_frame_pc (deprecated_selected_frame)));
              if (arg)
                if_arg = 1;
            }
@@ -5220,13 +5170,13 @@ break_command (char *arg, int from_tty)
   break_command_1 (arg, 0, from_tty);
 }
 
-static void
+void
 break_at_finish_command (char *arg, int from_tty)
 {
   break_at_finish_command_1 (arg, 0, from_tty);
 }
 
-static void
+void
 break_at_finish_at_depth_command (char *arg, int from_tty)
 {
   break_at_finish_at_depth_command_1 (arg, 0, from_tty);
@@ -5238,7 +5188,7 @@ tbreak_command (char *arg, int from_tty)
   break_command_1 (arg, BP_TEMPFLAG, from_tty);
 }
 
-static void
+void
 tbreak_at_finish_command (char *arg, int from_tty)
 {
   break_at_finish_command_1 (arg, BP_TEMPFLAG, from_tty);
@@ -5354,7 +5304,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
   enum bptype bp_type;
   int mem_cnt = 0;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
+  init_sal (&sal);             /* initialize to zeroes */
 
   /* Parse arguments.  */
   innermost_block = NULL;
@@ -5455,10 +5405,12 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
   if (frame)
     {
       prev_frame = get_prev_frame (frame);
-      b->watchpoint_frame = frame->frame;
+      b->watchpoint_frame = get_frame_id (frame);
     }
   else
-    b->watchpoint_frame = (CORE_ADDR) 0;
+    {
+      memset (&b->watchpoint_frame, 0, sizeof (b->watchpoint_frame));
+    }
 
   /* If the expression is "local", then set up a "watchpoint scope"
      breakpoint at the point where we've left the scope of the watchpoint
@@ -5468,16 +5420,8 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
       if (prev_frame)
        {
          struct breakpoint *scope_breakpoint;
-         struct symtab_and_line scope_sal;
-
-         INIT_SAL (&scope_sal);        /* initialize to zeroes */
-         scope_sal.pc = get_frame_pc (prev_frame);
-         scope_sal.section = find_pc_overlay (scope_sal.pc);
-
-         scope_breakpoint = set_raw_breakpoint (scope_sal,
-                                                bp_watchpoint_scope);
-         set_breakpoint_count (breakpoint_count + 1);
-         scope_breakpoint->number = breakpoint_count;
+         scope_breakpoint = create_internal_breakpoint (get_frame_pc (prev_frame),
+                                                        bp_watchpoint_scope);
 
          scope_breakpoint->enable_state = bp_enabled;
 
@@ -5485,7 +5429,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
          scope_breakpoint->disposition = disp_del;
 
          /* Only break in the proper frame (help with recursion).  */
-         scope_breakpoint->frame = prev_frame->frame;
+         scope_breakpoint->frame_id = get_frame_id (prev_frame);
 
          /* Set the address at which we will stop.  */
          scope_breakpoint->address = get_frame_pc (prev_frame);
@@ -5585,39 +5529,36 @@ can_use_hardware_watchpoint (struct value *v)
   return found_memory_cnt;
 }
 
-#ifdef UI_OUT
 void
 watch_command_wrapper (char *arg, int from_tty)
 {
   watch_command (arg, from_tty);
 }
-#endif
+
 static void
 watch_command (char *arg, int from_tty)
 {
   watch_command_1 (arg, hw_write, from_tty);
 }
 
-#ifdef UI_OUT
 void
 rwatch_command_wrapper (char *arg, int from_tty)
 {
   rwatch_command (arg, from_tty);
 }
-#endif
+
 static void
 rwatch_command (char *arg, int from_tty)
 {
   watch_command_1 (arg, hw_read, from_tty);
 }
 
-#ifdef UI_OUT
 void
 awatch_command_wrapper (char *arg, int from_tty)
 {
   awatch_command (arg, from_tty);
 }
-#endif
+
 static void
 awatch_command (char *arg, int from_tty)
 {
@@ -5643,11 +5584,11 @@ until_break_command_continuation (struct continuation_arg *arg)
 
 /* ARGSUSED */
 void
-until_break_command (char *arg, int from_tty)
+until_break_command (char *arg, int from_tty, int anywhere)
 {
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  struct frame_info *prev_frame = get_prev_frame (selected_frame);
+  struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
   struct breakpoint *breakpoint;
   struct cleanup *old_chain;
   struct continuation_arg *arg1;
@@ -5676,7 +5617,16 @@ until_break_command (char *arg, int from_tty)
 
   resolve_sal_pc (&sal);
 
-  breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
+  if (anywhere)
+    /* If the user told us to continue until a specified location,
+       we don't specify a frame at which we need to stop.  */
+    breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
+  else
+    /* Otherwise, specify the current frame, because we want to stop only
+       at the very same frame.  */
+    breakpoint = set_momentary_breakpoint (sal,
+                                          get_frame_id (deprecated_selected_frame),
+                                          bp_until);
 
   if (!event_loop_p || !target_can_async_p ())
     old_chain = make_cleanup_delete_breakpoint (breakpoint);
@@ -5704,13 +5654,14 @@ until_break_command (char *arg, int from_tty)
       add_continuation (until_break_command_continuation, arg1);
     }
 
-  /* Keep within the current frame */
-
+  /* Keep within the current frame, or in frames called by the current
+     one.  */
   if (prev_frame)
     {
-      sal = find_pc_line (prev_frame->pc, 0);
-      sal.pc = prev_frame->pc;
-      breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
+      sal = find_pc_line (get_frame_pc (prev_frame), 0);
+      sal.pc = get_frame_pc (prev_frame);
+      breakpoint = set_momentary_breakpoint (sal, get_frame_id (prev_frame),
+                                            bp_until);
       if (!event_loop_p || !target_can_async_p ())
        make_cleanup_delete_breakpoint (breakpoint);
       else
@@ -5723,7 +5674,7 @@ until_break_command (char *arg, int from_tty)
   if (!event_loop_p || !target_can_async_p ())
     do_cleanups (old_chain);
 }
-\f
+
 #if 0
 /* These aren't used; I don't konw what they were for.  */
 /* Set a breakpoint at the catch clause for NAME.  */
@@ -5834,10 +5785,10 @@ get_catch_sals (int this_level_only)
 
   /* Not sure whether an error message is always the correct response,
      but it's better than a core dump.  */
-  if (selected_frame == NULL)
+  if (deprecated_selected_frame == NULL)
     error ("No selected frame.");
-  block = get_frame_block (selected_frame);
-  pc = selected_frame->pc;
+  block = get_frame_block (deprecated_selected_frame, 0);
+  pc = get_frame_pc (deprecated_selected_frame);
 
   sals.nelts = 0;
   sals.sals = NULL;
@@ -6289,7 +6240,7 @@ catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
    inside a catch_errors */
 
 static int
-cover_target_enable_exception_callback (PTR arg)
+cover_target_enable_exception_callback (void *arg)
 {
   args_for_catchpoint_enable *args = arg;
   struct symtab_and_line *sal;
@@ -6329,7 +6280,7 @@ handle_gnu_4_16_catch_command (char *arg, int tempflag, int from_tty)
   char *save_arg;
   int i;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
+  init_sal (&sal);             /* initialize to zeroes */
 
   /* If no arg given, or if first arg is 'if ', all active catch clauses
      are breakpointed. */
@@ -6407,30 +6358,6 @@ handle_gnu_4_16_catch_command (char *arg, int tempflag, int from_tty)
   xfree (sals.sals);
 }
 
-#if 0
-/* This creates a temporary internal breakpoint
-   just to placate infrun */
-static struct breakpoint *
-create_temp_exception_breakpoint (CORE_ADDR pc)
-{
-  struct symtab_and_line sal;
-  struct breakpoint *b;
-
-  INIT_SAL (&sal);
-  sal.pc = pc;
-  sal.symtab = NULL;
-  sal.line = 0;
-
-  b = set_raw_breakpoint (sal, bp_breakpoint);
-
-  b->disposition = disp_del;
-  b->enable_state = bp_enabled;
-  b->silent = 1;
-  b->number = internal_breakpoint_number--;
-  return b;
-}
-#endif
-
 static void
 catch_command_1 (char *arg, int tempflag, int from_tty)
 {
@@ -6603,15 +6530,15 @@ tcatch_command (char *arg, int from_tty)
   catch_command_1 (arg, 1, from_tty);
 }
 
+/* Delete breakpoints by address or line.  */
 
 static void
 clear_command (char *arg, int from_tty)
 {
-  register struct breakpoint *b, *b1;
+  struct breakpoint *b, *tmp, *prev, *found;
   int default_match;
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  register struct breakpoint *found;
   int i;
 
   if (arg)
@@ -6623,7 +6550,8 @@ clear_command (char *arg, int from_tty)
     {
       sals.sals = (struct symtab_and_line *)
        xmalloc (sizeof (struct symtab_and_line));
-      INIT_SAL (&sal);         /* initialize to zeroes */
+      make_cleanup (xfree, sals.sals);
+      init_sal (&sal);         /* initialize to zeroes */
       sal.line = default_breakpoint_line;
       sal.symtab = default_breakpoint_symtab;
       sal.pc = default_breakpoint_address;
@@ -6637,13 +6565,11 @@ clear_command (char *arg, int from_tty)
     }
 
   /* For each line spec given, delete bps which correspond
-     to it.  We do this in two loops: the first loop looks at
-     the initial bp(s) in the chain which should be deleted,
-     the second goes down the rest of the chain looking ahead
-     one so it can take those bps off the chain without messing
-     up the chain. */
-
+     to it.  Do it in two passes, solely to preserve the current
+     behavior that from_tty is forced true if we delete more than
+     one breakpoint.  */
 
+  found = NULL;
   for (i = 0; i < sals.nelts; i++)
     {
       /* If exact pc given, clear bpts at that pc.
@@ -6659,83 +6585,75 @@ clear_command (char *arg, int from_tty)
          1              0             <can't happen> */
 
       sal = sals.sals[i];
-      found = (struct breakpoint *) 0;
-
-
-      while (breakpoint_chain
-      /* Why don't we check here that this is not
-         a watchpoint, etc., as we do below?
-         I can't make it fail, but don't know
-         what's stopping the failure: a watchpoint
-         of the same address as "sal.pc" should
-         wind up being deleted. */
-
-            && (((sal.pc && (breakpoint_chain->address == sal.pc)) &&
-                 (overlay_debugging == 0 ||
-                  breakpoint_chain->section == sal.section))
-                || ((default_match || (0 == sal.pc))
-                    && breakpoint_chain->source_file != NULL
-                    && sal.symtab != NULL
-             && STREQ (breakpoint_chain->source_file, sal.symtab->filename)
-                    && breakpoint_chain->line_number == sal.line)))
+      prev = NULL;
 
+      /* Find all matching breakpoints, remove them from the
+        breakpoint chain, and add them to the 'found' chain.  */
+      ALL_BREAKPOINTS_SAFE (b, tmp)
        {
-         b1 = breakpoint_chain;
-         breakpoint_chain = b1->next;
-         b1->next = found;
-         found = b1;
-       }
-
-      ALL_BREAKPOINTS (b)
-
-       while (b->next
-              && b->next->type != bp_none
-              && b->next->type != bp_watchpoint
-              && b->next->type != bp_hardware_watchpoint
-              && b->next->type != bp_read_watchpoint
-              && b->next->type != bp_access_watchpoint
-              && (((sal.pc && (b->next->address == sal.pc)) &&
-                   (overlay_debugging == 0 ||
-                    b->next->section == sal.section))
-                  || ((default_match || (0 == sal.pc))
-                      && b->next->source_file != NULL
-                      && sal.symtab != NULL
-                      && STREQ (b->next->source_file, sal.symtab->filename)
-                      && b->next->line_number == sal.line)))
-
-
-       {
-         b1 = b->next;
-         b->next = b1->next;
-         b1->next = found;
-         found = b1;
-       }
-
-      if (found == 0)
-       {
-         if (arg)
-           error ("No breakpoint at %s.", arg);
+         /* Are we going to delete b? */
+         if (b->type != bp_none
+             && b->type != bp_watchpoint
+             && b->type != bp_hardware_watchpoint
+             && b->type != bp_read_watchpoint
+             && b->type != bp_access_watchpoint
+             /* Not if b is a watchpoint of any sort... */
+             && (((sal.pc && (b->address == sal.pc)) 
+                  && (!section_is_overlay (b->section)
+                      || b->section == sal.section))
+                 /* Yes, if sal.pc matches b (modulo overlays).  */
+                 || ((default_match || (0 == sal.pc))
+                     && b->source_file != NULL
+                     && sal.symtab != NULL
+                     && STREQ (b->source_file, sal.symtab->filename)
+                     && b->line_number == sal.line)))
+           /* Yes, if sal source file and line matches b.  */
+           {
+             /* Remove it from breakpoint_chain...  */
+             if (b == breakpoint_chain)
+               {
+                 /* b is at the head of the list */
+                 breakpoint_chain = b->next;
+               }
+             else
+               {
+                 prev->next = b->next;
+               }
+             /* And add it to 'found' chain.  */
+             b->next = found;
+             found = b;
+           }
          else
-           error ("No breakpoint at this line.");
+           {
+             /* Keep b, and keep a pointer to it.  */
+             prev = b;
+           }
        }
+    }
+  /* Now go thru the 'found' chain and delete them.  */
+  if (found == 0)
+    {
+      if (arg)
+       error ("No breakpoint at %s.", arg);
+      else
+       error ("No breakpoint at this line.");
+    }
 
-      if (found->next)
-       from_tty = 1;           /* Always report if deleted more than one */
-      if (from_tty)
-       printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
-      breakpoints_changed ();
-      while (found)
-       {
-         if (from_tty)
-           printf_unfiltered ("%d ", found->number);
-         b1 = found->next;
-         delete_breakpoint (found);
-         found = b1;
-       }
+  if (found->next)
+    from_tty = 1;              /* Always report if deleted more than one */
+  if (from_tty)
+    printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
+  breakpoints_changed ();
+  while (found)
+    {
       if (from_tty)
-       putchar_unfiltered ('\n');
+       printf_unfiltered ("%d ", found->number);
+      tmp = found->next;
+      delete_breakpoint (found);
+      found = tmp;
     }
-  xfree (sals.sals);
+  if (from_tty)
+    putchar_unfiltered ('\n');
 }
 \f
 /* Delete breakpoint in BS if they are `delete' breakpoints and
@@ -6862,11 +6780,32 @@ delete_breakpoint (struct breakpoint *bpt)
          else
            val = target_insert_breakpoint (b->address, b->shadow_contents);
 
+         /* If there was an error in the insert, print a message, then stop execution.  */
          if (val != 0)
            {
+             struct ui_file *tmp_error_stream = mem_fileopen ();
+             make_cleanup_ui_file_delete (tmp_error_stream);
+            
+
+             if (b->type == bp_hardware_breakpoint)
+               {
+                 fprintf_unfiltered (tmp_error_stream, 
+                                       "Cannot insert hardware breakpoint %d.\n"
+                                     "You may have requested too many hardware breakpoints.\n",
+                                       b->number);
+                 }
+               else
+                 {
+                   fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n", b->number);
+                   fprintf_filtered (tmp_error_stream, "Error accessing memory address ");
+                   print_address_numeric (b->address, 1, tmp_error_stream);
+                   fprintf_filtered (tmp_error_stream, ": %s.\n",
+                                     safe_strerror (val));
+                 }
+             
+             fprintf_unfiltered (tmp_error_stream,"The same program may be running in another process.");
              target_terminal_ours_for_output ();
-             warning ("Cannot insert breakpoint %d:", b->number);
-             memory_error (val, b->address);   /* which bombs us out */
+             error_stream(tmp_error_stream); 
            }
          else
            b->inserted = 1;
@@ -6902,14 +6841,8 @@ delete_breakpoint (struct breakpoint *bpt)
     if (bs->breakpoint_at == bpt)
       {
        bs->breakpoint_at = NULL;
-
-       /* we'd call bpstat_clear_actions, but that free's stuff and due
-          to the multiple pointers pointing to one item with no
-          reference counts found anywhere through out the bpstat's (how
-          do you spell fragile?), we don't want to free things twice --
-          better a memory leak than a corrupt malloc pool! */
-       bs->commands = NULL;
        bs->old_val = NULL;
+       /* bs->commands will be freed later.  */
       }
   /* On the chance that someone will soon try again to delete this same
      bp, we mark it as deleted before freeing its storage. */
@@ -6941,6 +6874,8 @@ delete_command (char *arg, int from_tty)
 {
   struct breakpoint *b, *temp;
 
+  dont_repeat ();
+
   if (arg == 0)
     {
       int breaks_to_delete = 0;
@@ -6953,6 +6888,7 @@ delete_command (char *arg, int from_tty)
        if (b->type != bp_call_dummy &&
            b->type != bp_shlib_event &&
            b->type != bp_thread_event &&
+           b->type != bp_overlay_event &&
            b->number >= 0)
          breaks_to_delete = 1;
       }
@@ -6966,6 +6902,7 @@ delete_command (char *arg, int from_tty)
            if (b->type != bp_call_dummy &&
                b->type != bp_shlib_event &&
                b->type != bp_thread_event &&
+               b->type != bp_overlay_event &&
                b->number >= 0)
              delete_breakpoint (b);
          }
@@ -6980,7 +6917,7 @@ delete_command (char *arg, int from_tty)
    Unused in this case.  */
 
 static int
-breakpoint_re_set_one (PTR bint)
+breakpoint_re_set_one (void *bint)
 {
   /* get past catch_errs */
   struct breakpoint *b = (struct breakpoint *) bint;
@@ -7006,10 +6943,32 @@ breakpoint_re_set_one (PTR bint)
          delete_breakpoint (b);
          return 0;
        }
-      /* In case we have a problem, disable this breakpoint.  We'll restore
-         its status if we succeed.  */
+      /* HACK: cagney/2001-11-11: kettenis/2001-11-11: MarkK wrote:
+
+        ``And a hack it is, although Apple's Darwin version of GDB
+        contains an almost identical hack to implement a "future
+        break" command.  It seems to work in many real world cases,
+        but it is easy to come up with a test case where the patch
+        doesn't help at all.''
+
+        ``It seems that the way GDB implements breakpoints - in -
+        shared - libraries was designed for a.out shared library
+        systems (SunOS 4) where shared libraries were loaded at a
+        fixed address in memory.  Since ELF shared libraries can (and
+        will) be loaded at any address in memory, things break.
+        Fixing this is not trivial.  Therefore, I'm not sure whether
+        we should add this hack to the branch only.  I cannot
+        guarantee that things will be fixed on the trunk in the near
+        future.''
+
+         In case we have a problem, disable this breakpoint.  We'll
+         restore its status if we succeed.  Don't disable a
+         shlib_disabled breakpoint though.  There's a fair chance we
+         can't re-set it if the shared library it's in hasn't been
+         loaded yet.  */
       save_enable = b->enable_state;
-      b->enable_state = bp_disabled;
+      if (b->enable_state != bp_shlib_disabled)
+        b->enable_state = bp_disabled;
 
       set_language (b->language);
       input_radix = b->input_radix;
@@ -7055,7 +7014,7 @@ breakpoint_re_set_one (PTR bint)
              b->address = sals.sals[i].pc;
 
              /* Used to check for duplicates here, but that can
-                cause trouble, as it doesn't check for disable
+                cause trouble, as it doesn't check for disabled
                 breakpoints. */
 
              mention (b);
@@ -7099,7 +7058,7 @@ breakpoint_re_set_one (PTR bint)
        value_free (b->val);
       b->val = evaluate_expression (b->exp);
       release_value (b->val);
-      if (VALUE_LAZY (b->val))
+      if (VALUE_LAZY (b->val) && b->enable_state == bp_enabled)
        value_fetch_lazy (b->val);
 
       if (b->cond_string != NULL)
@@ -7127,10 +7086,11 @@ breakpoint_re_set_one (PTR bint)
     default:
       printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
       /* fall through */
-      /* Delete longjmp breakpoints, they will be reset later by
-         breakpoint_re_set.  */
+      /* Delete longjmp and overlay event breakpoints; they will be
+         reset later by breakpoint_re_set.  */
     case bp_longjmp:
     case bp_longjmp_resume:
+    case bp_overlay_event:
       delete_breakpoint (b);
       break;
 
@@ -7178,26 +7138,18 @@ breakpoint_re_set (void)
   set_language (save_language);
   input_radix = save_input_radix;
 
-#ifdef GET_LONGJMP_TARGET
-  create_longjmp_breakpoint ("longjmp");
-  create_longjmp_breakpoint ("_longjmp");
-  create_longjmp_breakpoint ("siglongjmp");
-  create_longjmp_breakpoint ("_siglongjmp");
-  create_longjmp_breakpoint (NULL);
-#endif
-
-#if 0
-  /* Took this out (temporarily at least), since it produces an extra 
-     blank line at startup. This messes up the gdbtests. -PB */
-  /* Blank line to finish off all those mention() messages we just printed.  */
-  printf_filtered ("\n");
-#endif
+  if (GET_LONGJMP_TARGET_P ())
+    {
+      create_longjmp_breakpoint ("longjmp");
+      create_longjmp_breakpoint ("_longjmp");
+      create_longjmp_breakpoint ("siglongjmp");
+      create_longjmp_breakpoint ("_siglongjmp");
+      create_longjmp_breakpoint (NULL);
+    }
+  
+  create_overlay_event_breakpoint ("_ovly_debug_event");
 }
 \f
-/* Set ignore-count of breakpoint number BPTNUM to COUNT.
-   If from_tty is nonzero, it prints a message to that effect,
-   which ends with a period (no newline).  */
-
 /* Reset the thread number of this breakpoint:
 
    - If the breakpoint is for all threads, leave it as-is.
@@ -7212,6 +7164,10 @@ breakpoint_re_set_thread (struct breakpoint *b)
     }
 }
 
+/* Set ignore-count of breakpoint number BPTNUM to COUNT.
+   If from_tty is nonzero, it prints a message to that effect,
+   which ends with a period (no newline).  */
+
 void
 set_ignore_count (int bptnum, int count, int from_tty)
 {
@@ -7224,18 +7180,20 @@ set_ignore_count (int bptnum, int count, int from_tty)
     if (b->number == bptnum)
     {
       b->ignore_count = count;
-      if (!from_tty)
-       return;
-      else if (count == 0)
-       printf_filtered ("Will stop next time breakpoint %d is reached.",
-                        bptnum);
-      else if (count == 1)
-       printf_filtered ("Will ignore next crossing of breakpoint %d.",
-                        bptnum);
-      else
-       printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
-                        count, bptnum);
+      if (from_tty)
+       {
+         if (count == 0)
+           printf_filtered ("Will stop next time breakpoint %d is reached.",
+                            bptnum);
+         else if (count == 1)
+           printf_filtered ("Will ignore next crossing of breakpoint %d.",
+                            bptnum);
+         else
+           printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
+                            count, bptnum);
+       }
       breakpoints_changed ();
+      breakpoint_modify_event (b->number);
       return;
     }
 
@@ -7272,8 +7230,8 @@ ignore_command (char *args, int from_tty)
   set_ignore_count (num,
                    longest_to_int (value_as_long (parse_and_eval (p))),
                    from_tty);
-  printf_filtered ("\n");
-  breakpoints_changed ();
+  if (from_tty)
+    printf_filtered ("\n");
 }
 \f
 /* Call FUNCTION on each of the breakpoints
@@ -7320,6 +7278,10 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *))
     }
 }
 
+/* Set ignore-count of breakpoint number BPTNUM to COUNT.
+   If from_tty is nonzero, it prints a message to that effect,
+   which ends with a period (no newline).  */
+
 void
 disable_breakpoint (struct breakpoint *bpt)
 {
@@ -7411,12 +7373,7 @@ do_enable_breakpoint (struct breakpoint *bpt, enum bpdisp disposition)
       if (bpt->exp_valid_block != NULL)
        {
          struct frame_info *fr =
-
-         /* Ensure that we have the current frame.  Else, this
-            next query may pessimistically be answered as, "No,
-            not within current scope". */
-         get_current_frame ();
-         fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
+         fr = frame_find_by_id (bpt->watchpoint_frame);
          if (fr == NULL)
            {
              printf_filtered ("\
@@ -7426,9 +7383,9 @@ is valid is not currently in scope.\n", bpt->number);
              return;
            }
 
-         save_selected_frame = selected_frame;
-         save_selected_frame_level = selected_frame_level;
-         select_frame (fr, -1);
+         save_selected_frame = deprecated_selected_frame;
+         save_selected_frame_level = frame_relative_level (deprecated_selected_frame);
+         select_frame (fr);
        }
 
       value_free (bpt->val);
@@ -7463,7 +7420,7 @@ have been allocated for other watchpoints.\n", bpt->number);
        }
 
       if (save_selected_frame_level >= 0)
-       select_frame (save_selected_frame, save_selected_frame_level);
+       select_frame (save_selected_frame);
       value_free_to_mark (mark);
     }
   if (modify_breakpoint_hook)
@@ -7590,31 +7547,26 @@ then no output is printed when it is hit, except what the commands print.");
   add_com ("condition", class_breakpoint, condition_command,
           "Specify breakpoint number N to break only if COND is true.\n\
 Usage is `condition N COND', where N is an integer and COND is an\n\
-expression to be evaluated whenever breakpoint N is reached.  ");
+expression to be evaluated whenever breakpoint N is reached.");
 
   c = add_com ("tbreak", class_breakpoint, tbreak_command,
               "Set a temporary breakpoint.  Args like \"break\" command.\n\
 Like \"break\" except the breakpoint is only temporary,\n\
 so it will be deleted when hit.  Equivalent to \"break\" followed\n\
 by using \"enable delete\" on the breakpoint number.");
-  c->completer = location_completer;
-
-  c = add_com ("txbreak", class_breakpoint, tbreak_at_finish_command,
-              "Set temporary breakpoint at procedure exit.  Either there should\n\
-be no argument or the argument must be a depth.\n");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("hbreak", class_breakpoint, hbreak_command,
               "Set a hardware assisted  breakpoint. Args like \"break\" command.\n\
 Like \"break\" except the breakpoint requires hardware support,\n\
 some target hardware may not have this support.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("thbreak", class_breakpoint, thbreak_command,
               "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
 Like \"hbreak\" except the breakpoint is only temporary,\n\
 so it will be deleted when hit.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_prefix_cmd ("enable", class_breakpoint, enable_command,
                  "Enable some breakpoints.\n\
@@ -7728,37 +7680,17 @@ This is useful for breaking on return to a stack frame.\n\
 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
 \n\
 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_com_alias ("b", "break", class_run, 1);
   add_com_alias ("br", "break", class_run, 1);
   add_com_alias ("bre", "break", class_run, 1);
   add_com_alias ("brea", "break", class_run, 1);
 
-  add_com ("xbreak", class_breakpoint, break_at_finish_command,
-          concat ("Set breakpoint at procedure exit. \n\
-Argument may be function name, or \"*\" and an address.\n\
-If function is specified, break at end of code for that function.\n\
-If an address is specified, break at the end of the function that contains \n\
-that exact address.\n",
-                  "With no arg, uses current execution address of selected stack frame.\n\
-This is useful for breaking on return to a stack frame.\n\
-\n\
-Multiple breakpoints at one place are permitted, and useful if conditional.\n\
-\n\
-Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
-  add_com_alias ("xb", "xbreak", class_breakpoint, 1);
-  add_com_alias ("xbr", "xbreak", class_breakpoint, 1);
-  add_com_alias ("xbre", "xbreak", class_breakpoint, 1);
-  add_com_alias ("xbrea", "xbreak", class_breakpoint, 1);
-
-  if (xdb_commands)
+ if (xdb_commands)
     {
       add_com_alias ("ba", "break", class_breakpoint, 1);
       add_com_alias ("bu", "ubreak", class_breakpoint, 1);
-      add_com ("bx", class_breakpoint, break_at_finish_at_depth_command,
-              "Set breakpoint at procedure exit.  Either there should\n\
-be no argument or the argument must be a depth.\n");
     }
 
   if (dbx_commands)
@@ -7879,19 +7811,19 @@ by using \"enable delete\" on the catchpoint number.");
               "Set a watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression changes.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("rwatch", class_breakpoint, rwatch_command,
               "Set a read watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression is read.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("awatch", class_breakpoint, awatch_command,
               "Set a watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression is either read or written.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_info ("watchpoints", breakpoints_info,
            "Synonym for ``info breakpoints''.");
This page took 0.060022 seconds and 4 git commands to generate.