* config/i386/tm-i386.h (PARM_BOUNDARY, CALL_DUMMY,
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index d310766043b91c16a56c2624f366cc71d3f1d87a..1861370eaa79cd13486c28ade2eb4234b248f65a 100644 (file)
@@ -84,10 +84,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);
 
@@ -117,10 +117,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,
@@ -147,9 +143,9 @@ static int cover_target_enable_exception_callback (PTR);
 
 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 +214,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.  */
@@ -741,33 +738,65 @@ insert_breakpoints (void)
        && !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)
              {
-               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 -- 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)
+                     warning ("overlay breakpoint %d failed: in ROM?", 
+                              b->number);
+                 }
+             }
+           /* Shall we set a breakpoint at the VMA? */
+           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.  */
@@ -872,7 +901,7 @@ 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_level = frame_relative_level (selected_frame);
 
        /* Determine if the watchpoint is within scope.  */
        if (b->exp_valid_block == NULL)
@@ -880,16 +909,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)
@@ -973,8 +996,8 @@ insert_breakpoints (void)
 
        /* Restore the frame and level.  */
        if ((saved_frame != selected_frame) ||
-           (saved_level != selected_frame_level))
-         select_frame (saved_frame, saved_level);
+           (saved_level != frame_relative_level (selected_frame)))
+         select_frame (saved_frame);
 
        if (val)
          return_val = val;     /* remember failure */
@@ -1107,8 +1130,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;
@@ -1216,6 +1240,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 +1295,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;
@@ -1510,9 +1565,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 +1592,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;
@@ -1598,9 +1653,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;
@@ -1910,6 +1965,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);
@@ -2253,7 +2314,7 @@ 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.
@@ -2267,7 +2328,7 @@ watchpoint_check (PTR p)
        /* 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)
@@ -2386,15 +2447,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,
@@ -2589,7 +2659,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",
@@ -2774,7 +2844,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 (?).  */
 
@@ -2893,6 +2963,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:
@@ -3069,6 +3140,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"},
@@ -3225,6 +3297,7 @@ print_one_breakpoint (struct breakpoint *b,
     case bp_call_dummy:
     case bp_shlib_event:
     case bp_thread_event:
+    case bp_overlay_event:
       if (addressprint)
        {
          annotate_field (4);
@@ -3506,29 +3579,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");
@@ -3604,8 +3677,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?  */
@@ -3643,8 +3716,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;
          }
@@ -3728,40 +3801,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. */
@@ -3793,20 +3874,67 @@ 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));
@@ -3840,15 +3968,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;
 }
 
@@ -4308,6 +4429,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)
@@ -4958,13 +5080,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);
@@ -4976,7 +5098,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);
@@ -5193,10 +5315,12 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
   if (frame)
     {
       prev_frame = get_prev_frame (frame);
-      b->watchpoint_frame = frame->frame;
+      get_frame_id (frame, &b->watchpoint_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
@@ -5571,7 +5695,7 @@ get_catch_sals (int this_level_only)
      but it's better than a core dump.  */
   if (selected_frame == NULL)
     error ("No selected frame.");
-  block = get_frame_block (selected_frame);
+  block = get_frame_block (selected_frame, 0);
   pc = selected_frame->pc;
 
   sals.nelts = 0;
@@ -6142,30 +6266,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)
 {
@@ -6338,15 +6438,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)
@@ -6358,6 +6458,7 @@ clear_command (char *arg, int from_tty)
     {
       sals.sals = (struct symtab_and_line *)
        xmalloc (sizeof (struct symtab_and_line));
+      make_cleanup (xfree, sals.sals);
       INIT_SAL (&sal);         /* initialize to zeroes */
       sal.line = default_breakpoint_line;
       sal.symtab = default_breakpoint_symtab;
@@ -6372,13 +6473,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.
@@ -6394,83 +6493,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)))
-
-       {
-         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)))
+      prev = NULL;
 
-
-       {
-         b1 = b->next;
-         b->next = b1->next;
-         b1->next = found;
-         found = b1;
-       }
-
-      if (found == 0)
+      /* Find all matching breakpoints, remove them from the
+        breakpoint chain, and add them to the 'found' chain.  */
+      ALL_BREAKPOINTS_SAFE (b, tmp)
        {
-         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
@@ -6688,6 +6779,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;
       }
@@ -6701,6 +6793,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);
          }
@@ -6812,7 +6905,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);
@@ -6884,10 +6977,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;
 
@@ -6935,26 +7029,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.
@@ -6969,6 +7055,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)
 {
@@ -7077,6 +7167,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)
 {
@@ -7168,12 +7262,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 ("\
@@ -7184,8 +7273,8 @@ is valid is not currently in scope.\n", bpt->number);
            }
 
          save_selected_frame = selected_frame;
-         save_selected_frame_level = selected_frame_level;
-         select_frame (fr, -1);
+         save_selected_frame_level = frame_relative_level (selected_frame);
+         select_frame (fr);
        }
 
       value_free (bpt->val);
@@ -7220,7 +7309,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)
@@ -7347,31 +7436,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\
@@ -7485,37 +7569,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)
@@ -7636,19 +7700,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.046689 seconds and 4 git commands to generate.