* symtab.c (find_pc_symtab): some object file formats, notably mips,
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 61a7a9f9fba15bf1def85094fdb965918f8710ac..95e26047b93fce1e646cd00333613993bd5f4808 100644 (file)
@@ -17,9 +17,8 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-#include <stdio.h>
-#include <ctype.h>
 #include "defs.h"
+#include <ctype.h>
 #include "symtab.h"
 #include "frame.h"
 #include "breakpoint.h"
@@ -34,6 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "target.h"
 #include "language.h"
 #include <string.h>
+#include "demangle.h"
 
 /* local function prototypes */
 
@@ -106,9 +106,6 @@ check_duplicates PARAMS ((CORE_ADDR));
 static void
 describe_other_breakpoints PARAMS ((CORE_ADDR));
 
-static void
-watchpoints_info PARAMS ((char *, int));
-
 static void
 breakpoints_info PARAMS ((char *, int));
 
@@ -143,8 +140,17 @@ extern int demangle;                       /* Print de-mangled symbol names? */
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
+/* Walk the following statement or block through all breakpoints.
+   ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
+   breakpoint.  */
+
 #define ALL_BREAKPOINTS(b)  for (b = breakpoint_chain; b; b = b->next)
 
+#define ALL_BREAKPOINTS_SAFE(b,tmp)    \
+       for (b = breakpoint_chain;      \
+            b? (tmp=b->next, 1): 0;    \
+            b = tmp)
+
 /* Chain of all breakpoints defined.  */
 
 struct breakpoint *breakpoint_chain;
@@ -216,6 +222,8 @@ get_number (pp)
     }
   else
     {
+      if (*p == '-')
+       ++p;
       while (*p >= '0' && *p <= '9')
        ++p;
       if (p == *pp)
@@ -253,18 +261,18 @@ condition_command (arg, from_tty)
       {
        if (b->cond)
          {
-           free (b->cond);
+           free ((PTR)b->cond);
            b->cond = 0;
          }
        if (b->cond_string != NULL)
-         free (b->cond_string);
+         free ((PTR)b->cond_string);
 
        if (*p == 0)
          {
            b->cond = 0;
            b->cond_string = NULL;
            if (from_tty)
-             printf ("Breakpoint %d now unconditional.\n", bnum);
+             printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
          }
        else
          {
@@ -309,11 +317,8 @@ commands_command (arg, from_tty)
     if (b->number == bnum)
       {
        if (from_tty && input_from_terminal_p ())
-         {
-           printf ("Type commands for when breakpoint %d is hit, one per line.\n\
+         printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
 End with a line saying just \"end\".\n", bnum);
-           fflush (stdout);
-         }
        l = read_command_lines ();
        free_command_lines (&b->commands);
        b->commands = l;
@@ -383,8 +388,8 @@ read_memory_nobpt (memaddr, myaddr, len)
              bptlen -= (membpt + bptlen) - (memaddr + len);
            }
 
-         bcopy (b->shadow_contents + bptoffset,
-                myaddr + membpt - memaddr, bptlen);
+         memcpy (myaddr + membpt - memaddr, 
+                 b->shadow_contents + bptoffset, bptlen);
 
          if (membpt > memaddr)
            {
@@ -440,8 +445,8 @@ insert_breakpoints ()
                b->enable = disabled;
                if (!disabled_breaks)
                  {
-                   fprintf (stderr,
-                        "Cannot insert breakpoint %d:\n", b->number);
+                   fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n",
+                                     b->number);
                    printf_filtered ("Disabling shared library breakpoints:\n");
                  }
                disabled_breaks = 1;
@@ -450,10 +455,11 @@ insert_breakpoints ()
            else
 #endif
              {
-               fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number);
+               fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n",
+                                 b->number);
 #ifdef ONE_PROCESS_WRITETEXT
-               fprintf (stderr,
-                 "The same program may be running in another process.\n");
+               fprintf_filtered (stderr,
+                                 "The same program may be running in another process.\n");
 #endif
                memory_error (val, b->address); /* which bombs us out */
              }
@@ -473,7 +479,7 @@ remove_breakpoints ()
   int val;
 
 #ifdef BREAKPOINT_DEBUG
-  printf ("Removing breakpoints.\n");
+  printf_filtered ("Removing breakpoints.\n");
 #endif /* BREAKPOINT_DEBUG */
 
   ALL_BREAKPOINTS (b)
@@ -484,12 +490,12 @@ remove_breakpoints ()
          return val;
        b->inserted = 0;
 #ifdef BREAKPOINT_DEBUG
-       printf ("Removed breakpoint at %s",
-               local_hex_string(b->address));
-       printf (", shadow %s",
-               local_hex_string(b->shadow_contents[0]));
-       printf (", %s.\n",
-               local_hex_string(b->shadow_contents[1]));
+       printf_filtered ("Removed breakpoint at %s",
+                        local_hex_string(b->address));
+       printf_filtered (", shadow %s",
+                        local_hex_string(b->shadow_contents[0]));
+       printf_filtered (", %s.\n",
+                        local_hex_string(b->shadow_contents[1]));
 #endif /* BREAKPOINT_DEBUG */
       }
 
