get rid of unused m4 files
[deliverable/binutils-gdb.git] / gdb / infrun.c
index fd3bf0aaad35e52fcb6ab6f89a12972f2b4d0247..cd6962984e09dd57f334f341a9f71ac6cc5da285 100644 (file)
@@ -43,26 +43,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Prototypes for local functions */
 
-static void
-signals_info PARAMS ((char *, int));
+static void signals_info PARAMS ((char *, int));
 
-static void
-handle_command PARAMS ((char *, int));
+static void handle_command PARAMS ((char *, int));
 
 static void sig_print_info PARAMS ((enum target_signal));
 
-static void
-sig_print_header PARAMS ((void));
+static void sig_print_header PARAMS ((void));
 
-static void
-resume_cleanups PARAMS ((int));
+static void resume_cleanups PARAMS ((int));
 
-static int
-hook_stop_stub PARAMS ((char *));
+static int hook_stop_stub PARAMS ((char *));
 
 /* GET_LONGJMP_TARGET returns the PC at which longjmp() will resume the
    program.  It needs to examine the jmp_buf argument and extract the PC
    from it.  The return value is non-zero on success, zero otherwise. */
+
 #ifndef GET_LONGJMP_TARGET
 #define GET_LONGJMP_TARGET(PC_ADDR) 0
 #endif
@@ -71,15 +67,24 @@ hook_stop_stub PARAMS ((char *));
 /* Some machines have trampoline code that sits between function callers
    and the actual functions themselves.  If this machine doesn't have
    such things, disable their processing.  */
+
 #ifndef SKIP_TRAMPOLINE_CODE
 #define        SKIP_TRAMPOLINE_CODE(pc)        0
 #endif
 
 /* For SVR4 shared libraries, each call goes through a small piece of
-   trampoline code in the ".plt" section.  IN_SOLIB_TRAMPOLINE evaluates
+   trampoline code in the ".plt" section.  IN_SOLIB_CALL_TRAMPOLINE evaluates
    to nonzero if we are current stopped in one of these. */
-#ifndef IN_SOLIB_TRAMPOLINE
-#define IN_SOLIB_TRAMPOLINE(pc,name)   0
+
+#ifndef IN_SOLIB_CALL_TRAMPOLINE
+#define IN_SOLIB_CALL_TRAMPOLINE(pc,name)      0
+#endif
+
+/* In some shared library schemes, the return path from a shared library
+   call may need to go through a trampoline too.  */
+
+#ifndef IN_SOLIB_RETURN_TRAMPOLINE
+#define IN_SOLIB_RETURN_TRAMPOLINE(pc,name)    0
 #endif
 
 /* On some systems, the PC may be left pointing at an instruction that  won't
@@ -131,11 +136,13 @@ static struct symbol *step_start_function;
 
 static int trap_expected;
 
+#ifdef HP_OS_BUG
 /* Nonzero if the next time we try to continue the inferior, it will
    step one instruction and generate a spurious trace trap.
    This is used to compensate for a bug in HP-UX.  */
 
 static int trap_expected_after_continue;
+#endif
 
 /* Nonzero means expecting a trace trap
    and should stop the inferior and return silently when it happens.  */
@@ -312,6 +319,7 @@ proceed (addr, siggnal, step)
     oneproc = 1;
 #endif /* PREPARE_TO_PROCEED */
 
