v850 files that weren't being removed if !keep-v850
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index f01e685736180d06f21b6a2fcd8132c399e5b1c4..e1355c962013eea0c777ebf164e5d2a5549397c5 100644 (file)
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "value.h"
 #include "command.h"
 #include "inferior.h"
-#include "thread.h"
+#include "gdbthread.h"
 #include "target.h"
 #include "language.h"
 #include "gdb_string.h"
@@ -118,7 +118,7 @@ static int
 breakpoint_cond_eval PARAMS ((char *));
 
 static void
-cleanup_executing_breakpoints PARAMS ((int));
+cleanup_executing_breakpoints PARAMS ((PTR));
 
 static void
 commands_command PARAMS ((char *, int));
@@ -135,6 +135,50 @@ set_breakpoint_count PARAMS ((int));
 static int
 remove_breakpoint PARAMS ((struct breakpoint *));
 
+static int
+print_it_normal PARAMS ((bpstat));
+
+static int
+watchpoint_check PARAMS ((char *));
+
+static int
+print_it_done PARAMS ((bpstat));
+
+static int
+print_it_noop PARAMS ((bpstat));
+
+static void
+maintenance_info_breakpoints PARAMS ((char *, int));
+
+#ifdef GET_LONGJMP_TARGET
+static void
+create_longjmp_breakpoint PARAMS ((char *));
+#endif
+
+static int
+hw_breakpoint_used_count PARAMS ((void));
+
+static int
+hw_watchpoint_used_count PARAMS ((enum bptype, int *));
+
+static void
+hbreak_command PARAMS ((char *, int));
+
+static void
+thbreak_command PARAMS ((char *, int));
+
+static void
+watch_command_1 PARAMS ((char *, int, int));
+
+static void
+rwatch_command PARAMS ((char *, int));
+
+static void
+awatch_command PARAMS ((char *, int));
+
+static void
+do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp));
+
 extern int addressprint;               /* Print machine addresses? */
 
 /* Are we executing breakpoint commands?  */
@@ -330,10 +374,9 @@ commands_command (arg, from_tty)
   ALL_BREAKPOINTS (b)
     if (b->number == bnum)
       {
-       if (from_tty && input_from_terminal_p ())
-         printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
-End with a line saying just \"end\".\n", bnum);
-       l = read_command_lines ();
+       char tmpbuf[128];
+       sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum);
+       l = read_command_lines (tmpbuf, from_tty);
        free_command_lines (&b->commands);
        b->commands = l;
        breakpoints_changed ();
@@ -915,7 +958,7 @@ bpstat_clear_actions (bs)
 /* ARGSUSED */
 static void
 cleanup_executing_breakpoints (ignore)
-     int ignore;
+     PTR ignore;
 {
   executing_breakpoint_commands = 0;
 }
@@ -933,6 +976,11 @@ bpstat_do_actions (bsp)
   struct cleanup *old_chain;
   struct command_line *cmd;
 
+  /* Avoid endless recursion if a `source' command is contained
+     in bs->commands.  */
+  if (executing_breakpoint_commands)
+    return;
+
   executing_breakpoint_commands = 1;
   old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
 
@@ -1666,7 +1714,7 @@ breakpoint_1 (bnum, allflag)
                              "watchpoint scope", "call dummy",
                              "shlib events" };
   static char *bpdisps[] = {"del", "dstp", "dis", "keep"};
-  static char bpenables[] = "ny";
+  static char bpenables[] = "nyn";
   char wrap_indent[80];
 
   ALL_BREAKPOINTS (b)
@@ -1795,6 +1843,12 @@ breakpoint_1 (bnum, allflag)
            printf_filtered ("\n");
          }
 
+       if (b->thread != -1)
+         {
+           /* FIXME should make an annotation for this */
+           printf_filtered ("\tstop only in thread %d\n", b->thread);
+         }
+
         if (show_breakpoint_hit_counts && b->hit_count)
          {
            /* FIXME should make an annotation for this */
@@ -2116,7 +2170,7 @@ re_enable_breakpoints_in_shlibs ()
 
 #endif
 
-int
+static int
 hw_breakpoint_used_count()
 {
   register struct breakpoint *b;
@@ -2131,7 +2185,7 @@ hw_breakpoint_used_count()
   return i;
 }
 
-int
+static int
 hw_watchpoint_used_count(type, other_type_used)
     enum bptype type;
     int *other_type_used;
@@ -2209,19 +2263,6 @@ set_momentary_breakpoint (sal, frame, type)
   return b;
 }
 
