* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index 389ed17f713ba0437068097aabddce55d709d2ae..cd74b20aa26eefe07da101f1edc5e8e7b673983c 100644 (file)
@@ -211,6 +211,7 @@ run_command (args, from_tty)
 
   dont_repeat ();
 
+  /* Shouldn't this be target_has_execution?  FIXME.  */
   if (inferior_pid)
     {
       if (
@@ -363,47 +364,26 @@ step_1 (skip_subroutines, single_inst, count_string)
          find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
          if (step_range_end == 0)
            {
-             struct minimal_symbol *msymbol;
+             char *name;
+             if (find_pc_partial_function (stop_pc, &name, &step_range_start,
+                                           &step_range_end) == 0)
+               error ("Cannot find bounds of current function");
 
-             /* FIXME: This should be using containing_function_bounds or a
-                cleaned-up version thereof, to deal with things like the
-                end of the text segment.  */
-
-             msymbol = lookup_minimal_symbol_by_pc (stop_pc);
              target_terminal_ours ();
-             printf_filtered ("Current function has no line number information.\n");
-             fflush (stdout);
-
-             if (msymbol == NULL || SYMBOL_NAME (msymbol + 1) == NULL)
-               {
-                 /* If sigtramp is in the u area, check for it.  */
-#if defined SIGTRAMP_START
-                 if (IN_SIGTRAMP (stop_pc, (char *)NULL))
-                   {
-                     step_range_start = SIGTRAMP_START;
-                     step_range_end = SIGTRAMP_END;
-                   }
-                 else
-#endif
-                   error ("Cannot find bounds of current function.");
-               }
-             else
-               {
-                 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
-                 step_range_end = SYMBOL_VALUE_ADDRESS (msymbol + 1);
-               }
-
-             printf_filtered ("Single stepping until function exit.\n");
+             printf_filtered ("\
+Single stepping until exit from function %s, \n\
+which has no line number information.\n", name);
              fflush (stdout);
            }
        }
       else
        {
-         /* Say we are stepping, but stop after one insn whatever it does.
-            Don't step through subroutine calls even to undebuggable
-            functions.  */
+         /* Say we are stepping, but stop after one insn whatever it does.  */
          step_range_start = step_range_end = 1;
          if (!skip_subroutines)
+           /* It is stepi.
+              Don't step over function calls, not even to functions lacking
+              line numbers.  */
            step_over_calls = 0;
        }
 
@@ -414,9 +394,12 @@ step_1 (skip_subroutines, single_inst, count_string)
       proceed ((CORE_ADDR) -1, -1, 1);
       if (! stop_step)
        break;
+
+      /* FIXME: On nexti, this may have already been done (when we hit the
+        step resume break, I think).  Probably this should be moved to
+        wait_for_inferior (near the top).  */
 #if defined (SHIFT_INST_REGS)
-      write_register (NNPC_REGNUM, read_register (NPC_REGNUM));
-      write_register (NPC_REGNUM, read_register (PC_REGNUM));
+      SHIFT_INST_REGS();
 #endif
     }
 
@@ -469,10 +452,11 @@ jump_command (arg, from_tty)
        }
     }
 
-  addr = ADDR_BITS_SET (sal.pc);
+  addr = sal.pc;
 
   if (from_tty)
-    printf_filtered ("Continuing at %s.\n", local_hex_string(addr));
+    printf_filtered ("Continuing at %s.\n",
+                    local_hex_string((unsigned long) addr));
 
   clear_proceed_status ();
   proceed (addr, 0, 0);
@@ -517,6 +501,15 @@ signal_command (signum_exp, from_tty)
   proceed (stop_pc, signum, 0);
 }
 