+#ifdef HP_OS_BUG
   if (trap_expected_after_continue)
     {
       /* If (step == 0), a trap will be automatically generated after
@@ -321,6 +329,7 @@ proceed (addr, siggnal, step)
       oneproc = 1;
       trap_expected_after_continue = 0;
     }
+#endif /* HP_OS_BUG */
 
   if (oneproc)
     /* We will get a trace trap after one instruction.
@@ -347,6 +356,10 @@ The same program may be running in another process.");
 
   annotate_starting ();
 
+  /* Make sure that output from GDB appears before output from the
+     inferior.  */
+  gdb_flush (gdb_stdout);
+
   /* Resume inferior.  */
   resume (oneproc || step || bpstat_should_step (), stop_signal);
 
@@ -371,6 +384,7 @@ static char *prev_func_name;
 void
 start_remote ()
 {
+  init_thread_list ();
   init_wait_for_inferior ();
   clear_proceed_status ();
   stop_soon_quietly = 1;
@@ -389,7 +403,9 @@ init_wait_for_inferior ()
   prev_func_start = 0;
   prev_func_name = NULL;
 
+#ifdef HP_OS_BUG
   trap_expected_after_continue = 0;
+#endif
   breakpoints_inserted = 0;
   breakpoint_init_inferior ();
 
@@ -485,6 +501,24 @@ wait_for_inferior ()
          continue;
        }
 
+      stop_signal = w.value.sig;
+
+      stop_pc = read_pc_pid (pid);
+
+      if (STOPPED_BY_WATCHPOINT (w))
+       {
+         write_pc (stop_pc - DECR_PC_AFTER_BREAK);
+
+         remove_breakpoints ();
+         target_resume (pid, 1, TARGET_SIGNAL_0); /* Single step */
+
+         if (target_wait_hook)
+           target_wait_hook (pid, &w);
+         else
+           target_wait (pid, &w);
+         insert_breakpoints ();
+       }
+
       switch (w.kind)
        {
        case TARGET_WAITKIND_LOADED:
@@ -522,7 +556,14 @@ wait_for_inferior ()
          stop_signal = w.value.sig;
          target_terminal_ours ();      /* Must do this before mourn anyway */
          annotate_signalled ();
+
+         /* This looks pretty bogus to me.  Doesn't TARGET_WAITKIND_SIGNALLED
+            mean it is already dead?  This has been here since GDB 2.8, so
+            perhaps it means rms didn't understand unix waitstatuses?
+            For the moment I'm just kludging around this in remote.c
+            rather than trying to change it here --kingdon, 5 Dec 1994.  */
          target_kill ();               /* kill mourns as well */
+
          printf_filtered ("\nProgram terminated with signal ");
          annotate_signal_name ();
          printf_filtered ("%s", target_signal_to_name (stop_signal));
@@ -546,10 +587,6 @@ wait_for_inferior ()
          break;
        }
 
-      stop_signal = w.value.sig;
-
-      stop_pc = read_pc_pid (pid);
-
       /* See if a thread hit a thread-specific breakpoint that was meant for
         another thread.  If so, then step that thread past the breakpoint,
         and continue it.  */
@@ -666,45 +703,6 @@ wait_for_inferior ()
          continue;
        }
 
-#ifdef HAVE_STEPPABLE_WATCHPOINT
-      /* It may not be necessary to disable the watchpoint to stop over
-        it.  For example, the PA can (with some kernel cooperation) 
-        single step over a watchpoint without disabling the watchpoint.  */
-      if (STOPPED_BY_WATCHPOINT (w))
-       {
-         resume (1, 0);
-         continue;
-       }
-#endif
-
-#ifdef HAVE_NONSTEPPABLE_WATCHPOINT
-      /* It is far more common to need to disable a watchpoint
-        to step the inferior over it.  FIXME.  What else might
-        a debug register or page protection watchpoint scheme need
-        here?  */
-      if (STOPPED_BY_WATCHPOINT (w))
-       {
-         remove_breakpoints ();
-         resume (1, 0);
-
-         /* FIXME: This is bogus.  You can't interact with the
-            inferior except when it is stopped.  It apparently
-            happens to work on Irix4, but it depends on /proc
-            allowing us to muck with the memory of a running process,
-            and the kernel deciding to run one instruction of the
-            inferior before it executes our insert_breakpoints code,
-            which seems like an awfully dubious assumption.  */
-         insert_breakpoints ();
-
-         continue;
-       }
-#endif
-
-#ifdef HAVE_CONTINUABLE_WATCHPOINT
-      /* It may be possible to simply continue after a watchpoint.  */
-      STOPPED_BY_WATCHPOINT (w);
-#endif
-
       stop_func_start = 0;
       stop_func_name = 0;
       /* Don't care about return value; stop_func_start and stop_func_name
@@ -1142,7 +1140,7 @@ wait_for_inferior ()
                 call.  I'm not completely sure this is necessary now that we
                 have the above checks with stop_func_start (and now that
                 find_pc_partial_function is pickier).  */
