* Makefile.in (ALLDEPFILES): Add nbsd-tdep.c.
[deliverable/binutils-gdb.git] / gdb / infrun.c
index d56363656d61c07df72dbc773a1e9aed8b505ad2..e9fea2a0ac7ce313f51ca6e1f6c448c393d0ba32 100644 (file)
@@ -1,6 +1,9 @@
-/* Target-struct-independent code to start (run) and stop an inferior process.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Target-struct-independent code to start (run) and stop an inferior
+   process.
+
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -112,15 +115,6 @@ static ptid_t previous_inferior_ptid;
 
 static int may_follow_exec = MAY_FOLLOW_EXEC;
 
-/* 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
-
-
 /* Dynamic function trampolines are similar to solib trampolines in that they
    are between the caller and the callee.  The difference is that when you
    enter a dynamic trampoline, you can't determine the callee's address.  Some
@@ -149,12 +143,12 @@ static int may_follow_exec = MAY_FOLLOW_EXEC;
    The simple approach is to single-step until control leaves the
    dynamic linker.
 
-   However, on some systems (e.g., Red Hat Linux 5.2) the dynamic
-   linker calls functions in the shared C library, so you can't tell
-   from the PC alone whether the dynamic linker is still running.  In
-   this case, we use a step-resume breakpoint to get us past the
-   dynamic linker, as if we were using "next" to step over a function
-   call.
+   However, on some systems (e.g., Red Hat's 5.2 distribution) the
+   dynamic linker calls functions in the shared C library, so you
+   can't tell from the PC alone whether the dynamic linker is still
+   running.  In this case, we use a step-resume breakpoint to get us
+   past the dynamic linker, as if we were using "next" to step over a
+   function call.
 
    IN_SOLIB_DYNSYM_RESOLVE_CODE says whether we're in the dynamic
    linker code or not.  Normally, this means we single-step.  However,
@@ -230,12 +224,10 @@ static int may_follow_exec = MAY_FOLLOW_EXEC;
 static void
 default_skip_permanent_breakpoint (void)
 {
-  error_begin ();
-  fprintf_filtered (gdb_stderr, "\
+  error ("\
 The program is stopped at a permanent breakpoint, but GDB does not know\n\
 how to step past a permanent breakpoint on this architecture.  Try using\n\
-a command like `return' or `jump' to continue execution.\n");
-  return_to_top_level (RETURN_ERROR);
+a command like `return' or `jump' to continue execution.");
 }
 #endif
    
@@ -757,7 +749,15 @@ static const char *scheduler_enums[] =
 static void
 set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c)
 {
-  if (c->type == set_cmd)
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+  if (cmd_type (c) == set_cmd)
     if (!target_can_lock_scheduler)
       {
        scheduler_mode = schedlock_off;
@@ -1469,13 +1469,9 @@ handle_inferior_event (struct execution_control_state *ecs)
       {
        add_thread (ecs->ptid);
 
-#ifdef UI_OUT
        ui_out_text (uiout, "[New ");
        ui_out_text (uiout, target_pid_or_tid_to_str (ecs->ptid));
        ui_out_text (uiout, "]\n");
-#else
-       printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->ptid));
-#endif
 
 #if 0
        /* NOTE: This block is ONLY meant to be invoked in case of a
@@ -2310,7 +2306,8 @@ handle_inferior_event (struct execution_control_state *ecs)
          disable_longjmp_breakpoint ();
          remove_breakpoints ();
          breakpoints_inserted = 0;
-         if (!GET_LONGJMP_TARGET (&jmp_buf_pc))
+         if (!GET_LONGJMP_TARGET_P ()
+             || !GET_LONGJMP_TARGET (&jmp_buf_pc))
            {
              keep_going (ecs);
              return;
@@ -2643,8 +2640,8 @@ handle_inferior_event (struct execution_control_state *ecs)
     ecs->update_step_sp = 1;
 
     /* Did we just take a signal?  */