-#if 0
-void
-clear_momentary_breakpoints ()
-{
-  register struct breakpoint *b, *temp;
-  ALL_BREAKPOINTS_SAFE (b, temp)
-    if (b->disposition == delete)
-      {
-       delete_breakpoint (b);
-       break;
-      }
-}
-#endif
 \f
 /* Tell the user we have just set a breakpoint B.  */
 
@@ -2290,43 +2331,6 @@ mention (b)
   printf_filtered ("\n");
 }
 
-#if 0
-/* Nobody calls this currently. */
-/* Set a breakpoint from a symtab and line.
-   If TEMPFLAG is nonzero, it is a temporary breakpoint.
-   ADDR_STRING is a malloc'd string holding the name of where we are
-   setting the breakpoint.  This is used later to re-set it after the
-   program is relinked and symbols are reloaded.
-   Print the same confirmation messages that the breakpoint command prints.  */
-
-void
-set_breakpoint (s, line, tempflag, addr_string)
-     struct symtab *s;
-     int line;
-     int tempflag;
-     char *addr_string;
-{
-  register struct breakpoint *b;
-  struct symtab_and_line sal;
-  
-  sal.symtab = s;
-  sal.line = line;
-  sal.pc = 0;
-  resolve_sal_pc (&sal);                       /* Might error out */
-  describe_other_breakpoints (sal.pc);
-
-  b = set_raw_breakpoint (sal);
-  set_breakpoint_count (breakpoint_count + 1);
-  b->number = breakpoint_count;
-  b->type = bp_breakpoint;
-  b->cond = 0;
-  b->addr_string = addr_string;
-  b->enable = enabled;
-  b->disposition = tempflag ? delete : donttouch;
-
-  mention (b);
-}
-#endif /* 0 */
 \f
 /* Set a breakpoint according to ARG (function, linenum or *address)
    flag: first bit  : 0 non-temporary, 1 temporary.
@@ -2585,7 +2589,8 @@ watch_command_1 (arg, accessflag, from_tty)
   struct expression *exp;
   struct block *exp_valid_block;
   struct value *val, *mark;
-  struct frame_info *frame, *prev_frame;
+  struct frame_info *frame;
+  struct frame_info *prev_frame = NULL;
   char *exp_start = NULL;
   char *exp_end = NULL;
   char *tok, *end_tok;
@@ -3673,113 +3678,6 @@ map_breakpoint_numbers (args, function)
     }
 }
 
-void
-enable_breakpoint (bpt)
-     struct breakpoint *bpt;
-{
-  struct frame_info *save_selected_frame = NULL;
-  int save_selected_frame_level = -1;
-  int target_resources_ok, other_type_used;
-  struct value *mark;
-  
-  if (bpt->type == bp_hardware_breakpoint)
-    {
-      int i;
-      i = hw_breakpoint_used_count();
-      target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT( 
-               bp_hardware_breakpoint, i+1, 0);
-      if (target_resources_ok == 0)
-        error ("No hardware breakpoint support in the target.");
-      else if (target_resources_ok < 0)
-        error ("Hardware breakpoints used exceeds limit.");
-    }
-  bpt->enable = enabled;
-  check_duplicates (bpt->address);
-
-  if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
-      bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
-    {
-      if (bpt->exp_valid_block != NULL)
-       {
-         struct frame_info *fr =
-           find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
-         if (fr == NULL)
-           {
-             printf_filtered ("\
-Cannot enable watchpoint %d because the block in which its expression\n\
-is valid is not currently in scope.\n", bpt->number);
-             bpt->enable = disabled;
-             return;
-           }
-
-         save_selected_frame = selected_frame;
-         save_selected_frame_level = selected_frame_level;
-         select_frame (fr, -1);
-       }
-
-      value_free (bpt->val);
-      mark = value_mark ();
-      bpt->val = evaluate_expression (bpt->exp);
-      release_value (bpt->val);
-      if (VALUE_LAZY (bpt->val))
-       value_fetch_lazy (bpt->val);
-
-      if (bpt->type == bp_hardware_watchpoint ||
-           bpt->type == bp_read_watchpoint ||
-           bpt->type == bp_access_watchpoint)
-      {
-        int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
-        int mem_cnt = can_use_hardware_watchpoint (bpt->val);
-
-        target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
-                bpt->type, i + mem_cnt, other_type_used);
-        /* we can consider of type is bp_hardware_watchpoint, convert to 
-          bp_watchpoint in the following condition */
-        if (target_resources_ok < 0)
-         {
-             printf_filtered("\
-Cannot enable watchpoint %d because target watch resources\n\
-have been allocated for other watchpoints.\n", bpt->number);
-           bpt->enable = disabled;
-           value_free_to_mark (mark);
-           return;
-          }
-      }
-
-      if (save_selected_frame_level >= 0)
-       select_frame (save_selected_frame, save_selected_frame_level);
-      value_free_to_mark (mark);
-    }
-
-  if (modify_breakpoint_hook)
-    modify_breakpoint_hook (bpt);
-}
-
-/* ARGSUSED */
-static void
-enable_command (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  struct breakpoint *bpt;
-  if (args == 0)
-    ALL_BREAKPOINTS (bpt)
-      switch (bpt->type)
-       {
-       case bp_breakpoint:
-       case bp_hardware_breakpoint:
-       case bp_watchpoint:
-       case bp_hardware_watchpoint:
-       case bp_read_watchpoint:
-       case bp_access_watchpoint:
-         enable_breakpoint (bpt);
-       default:
-         continue;
-       }
-  else
-    map_breakpoint_numbers (args, enable_breakpoint);
-}
-
 void
 disable_breakpoint (bpt)
      struct breakpoint *bpt;