+/* Call breakpoint_auto_delete on the current contents of the bpstat
+   pointed to by arg (which is really a bpstat *).  */
+void
+breakpoint_auto_delete_contents (arg)
+     PTR arg;
+{
+  breakpoint_auto_delete (*(bpstat *)arg);
+}
+
 /* Execute a "stack dummy", a piece of code stored in the stack
    by the debugger to be executed in the inferior.
 
@@ -529,38 +522,67 @@ signal_command (signum_exp, from_tty)
 
    The dummy's frame is automatically popped whenever that break is hit.
    If that is the first time the program stops, run_stack_dummy
-   returns to its caller with that frame already gone.
-   Otherwise, the caller never gets returned to.  */
+   returns to its caller with that frame already gone and returns 0.
+   Otherwise, run_stack-dummy returns 1 (the frame will eventually be popped
+   when we do hit that breakpoint).  */
 
 /* DEBUG HOOK:  4 => return instead of letting the stack dummy run.  */
 
 static int stack_dummy_testing = 0;
 
-void
+int
 run_stack_dummy (addr, buffer)
      CORE_ADDR addr;
      char buffer[REGISTER_BYTES];
 {
+  struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
+
   /* Now proceed, having reached the desired place.  */
   clear_proceed_status ();
   if (stack_dummy_testing & 4)
     {
       POP_FRAME;
-      return;
+      return(0);
     }
+#ifdef CALL_DUMMY_BREAKPOINT_OFFSET
+  {
+    struct breakpoint *bpt;
+    struct symtab_and_line sal;
+
+    sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
+    sal.symtab = NULL;
+    sal.line = 0;
+
+    /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
+       a breakpoint instruction.  If not, the call dummy already has the
+       breakpoint instruction in it.
+
+       addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
+       so we need to subtract the CALL_DUMMY_START_OFFSET.  */
+    bpt = set_momentary_breakpoint (sal,
+                                   NULL,
+                                   bp_call_dummy);
+    bpt->disposition = delete;
+
+    /* If all error()s out of proceed ended up calling normal_stop (and
+       perhaps they should; it already does in the special case of error
+       out of resume()), then we wouldn't need this.  */
+    make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
+  }
+#endif /* CALL_DUMMY_BREAKPOINT_OFFSET.  */
+
   proceed_to_finish = 1;       /* We want stop_registers, please... */
   proceed (addr, 0, 0);
 
+  discard_cleanups (old_cleanups);
+
   if (!stop_stack_dummy)
-    /* This used to say
-       "Cannot continue previously requested operation".  */
-    error ("\
-The program being debugged stopped while in a function called from GDB.\n\
-The expression which contained the function call has been discarded.");
+    return 1;
 
   /* On return, the stack dummy has been popped already.  */
 
   memcpy (buffer, stop_registers, sizeof stop_registers);
+  return 0;
 }
 \f
 /* Proceed until we reach a different source line with pc greater than
@@ -701,7 +723,7 @@ finish_command (arg, from_tty)
       funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
 
       val = value_being_returned (value_type, stop_registers,
-             using_struct_return (value_of_variable (function),
+             using_struct_return (value_of_variable (function, NULL),
                                   funcaddr,
                                   value_type,
                BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))));
@@ -729,7 +751,8 @@ program_info (args, from_tty)
     }
 
   target_files_info ();
-  printf_filtered ("Program stopped at %s.\n", local_hex_string(stop_pc));
+  printf_filtered ("Program stopped at %s.\n",
+                  local_hex_string((unsigned long) stop_pc));
   if (stop_step)
     printf_filtered ("It stopped after being stepped.\n");
   else if (num != 0)
@@ -919,19 +942,11 @@ path_command (dirname, from_tty)
 CORE_ADDR
 read_pc ()
 {
-#ifdef GDB_TARGET_IS_HPPA
-  int flags = read_register(FLAGS_REGNUM);
-
-  if (flags & 2)
-    return read_register(31) & ~0x3; /* User PC is here when in sys call */
-  return read_register (PC_REGNUM) & ~0x3;
-#else
 #ifdef TARGET_READ_PC
   return TARGET_READ_PC ();
 #else
   return ADDR_BITS_REMOVE ((CORE_ADDR) read_register (PC_REGNUM));
 #endif
-#endif
 }
 
 void
@@ -949,7 +964,6 @@ write_pc (val)
 #endif
 #endif
 #endif
-  pc_changed = 0;
 }
 
 /* Cope with strage ways of getting to the stack and frame pointers */
This page took 0.02559 seconds and 4 git commands to generate.