-    if (IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
-       && !IN_SIGTRAMP (prev_pc, prev_func_name)
+    if (PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+       && !PC_IN_SIGTRAMP (prev_pc, prev_func_name)
        && INNER_THAN (read_sp (), step_sp))
       {
        /* We've just taken a signal; go until we are back to
@@ -2755,7 +2752,7 @@ handle_inferior_event (struct execution_control_state *ecs)
          {
            /* We're doing a "next".  */
 
-           if (IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+           if (PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
                && INNER_THAN (step_frame_address, read_sp()))
              /* We stepped out of a signal handler, and into its
                  calling trampoline.  This is misdetected as a
@@ -2964,8 +2961,8 @@ static void
 check_sigtramp2 (struct execution_control_state *ecs)
 {
   if (trap_expected
-      && IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
-      && !IN_SIGTRAMP (prev_pc, prev_func_name)
+      && PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+      && !PC_IN_SIGTRAMP (prev_pc, prev_func_name)
       && INNER_THAN (read_sp (), step_sp))
     {
       /* What has happened here is that we have just stepped the
@@ -3284,13 +3281,11 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
     case END_STEPPING_RANGE:
       /* We are done with a step/next/si/ni command. */
       /* For now print nothing. */
-#ifdef UI_OUT
       /* Print a message only if not in the middle of doing a "step n"
         operation for n > 1 */
       if (!step_multi || !stop_step)
        if (ui_out_is_mi_like_p (uiout))
          ui_out_field_string (uiout, "reason", "end-stepping-range");
-#endif
       break;
     case BREAKPOINT_HIT:
       /* We found a breakpoint. */
@@ -3298,7 +3293,6 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
       break;
     case SIGNAL_EXITED:
       /* The inferior was terminated by a signal. */
-#ifdef UI_OUT
       annotate_signalled ();
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", "exited-signalled");
@@ -3312,25 +3306,9 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
       annotate_signal_string_end ();
       ui_out_text (uiout, ".\n");
       ui_out_text (uiout, "The program no longer exists.\n");
-#else
-      annotate_signalled ();
-      printf_filtered ("\nProgram terminated with signal ");
-      annotate_signal_name ();
-      printf_filtered ("%s", target_signal_to_name (stop_info));
-      annotate_signal_name_end ();
-      printf_filtered (", ");
-      annotate_signal_string ();
-      printf_filtered ("%s", target_signal_to_string (stop_info));
-      annotate_signal_string_end ();
-      printf_filtered (".\n");
-
-      printf_filtered ("The program no longer exists.\n");
-      gdb_flush (gdb_stdout);
-#endif
       break;
     case EXITED:
       /* The inferior program is finished. */
-#ifdef UI_OUT
       annotate_exited (stop_info);
       if (stop_info)
        {
@@ -3346,19 +3324,10 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
            ui_out_field_string (uiout, "reason", "exited-normally");
          ui_out_text (uiout, "\nProgram exited normally.\n");
        }
-#else
-      annotate_exited (stop_info);
-      if (stop_info)
-       printf_filtered ("\nProgram exited with code 0%o.\n",
-                        (unsigned int) stop_info);
-      else
-       printf_filtered ("\nProgram exited normally.\n");
-#endif
       break;
     case SIGNAL_RECEIVED:
       /* Signal received. The signal table tells us to print about
          it. */
-#ifdef UI_OUT
       annotate_signal ();
       ui_out_text (uiout, "\nProgram received signal ");
       annotate_signal_name ();
@@ -3371,19 +3340,6 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
       ui_out_field_string (uiout, "signal-meaning", target_signal_to_string (stop_info));
       annotate_signal_string_end ();
       ui_out_text (uiout, ".\n");
-#else
-      annotate_signal ();
-      printf_filtered ("\nProgram received signal ");
-      annotate_signal_name ();
-      printf_filtered ("%s", target_signal_to_name (stop_info));
-      annotate_signal_name_end ();
-      printf_filtered (", ");
-      annotate_signal_string ();
-      printf_filtered ("%s", target_signal_to_string (stop_info));
-      annotate_signal_string_end ();
-      printf_filtered (".\n");
-      gdb_flush (gdb_stdout);      
-#endif
       break;
     default:
       internal_error (__FILE__, __LINE__,
@@ -3466,13 +3422,11 @@ and/or watchpoints.\n");
 
   target_terminal_ours ();
 
-  /* Look up the hook_stop and run it if it exists.  */
-
-  if (stop_command && stop_command->hook_pre)
-    {
-      catch_errors (hook_stop_stub, stop_command->hook_pre,
-                   "Error while running hook_stop:\n", RETURN_MASK_ALL);
-    }
+  /* Look up the hook_stop and run it (CLI internally handles problem
+     of stop_command's pre-hook not existing).  */
+  if (stop_command)
+    catch_errors (hook_stop_stub, stop_command,
+                 "Error while running hook_stop:\n", RETURN_MASK_ALL);
 
   if (!target_has_stack)
     {
@@ -3487,7 +3441,7 @@ and/or watchpoints.\n");
 
   if (!stop_stack_dummy)
     {
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
 
       /* Print current location without a level number, if
          we have changed functions or hit a breakpoint.
@@ -3527,18 +3481,14 @@ and/or watchpoints.\n");
              internal_error (__FILE__, __LINE__,
                              "Unknown value.");
            }
-#ifdef UI_OUT
          /* For mi, have the same behavior every time we stop:
              print everything but the source line. */
          if (ui_out_is_mi_like_p (uiout))
            source_flag = LOC_AND_ADDRESS;
-#endif
 
-#ifdef UI_OUT
          if (ui_out_is_mi_like_p (uiout))
            ui_out_field_int (uiout, "thread-id",
                              pid_to_thread_id (inferior_ptid));
-#endif
          /* The behavior of this routine with respect to the source
             flag is:
             SRC_LINE: Print only source line
@@ -3567,7 +3517,7 @@ and/or watchpoints.\n");
          Can't rely on restore_inferior_status because that only gets
          called if we don't stop in the called function.  */
       stop_pc = read_pc ();
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
     }
 
 done:
@@ -3577,7 +3527,7 @@ done:
 static int
 hook_stop_stub (void *cmd)
 {
-  execute_user_command ((struct cmd_list_element *) cmd, 0);
+  execute_cmd_pre_hook ((struct cmd_list_element *) cmd);
   return (0);
 }
 \f
@@ -4074,7 +4024,7 @@ restore_selected_frame (void *args)
       return 0;
     }
 
-  select_frame (frame, fr->level);
+  select_frame (frame);
 
   return (1);
 }
@@ -4129,7 +4079,7 @@ restore_inferior_status (struct inferior_status *inf_status)
           frame.  */
 
 
-       select_frame (get_current_frame (), 0);
+       select_frame (get_current_frame ());
 
     }
 
@@ -4399,7 +4349,6 @@ A fork or vfork creates a new process.  follow-fork-mode can be:\n\
 For \"parent\" or \"child\", the unfollowed process will run free.\n\
 By default, the debugger will follow the parent process.",
                        &setlist);
-/*  c->function.sfunc = ; */
   add_show_from_set (c, &showlist);
 
   c = add_set_enum_cmd ("scheduler-locking", class_run,
@@ -4413,7 +4362,7 @@ step == scheduler locked during every single-step operation.\n\
        Other threads may run while stepping over a function call ('next').",
                        &setlist);
 
-  c->function.sfunc = set_schedlock_func;      /* traps on target vector */
+  set_cmd_sfunc (c, set_schedlock_func);       /* traps on target vector */
   add_show_from_set (c, &showlist);
 
   c = add_set_cmd ("step-mode", class_run,
This page took 0.044849 seconds and 4 git commands to generate.