@@ -3824,16 +3722,17 @@ disable_command (args, from_tty)
 }
 
 static void
-enable_once_breakpoint (bpt)
+do_enable_breakpoint (bpt, disposition)
      struct breakpoint *bpt;
+     enum bpdisp disposition;
 {
   struct frame_info *save_selected_frame = NULL;
   int save_selected_frame_level = -1;
   int target_resources_ok, other_type_used;
   struct value *mark;
 
-  if (bpt->type == bp_hardware_breakpoint) 
-    {   
+  if (bpt->type == bp_hardware_breakpoint)
+    {
       int i;
       i = hw_breakpoint_used_count();
       target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
@@ -3845,7 +3744,7 @@ enable_once_breakpoint (bpt)
     }
 
   bpt->enable = enabled;
-  bpt->disposition = disable;
+  bpt->disposition = disposition;
   check_duplicates (bpt->address);
   breakpoints_changed ();
 
@@ -3882,9 +3781,10 @@ is valid is not currently in scope.\n", bpt->number);
            bpt->type == bp_access_watchpoint)
       {
         int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
-        int mem_cnt = can_use_hardware_watchpoint(bpt->val);
+        int mem_cnt = can_use_hardware_watchpoint (bpt->val);
+
         target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
-                bpt->type, i+mem_cnt, other_type_used);
+                bpt->type, i + mem_cnt, other_type_used);
         /* we can consider of type is bp_hardware_watchpoint, convert to 
           bp_watchpoint in the following condition */
         if (target_resources_ok < 0)
@@ -3892,8 +3792,9 @@ is valid is not currently in scope.\n", bpt->number);
              printf_filtered("\
 Cannot enable watchpoint %d because target watch resources\n\
 have been allocated for other watchpoints.\n", bpt->number);
-           bpt->enable = disabled;
-           value_free_to_mark (mark);
+            bpt->enable = disabled;
+            value_free_to_mark (mark);
+            return;
           }
       }
 
@@ -3901,6 +3802,51 @@ have been allocated for other watchpoints.\n", bpt->number);
        select_frame (save_selected_frame, save_selected_frame_level);
       value_free_to_mark (mark);
     }
+  if (modify_breakpoint_hook)
+    modify_breakpoint_hook (bpt);
+}
+
+void
+enable_breakpoint (bpt)
+     struct breakpoint *bpt;
+{
+  do_enable_breakpoint (bpt, donttouch);
+}
+
+/* The enable command enables the specified breakpoints (or all defined
+   breakpoints) so they once again become (or continue to be) effective
+   in stopping the inferior. */
+
+/* ARGSUSED */
+static void
+enable_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  register struct breakpoint *bpt;
+  if (args == 0)
+    ALL_BREAKPOINTS (bpt)
+      switch (bpt->type)
+       {
+       case bp_breakpoint:
+       case bp_hardware_breakpoint:
+       case bp_watchpoint:
+       case bp_hardware_watchpoint:
+       case bp_read_watchpoint:
+       case bp_access_watchpoint:
+         enable_breakpoint (bpt);
+       default:
+         continue;
+       }
+  else
+    map_breakpoint_numbers (args, enable_breakpoint);
+}
+
+static void
+enable_once_breakpoint (bpt)
+     struct breakpoint *bpt;
+{
+  do_enable_breakpoint (bpt, disable);
 }
 
 /* ARGSUSED */
@@ -3916,11 +3862,7 @@ static void
 enable_delete_breakpoint (bpt)
      struct breakpoint *bpt;
 {
-  bpt->enable = enabled;
-  bpt->disposition = del;
-
-  check_duplicates (bpt->address);
-  breakpoints_changed ();
+  do_enable_breakpoint (bpt, del);
 }
 
 /* ARGSUSED */
This page took 0.028765 seconds and 4 git commands to generate.