-             || IN_SOLIB_TRAMPOLINE (stop_pc, stop_func_name)
+             || IN_SOLIB_CALL_TRAMPOLINE (stop_pc, stop_func_name)
 
              /* If none of the above apply, it is a jump within a function,
                 or a return from a subroutine.  The other case is longjmp,
@@ -1280,6 +1278,38 @@ step_into_function:
          break;
        }
 
+      /* If we're in the return path from a shared library trampoline,
+        we want to proceed through the trampoline when stepping.  */
+      if (IN_SOLIB_RETURN_TRAMPOLINE(stop_pc, stop_func_name))
+       {
+         CORE_ADDR tmp;
+
+         /* Determine where this trampoline returns.  */
+         tmp = SKIP_TRAMPOLINE_CODE (stop_pc);
+
+         /* Only proceed through if we know where it's going.  */
+         if (tmp)
+           {
+             /* And put the step-breakpoint there and go until there. */
+             struct symtab_and_line sr_sal;
+
+             sr_sal.pc = tmp;
+             sr_sal.symtab = NULL;
+             sr_sal.line = 0;
+             /* Do not specify what the fp should be when we stop
+                since on some machines the prologue
+                is where the new fp value is established.  */
+             step_resume_breakpoint =
+               set_momentary_breakpoint (sr_sal, NULL, bp_step_resume);
+             if (breakpoints_inserted)
+               insert_breakpoints ();
+
+             /* Restart without fiddling with the step ranges or
+                other state.  */
+             goto keep_going;
+           }
+       }
+        
       if (sal.line == 0)
        {
          /* We have no line number information.  That means to stop
@@ -1703,10 +1733,11 @@ handle_command (args, from_tty)
             anyway, and the common ones like SIGHUP, SIGINT, SIGALRM, etc.
             will work right anyway.  */
 
-         sigfirst = siglast = atoi (*argv);
+         sigfirst = siglast = (int) target_signal_from_command (atoi (*argv));
          if ((*argv)[digits] == '-')
            {
-             siglast = atoi ((*argv) + digits + 1);
+             siglast =
+               (int) target_signal_from_command (atoi ((*argv) + digits + 1));
            }
          if (sigfirst > siglast)
            {
@@ -1715,14 +1746,6 @@ handle_command (args, from_tty)
              sigfirst = siglast;
              siglast = signum;
            }
-         if (sigfirst < 0 || sigfirst >= nsigs)
-           {
-             error ("Signal %d not in range 0-%d", sigfirst, nsigs - 1);
-           }
-         if (siglast < 0 || siglast >= nsigs)
-           {
-             error ("Signal %d not in range 0-%d", siglast, nsigs - 1);
-           }
        }
       else
        {
@@ -1763,6 +1786,11 @@ Are you sure you want to change it? ",
                      }
                  }
                break;
+             case TARGET_SIGNAL_0:
+             case TARGET_SIGNAL_DEFAULT:
+             case TARGET_SIGNAL_UNKNOWN:
+               /* Make sure that "all" doesn't print these.  */
+               break;
              default:
                sigs[signum] = 1;
                break;