@@ -546,7 +552,7 @@ bpstat_clear (bsp)
       q = p->next;
       if (p->old_val != NULL)
        value_free (p->old_val);
-      free (p);
+      free ((PTR)p);
       p = q;
     }
   *bsp = NULL;
@@ -569,7 +575,7 @@ bpstat_copy (bs)
   for (; bs != NULL; bs = bs->next)
     {
       tmp = (bpstat) xmalloc (sizeof (*tmp));
-      bcopy (bs, tmp, sizeof (*tmp));
+      memcpy (tmp, bs, sizeof (*tmp));
       if (p == NULL)
        /* This is the first thing in the chain.  */
        retval = tmp;
@@ -810,7 +816,7 @@ bpstat_stop_status (pc, frame_address)
   int real_breakpoint = 0;
 #endif
   /* Root of the chain of bpstat's */
-  struct bpstat__struct root_bs[1];
+  struct bpstat root_bs[1];
   /* Pointer to the last thing in the chain currently.  */
   bpstat bs = root_bs;
 
@@ -987,9 +993,9 @@ bpstat_should_step ()
    is nonzero, process only watchpoints.  */
 
 static void
-breakpoint_1 (bnum, type)
+breakpoint_1 (bnum, allflag)
      int bnum;
-     enum bptype type;
+     int allflag;
 {
   register struct breakpoint *b;
   register struct command_line *l;
@@ -998,7 +1004,7 @@ breakpoint_1 (bnum, type)
   int found_a_breakpoint = 0;
   static char *bptypes[] = {"breakpoint", "until", "finish", "watchpoint",
                              "longjmp", "longjmp resume"};
-  static char *bpdisps[] = {"del", "dis", ""};
+  static char *bpdisps[] = {"del", "dis", "keep"};
   static char bpenables[] = "ny";
 
   if (!breakpoint_chain)
@@ -1011,21 +1017,31 @@ breakpoint_1 (bnum, type)
     if (bnum == -1
        || bnum == b->number)
       {
+/*  We only print out user settable breakpoints unless the allflag is set. */
+       if (!allflag
+           && b->type != bp_breakpoint
+           && b->type != bp_watchpoint)
+         continue;
+
        if (!found_a_breakpoint++)
-         printf_filtered ("Num Type       Disp Enb %sWhat\n",
+         printf_filtered ("Num Type           Disp Enb %sWhat\n",
                           addressprint ? "Address    " : "");
 
-       printf_filtered ("%-3d %-10s %-4s %-3c ",
+       printf_filtered ("%-3d %-14s %-4s %-3c ",
                         b->number,
-                        bptypes[b->type],
-                        bpdisps[b->disposition],
-                        bpenables[b->enable]);
+                        bptypes[(int)b->type],
+                        bpdisps[(int)b->disposition],
+                        bpenables[(int)b->enable]);
        switch (b->type)
          {
          case bp_watchpoint:
            print_expression (b->exp, stdout);
            break;
          case bp_breakpoint:
+         case bp_until:
+         case bp_finish:
+         case bp_longjmp:
+         case bp_longjmp_resume:
            if (addressprint)
              printf_filtered ("%s ", local_hex_string_custom(b->address, "08"));
 
@@ -1036,7 +1052,8 @@ breakpoint_1 (bnum, type)
                if (sym)
                  {
                    fputs_filtered ("in ", stdout);
-                   fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
+                   fputs_demangled (SYMBOL_NAME (sym), stdout, 
+                                    DMGL_ANSI | DMGL_PARAMS);
                    fputs_filtered (" at ", stdout);
                  }
                fputs_filtered (b->symtab->filename, stdout);
@@ -1090,12 +1107,14 @@ breakpoints_info (bnum_exp, from_tty)
   if (bnum_exp)
     bnum = parse_and_eval_address (bnum_exp);
 
-  breakpoint_1 (bnum, bp_breakpoint);
+  breakpoint_1 (bnum, 0);
 }
 
+#if MAINTENANCE_CMDS
+
 /* ARGSUSED */
 static void
-watchpoints_info (bnum_exp, from_tty)
+maintenance_info_breakpoints (bnum_exp, from_tty)
      char *bnum_exp;
      int from_tty;
 {
@@ -1104,9 +1123,11 @@ watchpoints_info (bnum_exp, from_tty)
   if (bnum_exp)
     bnum = parse_and_eval_address (bnum_exp);
 
-  breakpoint_1 (bnum, bp_watchpoint);
+  breakpoint_1 (bnum, 1);
 }
 
+#endif
+
 /* Print a message describing any breakpoints set at PC.  */
 
 static void
@@ -1121,17 +1142,18 @@ describe_other_breakpoints (pc)
       others++;
   if (others > 0)
     {
-      printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
+      printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
       ALL_BREAKPOINTS (b)
        if (b->address == pc)
          {
            others--;
-           printf ("%d%s%s ",
-                   b->number,
-                   (b->enable == disabled) ? " (disabled)" : "",
-                   (others > 1) ? "," : ((others == 1) ? " and" : ""));
+           printf_filtered ("%d%s%s ",
+                            b->number,
+                            (b->enable == disabled) ? " (disabled)" : "",
+                            (others > 1) ? "," :
+                              ((others == 1) ? " and" : ""));
          }
-      printf ("also set at pc %s.\n", local_hex_string(pc));
+      printf_filtered ("also set at pc %s.\n", local_hex_string(pc));
     }
 }
 \f
@@ -1190,7 +1212,7 @@ set_raw_breakpoint (sal)
   register struct breakpoint *b, *b1;
 
   b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
-  bzero (b, sizeof *b);
+  memset (b, 0, sizeof (*b));
   b->address = sal.pc;
   b->symtab = sal.symtab;
   b->line_number = sal.line;
@@ -1220,25 +1242,13 @@ set_raw_breakpoint (sal)
   return b;
 }
 
-struct breakpoint *longjmp_breakpoint = NULL;
-struct breakpoint *_longjmp_breakpoint = NULL;
-struct breakpoint *siglongjmp_breakpoint = NULL;
-struct breakpoint *longjmp_resume_breakpoint = NULL;
-
 static void
-create_longjmp_breakpoint_1(func_name, bpt)
+create_longjmp_breakpoint(func_name)
      char *func_name;
-     struct breakpoint **bpt;
 {
-  int i;
   struct symtab_and_line sal;
   struct breakpoint *b;
-
-  if (*bpt != NULL)
-    {
-      delete_breakpoint(*bpt);
-      *bpt = NULL;
-    }
+  static int internal_breakpoint_number = -1;
 
   if (func_name != NULL)
     {
@@ -1255,45 +1265,18 @@ create_longjmp_breakpoint_1(func_name, bpt)
 
   sal.symtab = NULL;
   sal.line = 0;
-  if (*bpt != NULL)
-    b = *bpt;
-  else
-    b = set_raw_breakpoint(sal);
 
+  b = set_raw_breakpoint(sal);
   if (!b) return;
 
-  b->type = bp_longjmp;
+  b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
   b->disposition = donttouch;
   b->enable = disabled;
   b->silent = 1;
-  *bpt = b;
-}
-
-/* Call this routine each time we read a new executable or symbol table
-   file.  */
-
-#ifdef GET_LONGJMP_TARGET
-void
-create_longjmp_breakpoint()
-{
-  create_longjmp_breakpoint_1("longjmp", &longjmp_breakpoint);
-  create_longjmp_breakpoint_1("_longjmp", &_longjmp_breakpoint);
-  create_longjmp_breakpoint_1("siglongjmp", &siglongjmp_breakpoint);
-
-  if ((longjmp_breakpoint || _longjmp_breakpoint || siglongjmp_breakpoint)
-      && !longjmp_resume_breakpoint)
-    {
-      create_longjmp_breakpoint_1(NULL, &longjmp_resume_breakpoint);
-      if (longjmp_resume_breakpoint)
-       longjmp_resume_breakpoint->type = bp_longjmp_resume;
-    }
-}
-#else
-void
-create_longjmp_breakpoint()
-{
+  if (func_name)
+    b->addr_string = strsave(func_name);
+  b->number = internal_breakpoint_number--;
 }
-#endif
 
 /* Call this routine when stepping and nexting to enable a breakpoint if we do
    a longjmp().  When we hit that breakpoint, call
@@ -1302,29 +1285,35 @@ create_longjmp_breakpoint()
 void
 enable_longjmp_breakpoint()
 {
-  if (longjmp_breakpoint)
-    longjmp_breakpoint->enable = enabled;
-  if (_longjmp_breakpoint)
-    _longjmp_breakpoint->enable = enabled;
-  if (siglongjmp_breakpoint)
-    siglongjmp_breakpoint->enable = enabled;
+  register struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (b->type == bp_longjmp)
+      {
+       b->enable = enabled;
+       check_duplicates (b->address);
+      }
 }
 
 void
 disable_longjmp_breakpoint()
 {
-  if (longjmp_breakpoint)
-    longjmp_breakpoint->enable = disabled;
-  if (_longjmp_breakpoint)
-    _longjmp_breakpoint->enable = disabled;
-  if (siglongjmp_breakpoint)
-    siglongjmp_breakpoint->enable = disabled;
-  if (longjmp_resume_breakpoint)
-    longjmp_resume_breakpoint->enable = disabled;
+  register struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (   b->type == bp_longjmp
+       || b->type == bp_longjmp_resume)
+      {
+       b->enable = disabled;
+       check_duplicates (b->address);
+      }
 }
 
 /* Call this after hitting the longjmp() breakpoint.  Use this to set a new
    breakpoint at the target of the jmp_buf.
+
+   FIXME - This ought to be done by setting a temporary breakpoint that gets
+   deleted automatically...
 */
 
 void
@@ -1332,12 +1321,20 @@ set_longjmp_resume_breakpoint(pc, frame)
      CORE_ADDR pc;
      FRAME frame;
 {
-  longjmp_resume_breakpoint->address = pc;
-  longjmp_resume_breakpoint->enable = enabled;
-  if (frame != NULL)
-    longjmp_resume_breakpoint->frame = FRAME_FP(frame);
-  else
-    longjmp_resume_breakpoint->frame = 0;
+  register struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    if (b->type == bp_longjmp_resume)
+      {
+       b->address = pc;
+       b->enable = enabled;
+       if (frame != NULL)
+         b->frame = FRAME_FP(frame);
+       else
+         b->frame = 0;
+       check_duplicates (b->address);
+       return;
+      }
 }
 
 /* Set a breakpoint that will evaporate an end of command
@@ -1390,6 +1387,12 @@ mention (b)
       if (b->symtab)
        printf_filtered (": file %s, line %d.",
                         b->symtab->filename, b->line_number);
+      break;
+    case bp_until:
+    case bp_finish:
+    case bp_longjmp:
+    case bp_longjmp_resume:
+      break;
     }
   printf_filtered ("\n");
 }
@@ -1549,10 +1552,10 @@ break_command_1 (arg, tempflag, from_tty)
 
   if (sals.nelts > 1)
     {
-      printf ("Multiple breakpoints were set.\n");
-      printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
+      printf_filtered ("Multiple breakpoints were set.\n");
+      printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
     }
-  free (sals.sals);
+  free ((PTR)sals.sals);
 }
 
 /* Helper function for break_command_1 and disassemble_command.  */
@@ -1657,7 +1660,7 @@ until_break_command (arg, from_tty)
     error ("Couldn't get information on specified line.");
   
   sal = sals.sals[0];
-  free (sals.sals);            /* malloc'd, so freed */
+  free ((PTR)sals.sals);               /* malloc'd, so freed */
   
   if (*arg)
     error ("Junk at end of arguments.");
@@ -1768,7 +1771,7 @@ map_catch_names (args, function)
          goto win;
        }
 #endif
-      printf ("No catch clause for exception %s.\n", p);
+      printf_filtered ("No catch clause for exception %s.\n", p);
 #if 0
     win:
 #endif
@@ -1809,7 +1812,7 @@ get_catch_sals (this_level_only)
 
   bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
   blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
-  bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
+  memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
 
   while (block != 0)
     {
@@ -1969,18 +1972,20 @@ catch_command_1 (arg, tempflag, from_tty)
       b->enable = enabled;
       b->disposition = tempflag ? delete : donttouch;
 
-      printf ("Breakpoint %d at %s", b->number, local_hex_string(b->address));
+      printf_filtered ("Breakpoint %d at %s", b->number,
+                      local_hex_string(b->address));
       if (b->symtab)
-       printf (": file %s, line %d.", b->symtab->filename, b->line_number);
-      printf ("\n");
+       printf_filtered (": file %s, line %d.",
+                        b->symtab->filename, b->line_number);
+      printf_filtered ("\n");
     }
 
   if (sals.nelts > 1)
     {
-      printf ("Multiple breakpoints were set.\n");
-      printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
+      printf_filtered ("Multiple breakpoints were set.\n");
+      printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
     }
-  free (sals.sals);
+  free ((PTR)sals.sals);
 }
 
 #if 0
@@ -2085,17 +2090,18 @@ clear_command (arg, from_tty)
        }
 
       if (found->next) from_tty = 1; /* Always report if deleted more than one */
