* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index ad0462a36e95ae2e7c5d749c35c50e1058fb272a..2db375340eb137dba18c07a92fc53ee9d945bace 100644 (file)
@@ -494,19 +494,18 @@ remove_breakpoints ()
        b->inserted = 0;
 #ifdef BREAKPOINT_DEBUG
        printf ("Removed breakpoint at %s",
-               local_hex_string(b->address));
+               local_hex_string((unsigned long) b->address));
        printf (", shadow %s",
-               local_hex_string(b->shadow_contents[0]));
+               local_hex_string((unsigned long) b->shadow_contents[0]));
        printf (", %s.\n",
-               local_hex_string(b->shadow_contents[1]));
+               local_hex_string((unsigned long) b->shadow_contents[1]));
 #endif /* BREAKPOINT_DEBUG */
       }
 
   return 0;
 }
 
-/* Clear the "inserted" flag in all breakpoints.
-   This is done when the inferior is loaded.  */
+/* Clear the "inserted" flag in all breakpoints.  */
 
 void
 mark_breakpoints_out ()
@@ -517,6 +516,26 @@ mark_breakpoints_out ()
     b->inserted = 0;
 }
 
+/* Clear the "inserted" flag in all breakpoints and delete any breakpoints
+   which should go away between runs of the program.  */
+
+void
+breakpoint_init_inferior ()
+{
+  register struct breakpoint *b, *temp;
+
+  ALL_BREAKPOINTS_SAFE (b, temp)
+    {
+      b->inserted = 0;
+
+      /* If the call dummy breakpoint is at the entry point it will
+        cause problems when the inferior is rerun, so we better
+        get rid of it.  */
+      if (b->type == bp_call_dummy)
+       delete_breakpoint (b);
+    }
+}
+
 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
    When continuing from a location with a breakpoint,
    we actually single step once before calling insert_breakpoints.  */
@@ -945,8 +964,8 @@ watchpoint_check (p)
     {
       /* We use value_{,free_to_}mark because it could be a
          *long* time before we return to the command level and
-        call free_all_values.  */
-      /* But couldn't we just call free_all_values instead?  */
+        call free_all_values.  We can't call free_all_values because
+        we might be in the middle of evaluating a function call.  */
 
       value mark = value_mark ();
       value new_val = evaluate_expression (bs->breakpoint_at->exp);
@@ -1003,14 +1022,18 @@ print_it_noop (bs)
   return -1;
 }
 
+/* Get a bpstat associated with having just stopped at address *PC
+   and frame address FRAME_ADDRESS.  Update *PC to point at the
+   breakpoint (if we hit a breakpoint).  NOT_A_BREAKPOINT is nonzero
+   if this is known to not be a real breakpoint (it could still be a
+   watchpoint, though).  */
+
 /* Determine whether we stopped at a breakpoint, etc, or whether we
    don't understand this stop.  Result is a chain of bpstat's such that:
 
        if we don't understand the stop, the result is a null pointer.
 
-       if we understand why we stopped, the result is not null, and
-       the first element of the chain contains summary "stop" and
-       "print" flags for the whole chain.
+       if we understand why we stopped, the result is not null.
 
        Each element of the chain refers to a particular breakpoint or
        watchpoint at which we have stopped.  (We may have stopped for
@@ -1021,11 +1044,11 @@ print_it_noop (bs)
 
  */
 
-       
 bpstat
-bpstat_stop_status (pc, frame_address)
+bpstat_stop_status (pc, frame_address, not_a_breakpoint)
      CORE_ADDR *pc;
      FRAME_ADDR frame_address;
+     int not_a_breakpoint;
 {
   register struct breakpoint *b;
   CORE_ADDR bp_addr;
@@ -1049,6 +1072,9 @@ bpstat_stop_status (pc, frame_address)
       if (b->type != bp_watchpoint && b->address != bp_addr)
        continue;
 
+      if (b->type != bp_watchpoint && not_a_breakpoint)
+       continue;
+
       /* Come here if it's a watchpoint, or if the break address matches */
 
       bs = bpstat_alloc (b, bs);       /* Alloc a bpstat to explain stop */
@@ -1152,15 +1178,7 @@ bpstat_stop_status (pc, frame_address)
        {
          *pc = bp_addr;
 #if defined (SHIFT_INST_REGS)
-         {
-           CORE_ADDR pc = read_register (PC_REGNUM);
-           CORE_ADDR npc = read_register (NPC_REGNUM);
-           if (pc != npc)
-             {
-               write_register (NNPC_REGNUM, npc);
-               write_register (NPC_REGNUM, pc);
-             }
-         }
+         SHIFT_INST_REGS();
 #else /* No SHIFT_INST_REGS.  */
          write_pc (bp_addr);
 #endif /* No SHIFT_INST_REGS.  */
@@ -1253,6 +1271,8 @@ bpstat_what (bs)
   enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
   struct bpstat_what retval;
 
+  retval.call_dummy = 0;
+  retval.step_resume = 0;
   for (; bs != NULL; bs = bs->next)
     {
       enum class bs_class = no_effect;
@@ -1397,7 +1417,7 @@ breakpoint_1 (bnum, allflag)
          case bp_step_resume:
          case bp_call_dummy:
            if (addressprint)
-             printf_filtered ("%s ", local_hex_string_custom(b->address, "08"));
+             printf_filtered ("%s ", local_hex_string_custom ((unsigned long) b->address, "08l"));
 
            last_addr = b->address;
            if (b->source_file)
@@ -1422,7 +1442,7 @@ breakpoint_1 (bnum, allflag)
 
        if (b->frame)
          printf_filtered ("\tstop only in stack frame at %s\n",
-                          local_hex_string(b->frame));
+                          local_hex_string((unsigned long) b->frame));
        if (b->cond)
          {
            printf_filtered ("\tstop only if ");
@@ -1511,7 +1531,7 @@ describe_other_breakpoints (pc)
                    (b->enable == disabled) ? " (disabled)" : "",
                    (others > 1) ? "," : ((others == 1) ? " and" : ""));
          }
-      printf ("also set at pc %s.\n", local_hex_string(pc));
+      printf ("also set at pc %s.\n", local_hex_string((unsigned long) pc));
     }
 }
 \f
@@ -1745,7 +1765,7 @@ mention (b)
       break;
     case bp_breakpoint:
       printf_filtered ("Breakpoint %d at %s", b->number,
-                      local_hex_string(b->address));
+                      local_hex_string((unsigned long) b->address));
       if (b->source_file)
        printf_filtered (": file %s, line %d.",
                         b->source_file, b->line_number);
@@ -2504,7 +2524,8 @@ breakpoint_auto_delete (bs)
      bpstat bs;
 {
   for (; bs; bs = bs->next)
-    if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete)
+    if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
+       && bs->stop)
       delete_breakpoint (bs->breakpoint_at);
 }
 
@@ -2536,7 +2557,9 @@ delete_breakpoint (bpt)
   if (bpt->inserted)
     {
       ALL_BREAKPOINTS (b)
-       if (b->address == bpt->address && !b->duplicate)
+       if (b->address == bpt->address
+           && !b->duplicate
+           && b->enable != disabled)
          {
            int val;
            val = target_insert_breakpoint (b->address, b->shadow_contents);
@@ -2705,6 +2728,7 @@ breakpoint_re_set_one (bint)
     case bp_finish:
     case bp_longjmp:
     case bp_longjmp_resume:
+    case bp_call_dummy:
       delete_breakpoint (b);
       break;
     }
This page took 0.025018 seconds and 4 git commands to generate.