* symtab.c (find_pc_symtab): some object file formats, notably mips,
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 4f0911195a87eb4ac2d22b5d835fa095005955b9..95e26047b93fce1e646cd00333613993bd5f4808 100644 (file)
@@ -317,11 +317,8 @@ commands_command (arg, from_tty)
     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\
+         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;
@@ -391,8 +388,8 @@ read_memory_nobpt (memaddr, myaddr, len)
              bptlen -= (membpt + bptlen) - (memaddr + len);
            }
 
-         (void) memcpy (myaddr + membpt - memaddr, 
-                        b->shadow_contents + bptoffset, bptlen);
+         memcpy (myaddr + membpt - memaddr, 
+                 b->shadow_contents + bptoffset, bptlen);
 
          if (membpt > memaddr)
            {
@@ -448,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;
@@ -458,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 */
              }
@@ -481,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)
@@ -492,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 */
       }
 
@@ -577,7 +575,7 @@ bpstat_copy (bs)
   for (; bs != NULL; bs = bs->next)
     {
       tmp = (bpstat) xmalloc (sizeof (*tmp));
-      (void) memcpy (tmp, bs, sizeof (*tmp));
+      memcpy (tmp, bs, sizeof (*tmp));
       if (p == NULL)
        /* This is the first thing in the chain.  */
        retval = tmp;
@@ -1112,9 +1110,11 @@ breakpoints_info (bnum_exp, from_tty)
   breakpoint_1 (bnum, 0);
 }
 
+#if MAINTENANCE_CMDS
+
 /* ARGSUSED */
 static void
-all_breakpoints_info (bnum_exp, from_tty)
+maintenance_info_breakpoints (bnum_exp, from_tty)
      char *bnum_exp;
      int from_tty;
 {
@@ -1126,6 +1126,8 @@ all_breakpoints_info (bnum_exp, from_tty)
   breakpoint_1 (bnum, 1);
 }
 
+#endif
+
 /* Print a message describing any breakpoints set at PC.  */
 
 static void
@@ -1140,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
@@ -1209,7 +1212,7 @@ set_raw_breakpoint (sal)
   register struct breakpoint *b, *b1;
 
   b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
-  (void) memset (b, 0, sizeof (*b));
+  memset (b, 0, sizeof (*b));
   b->address = sal.pc;
   b->symtab = sal.symtab;
   b->line_number = sal.line;
@@ -1286,7 +1289,10 @@ enable_longjmp_breakpoint()
 
   ALL_BREAKPOINTS (b)
     if (b->type == bp_longjmp)
-      b->enable = enabled;
+      {
+       b->enable = enabled;
+       check_duplicates (b->address);
+      }
 }
 
 void
@@ -1295,9 +1301,12 @@ disable_longjmp_breakpoint()
   register struct breakpoint *b;
 
   ALL_BREAKPOINTS (b)
-    if (b->type == bp_longjmp
+    if (   b->type == bp_longjmp
        || b->type == bp_longjmp_resume)
-      b->enable = disabled;
+      {
+       b->enable = disabled;
+       check_duplicates (b->address);
+      }
 }
 
 /* Call this after hitting the longjmp() breakpoint.  Use this to set a new
@@ -1323,6 +1332,7 @@ set_longjmp_resume_breakpoint(pc, frame)
          b->frame = FRAME_FP(frame);
        else
          b->frame = 0;
+       check_duplicates (b->address);
        return;
       }
 }
@@ -1542,8 +1552,8 @@ 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 ((PTR)sals.sals);
 }
@@ -1761,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
@@ -1802,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));
-  (void) memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
+  memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
 
   while (block != 0)
     {
@@ -1962,16 +1972,18 @@ 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 ((PTR)sals.sals);
 }
@@ -2078,10 +2090,11 @@ 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;
@@ -2136,7 +2149,7 @@ delete_breakpoint (bpt)
     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. */
@@ -2247,10 +2260,17 @@ breakpoint_re_set ()
   static char message1[] = "Error in re-setting breakpoint %d:\n";
   char message[sizeof (message1) + 30 /* slop */];
   
+  /* 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)
+    {
+      select_source_symtab (NULL);
+    }
+
   ALL_BREAKPOINTS_SAFE (b, temp)
     {
-      sprintf (message, message1, b->number);  /* Format possible error msg */
-      (void) catch_errors (breakpoint_re_set_one, (char *) b, message);
+      printf_filtered (message, message1, b->number);  /* Format possible error msg */
+      catch_errors (breakpoint_re_set_one, (char *) b, message);
     }
 
   create_longjmp_breakpoint("longjmp");
@@ -2362,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;
     }
@@ -2375,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)
@@ -2509,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 ()
 {
@@ -2662,7 +2673,9 @@ are set to the address of the last breakpoint listed.\n\n\
 Convenience variable \"$bpnum\" contains the number of the last\n\
 breakpoint set.");
 
-  add_info ("all-breakpoints", all_breakpoints_info,
+#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\
@@ -2678,7 +2691,10 @@ 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.");
+breakpoint set.",
+          &maintenanceinfolist);
+
+#endif /* MAINTENANCE_CMDS */
 
   add_com ("catch", class_breakpoint, catch_command,
          "Set breakpoints to catch exceptions that are raised.\n\
@@ -2701,7 +2717,7 @@ an expression changes.");
            "Synonym for ``info breakpoints''.");
 }
 
-#ifdef IBM6000_HOST
+#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
@@ -2723,7 +2739,6 @@ fixup_breakpoints (low, high, delta)
   CORE_ADDR delta;
 {
   struct breakpoint *b;
-  extern struct breakpoint *breakpoint_chain;
 
   ALL_BREAKPOINTS (b)
     {
This page took 0.029048 seconds and 4 git commands to generate.