-      if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
+      if (from_tty) printf_filtered ("Deleted breakpoint%s ",
+                                    found->next ? "s" : "");
       while (found)
        {
-         if (from_tty) printf ("%d ", found->number);
+         if (from_tty) printf_filtered ("%d ", found->number);
          b1 = found->next;
          delete_breakpoint (found);
          found = b1;
        }
       if (from_tty) putchar ('\n');
     }
-  free (sals.sals);
+  free ((PTR)sals.sals);
 }
 \f
 /* Delete breakpoint in BS if they are `delete' breakpoints.
@@ -2136,21 +2142,21 @@ delete_breakpoint (bpt)
 
   free_command_lines (&bpt->commands);
   if (bpt->cond)
-    free (bpt->cond);
+    free ((PTR)bpt->cond);
   if (bpt->cond_string != NULL)
-    free (bpt->cond_string);
+    free ((PTR)bpt->cond_string);
   if (bpt->addr_string != NULL)
-    free (bpt->addr_string);
+    free ((PTR)bpt->addr_string);
 
   if (xgdb_verbose && bpt->type == bp_breakpoint)
-    printf ("breakpoint #%d deleted\n", bpt->number);
+    printf_filtered ("breakpoint #%d deleted\n", bpt->number);
 
   /* Be sure no bpstat's are pointing at it after it's been freed.  */
   /* FIXME, how can we find all bpstat's?  We just check stop_bpstat for now. */
   for (bs = stop_bpstat; bs; bs = bs->next)
     if (bs->breakpoint_at == bpt)
       bs->breakpoint_at = NULL;