@@ -1809,20 +1837,9 @@ signals_info (signum_exp, from_tty)
       oursig = target_signal_from_name (signum_exp);
       if (oursig == TARGET_SIGNAL_UNKNOWN)
        {
-         /* Nope, maybe it's an address which evaluates to a signal
-            number.  */
-         /* The numeric signal refers to our own internal
-            signal numbering from target.h, not to host/target signal number.
-            This is a feature; users really should be using symbolic names
-            anyway, and the common ones like SIGHUP, SIGINT, SIGALRM, etc.
-            will work right anyway.  */
-         int i = parse_and_eval_address (signum_exp);
-         if (i >= (int)TARGET_SIGNAL_LAST
-             || i < 0
-             || i == (int)TARGET_SIGNAL_UNKNOWN
-             || i == (int)TARGET_SIGNAL_DEFAULT)
-           error ("Signal number out of bounds.");
-         oursig = (enum target_signal)i;
+         /* No, try numeric.  */
+         oursig =
+           target_signal_from_command (parse_and_eval_address (signum_exp));
        }
       sig_print_info (oursig);
       return;
@@ -1885,7 +1902,7 @@ save_inferior_status (inf_status, restore_stack_info)
 }
 
 struct restore_selected_frame_args {
-  FRAME_ADDR frame_address;
+  CORE_ADDR frame_address;
   int level;
 };
 
@@ -1895,27 +1912,28 @@ static int restore_selected_frame PARAMS ((char *));
    restore_selected_frame_args * (declared as char * for catch_errors)
    telling us what frame to restore.  Returns 1 for success, or 0 for
    failure.  An error message will have been printed on error.  */
+
 static int
 restore_selected_frame (args)
      char *args;
 {
   struct restore_selected_frame_args *fr =
     (struct restore_selected_frame_args *) args;
-  FRAME fid;
+  struct frame_info *frame;
   int level = fr->level;
 
-  fid = find_relative_frame (get_current_frame (), &level);
+  frame = find_relative_frame (get_current_frame (), &level);
 
   /* If inf_status->selected_frame_address is NULL, there was no
      previously selected frame.  */
-  if (fid == 0 ||
-      FRAME_FP (fid) != fr->frame_address ||
+  if (frame == NULL ||
+      FRAME_FP (frame) != fr->frame_address ||
       level != 0)
     {
       warning ("Unable to restore previously selected frame.\n");
       return 0;
     }
-  select_frame (fid, fr->level);
+  select_frame (frame, fr->level);
   return(1);
 }
 
@@ -1983,23 +2001,24 @@ _initialize_infrun ()
 
   add_info ("signals", signals_info,
            "What debugger does when program gets various signals.\n\
-Specify a signal number as argument to print info on that signal only.");
+Specify a signal as argument to print info on that signal only.");
   add_info_alias ("handle", "signals", 0);
 
   add_com ("handle", class_run, handle_command,
-          "Specify how to handle a signal.\n\
-Args are signal numbers and actions to apply to those signals.\n\
-Signal numbers may be numeric (ex. 11) or symbolic (ex. SIGSEGV).\n\
-Numeric ranges may be specified with the form LOW-HIGH (ex. 14-21).\n\
+          concat ("Specify how to handle a signal.\n\
+Args are signals and actions to apply to those signals.\n\
+Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals\n\
+from 1-15 are allowed for compatibility with old versions of GDB.\n\
+Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).\n\
 The special arg \"all\" is recognized to mean all signals except those\n\
-used by the debugger, typically SIGTRAP and SIGINT.\n\
-Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
+used by the debugger, typically SIGTRAP and SIGINT.\n",
+"Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
 \"pass\", \"nopass\", \"ignore\", or \"noignore\".\n\
 Stop means reenter debugger if this signal happens (implies print).\n\
 Print means print a message if this signal happens.\n\
 Pass means let program see this signal; otherwise program doesn't know.\n\
 Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
-Pass and Stop may be combined.");
+Pass and Stop may be combined.", NULL));
 
   stop_command = add_cmd ("stop", class_obscure, not_just_help_class_command,
           "There is no `stop' command, but you can set a hook on `stop'.\n\
This page took 0.02829 seconds and 4 git commands to generate.