-  free (bpt);
+  free ((PTR)bpt);
 }
 
 static void
@@ -2188,8 +2194,15 @@ breakpoint_re_set_one (bint)
   char *s;
   enum enable save_enable;
 
-  if (b->type != bp_watchpoint && b->addr_string != NULL)
+  switch (b->type)
     {
+    case bp_breakpoint:
+      if (b->addr_string == NULL)
+       {
+         /* Anything without a string can't be re-set. */
+         delete_breakpoint (b);
+         return 0;
+       }
       /* In case we have a problem, disable this breakpoint.  We'll restore
         its status if we succeed.  */
       save_enable = b->enable;
@@ -2200,28 +2213,42 @@ breakpoint_re_set_one (bint)
       for (i = 0; i < sals.nelts; i++)
        {
          resolve_sal_pc (&sals.sals[i]);
-         b->symtab = sals.sals[i].symtab;
-         b->line_number = sals.sals[i].line;
-         b->address = sals.sals[i].pc;
-
-         if (b->cond_string != NULL)
+         if (b->symtab != sals.sals[i].symtab
+             || b->line_number != sals.sals[i].line
+             || b->address != sals.sals[i].pc)
            {
-             s = b->cond_string;
-             b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
-           }
+             b->symtab = sals.sals[i].symtab;
+             b->line_number = sals.sals[i].line;
+             b->address = sals.sals[i].pc;
+
+             if (b->cond_string != NULL)
+               {
+                 s = b->cond_string;
+                 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
+               }
          
-         check_duplicates (b->address);
+             check_duplicates (b->address);
 
+             mention (b);
+           }
          b->enable = save_enable;      /* Restore it, this worked. */
-         mention (b);
        }
-      free (sals.sals);
-    }
-  else
-    {
-      /* Anything without a string can't be re-set. */
+      free ((PTR)sals.sals);
+      break;
+    case bp_watchpoint:
+      /* FIXME!  This is the wrong thing to do.... */
+      delete_breakpoint (b);
+      break;
+    default:
+      printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
+    case bp_until:
+    case bp_finish:
+    case bp_longjmp:
+    case bp_longjmp_resume:
       delete_breakpoint (b);
+      break;
     }
+
   return 0;
 }
 
@@ -2229,19 +2256,34 @@ breakpoint_re_set_one (bint)
 void
 breakpoint_re_set ()
 {
-  struct breakpoint *b;
+  struct breakpoint *b, *temp;
   static char message1[] = "Error in re-setting breakpoint %d:\n";
   char message[sizeof (message1) + 30 /* slop */];
   
-  ALL_BREAKPOINTS (b)
+  /* If we have no current source symtab, and we have any breakpoints,
+     go through the work of making a source context.  */
+  if (current_source_symtab == NULL && breakpoint_chain != 0)
     {
-      b->symtab = 0;           /* Be sure we don't point to old dead symtab */
-      sprintf (message, message1, b->number);  /* Format possible error msg */
-      (void) catch_errors (breakpoint_re_set_one, (char *) b, message);
+      select_source_symtab (NULL);
     }
 
+  ALL_BREAKPOINTS_SAFE (b, temp)
+    {
+      printf_filtered (message, message1, b->number);  /* Format possible error msg */
+      catch_errors (breakpoint_re_set_one, (char *) b, message);
+    }
+
+  create_longjmp_breakpoint("longjmp");
+  create_longjmp_breakpoint("_longjmp");
+  create_longjmp_breakpoint("siglongjmp");
+  create_longjmp_breakpoint(NULL);
+
+#if 0
+  /* Took this out (temporaliy 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
 }
 \f
 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
@@ -2264,11 +2306,13 @@ set_ignore_count (bptnum, count, from_tty)
        if (!from_tty)
          return;
        else if (count == 0)
-         printf ("Will stop next time breakpoint %d is reached.", bptnum);
+         printf_filtered ("Will stop next time breakpoint %d is reached.",
+                          bptnum);
        else if (count == 1)
-         printf ("Will ignore next crossing of breakpoint %d.", bptnum);
+         printf_filtered ("Will ignore next crossing of breakpoint %d.",
+                          bptnum);
        else
-         printf ("Will ignore next %d crossings of breakpoint %d.",
+         printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
                  count, bptnum);
        return;
       }
@@ -2307,7 +2351,7 @@ ignore_command (args, from_tty)
   set_ignore_count (num,
                    longest_to_int (value_as_long (parse_and_eval (p))),
                    from_tty);
-  printf ("\n");
+  printf_filtered ("\n");
 }
 \f
 /* Call FUNCTION on each of the breakpoints
@@ -2338,7 +2382,7 @@ map_breakpoint_numbers (args, function)
            function (b);
            goto win;
          }
-      printf ("No breakpoint number %d.\n", num);
+      printf_filtered ("No breakpoint number %d.\n", num);
     win:
       p = p1;
     }
@@ -2351,7 +2395,7 @@ enable_breakpoint (bpt)
   bpt->enable = enabled;
 
   if (xgdb_verbose && bpt->type == bp_breakpoint)
-    printf ("breakpoint #%d enabled\n", bpt->number);
+    printf_filtered ("breakpoint #%d enabled\n", bpt->number);
 
   check_duplicates (bpt->address);
   if (bpt->type == bp_watchpoint)
@@ -2381,7 +2425,14 @@ enable_command (args, from_tty)
   struct breakpoint *bpt;
   if (args == 0)
     ALL_BREAKPOINTS (bpt)
-      enable_breakpoint (bpt);
+      switch (bpt->type)
+       {
+       case bp_breakpoint:
+       case bp_watchpoint:
+         enable_breakpoint (bpt);
+       default:
+         continue;
+       }
   else
     map_breakpoint_numbers (args, enable_breakpoint);
 }
@@ -2393,7 +2444,7 @@ disable_breakpoint (bpt)
   bpt->enable = disabled;
 
   if (xgdb_verbose && bpt->type == bp_breakpoint)
-    printf ("breakpoint #%d disabled\n", bpt->number);
+    printf_filtered ("breakpoint #%d disabled\n", bpt->number);
 
   check_duplicates (bpt->address);
 }
@@ -2407,7 +2458,14 @@ disable_command (args, from_tty)
   register struct breakpoint *bpt;
   if (args == 0)
     ALL_BREAKPOINTS (bpt)
-      disable_breakpoint (bpt);
+      switch (bpt->type)
+       {
+       case bp_breakpoint:
+       case bp_watchpoint:
+         disable_breakpoint (bpt);
+       default:
+         continue;
+       }
   else
     map_breakpoint_numbers (args, disable_breakpoint);
 }
@@ -2471,15 +2529,6 @@ decode_line_spec_1 (string, funfirstline)
   return sals;
 }
 \f
-
-/* Chain containing all defined enable commands.  */
-
-extern struct cmd_list_element 
-  *enablelist, *disablelist,
-  *deletelist, *enablebreaklist;
-
-extern struct cmd_list_element *cmdlist;
-
 void
 _initialize_breakpoint ()
 {
@@ -2611,15 +2660,42 @@ Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
   add_com_alias ("brea", "break", class_run, 1);
 
   add_info ("breakpoints", breakpoints_info,
-           "Status of all breakpoints, or breakpoint number NUMBER.\n\
-Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
-\"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
-Then come the address and the file/line number.\n\n\
+           "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
+The \"Type\" column indicates one of:\n\
+\tbreakpoint     - normal breakpoint\n\
+\twatchpoint     - watchpoint\n\
+The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
+the disposition of the breakpoint after it gets hit.  \"dis\" means that the\n\
+breakpoint will be disabled.  The \"Address\" and \"What\" columns indicate the\n\
+address and file/line number respectively.\n\n\
 Convenience variable \"$_\" and default examine address for \"x\"\n\
 are set to the address of the last breakpoint listed.\n\n\
 Convenience variable \"$bpnum\" contains the number of the last\n\
 breakpoint set.");
 
+#if MAINTENANCE_CMDS
+
+  add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
+           "Status of all breakpoints, or breakpoint number NUMBER.\n\
+The \"Type\" column indicates one of:\n\
+\tbreakpoint     - normal breakpoint\n\
+\twatchpoint     - watchpoint\n\
+\tlongjmp        - internal breakpoint used to step through longjmp()\n\
+\tlongjmp resume - internal breakpoint at the target of longjmp()\n\
+\tuntil          - internal breakpoint used by the \"until\" command\n\
+\tfinish         - internal breakpoint used by the \"finish\" command\n\
+The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
+the disposition of the breakpoint after it gets hit.  \"dis\" means that the\n\
+breakpoint will be disabled.  The \"Address\" and \"What\" columns indicate the\n\
+address and file/line number respectively.\n\n\
+Convenience variable \"$_\" and default examine address for \"x\"\n\
+are set to the address of the last breakpoint listed.\n\n\
+Convenience variable \"$bpnum\" contains the number of the last\n\
+breakpoint set.",
+          &maintenanceinfolist);
+
+#endif /* MAINTENANCE_CMDS */
+
   add_com ("catch", class_breakpoint, catch_command,
          "Set breakpoints to catch exceptions that are raised.\n\
 Argument may be a single exception to catch, multiple exceptions\n\
@@ -2637,7 +2713,37 @@ Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
 A watchpoint stops execution of your program whenever the value of\n\
 an expression changes.");
 
-  add_info ("watchpoints", watchpoints_info,
-           "Status of all watchpoints, or watchpoint number NUMBER.\n\
-Second column is \"y\" for enabled watchpoints, \"n\" for disabled.");
+  add_info ("watchpoints", breakpoints_info,
+           "Synonym for ``info breakpoints''.");
+}
+
+#ifdef IBM6000_TARGET
+/* Where should this function go? It is used by AIX only. FIXME. */
+
+/* Breakpoint address relocation used to be done in breakpoint_re_set(). That
+   approach the following problem:
+
+     before running the program, if a file is list, then a breakpoint is
+     set (just the line number), then if we switch into another file and run
+     the program, just a line number as a breakpoint address was not
+     descriptive enough and breakpoint was ending up in a different file's
+     similar line. 
+
+  I don't think any other platform has this breakpoint relocation problem, so this
+  is not an issue for other platforms. */
+   
+void
+fixup_breakpoints (low, high, delta)
+  CORE_ADDR low;
+  CORE_ADDR high;
+  CORE_ADDR delta;
+{
+  struct breakpoint *b;
+
+  ALL_BREAKPOINTS (b)
+    {
+     if (b->address >= low && b->address <= high)
+       b->address += delta;
+    }
 }
+#endif
This page took 0.034485 seconds and 4 git commands to generate.