Add a symbol's value to the computed frag offset, rather than overwriting it.
[deliverable/binutils-gdb.git] / gdb / infrun.c
index 591f819d83f90af8e0bded9d1ad42aee8322f9db..078e95726745e77393236e2424be7138035dcdc0 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-struct-independent code to start (run) and stop an inferior process.
-   Copyright 1986-1989, 1991-1999 Free Software Foundation, Inc.
+   Copyright 1986-1989, 1991-2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,7 +25,7 @@
 #include "frame.h"
 #include "inferior.h"
 #include "breakpoint.h"
-#include "wait.h"
+#include "gdb_wait.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "target.h"
@@ -92,17 +92,7 @@ int sync_execution = 0;
    when the inferior stopped in a different thread than it had been
    running in.  */
 
-static int switched_from_inferior_pid;
-
-/* This will be true for configurations that may actually report an
-   inferior pid different from the original.  At present this is only
-   true for HP-UX native.  */
-
-#ifndef MAY_SWITCH_FROM_INFERIOR_PID
-#define MAY_SWITCH_FROM_INFERIOR_PID (0)
-#endif
-
-static int may_switch_from_inferior_pid = MAY_SWITCH_FROM_INFERIOR_PID;
+static int previous_inferior_pid;
 
 /* This is true for configurations that may follow through execl() and
    similar functions.  At present this is only true for HP-UX native.  */
@@ -871,6 +861,8 @@ resume (int step, enum target_signal sig)
 
   if (should_resume)
     {
+      int resume_pid;
+
       if (use_thread_step_needed && thread_step_needed)
        {
          /* We stopped on a BPT instruction;
@@ -882,7 +874,7 @@ resume (int step, enum target_signal sig)
            {
              /* Breakpoint deleted: ok to do regular resume
                 where all the threads either step or continue. */
-             target_resume (-1, step, sig);
+             resume_pid = -1;
            }
          else
            {
@@ -894,20 +886,19 @@ resume (int step, enum target_signal sig)
                  trap_expected = 1;
                  step = 1;
                }
-
-             target_resume (inferior_pid, step, sig);
+             resume_pid = inferior_pid;
            }
        }
       else
        {
          /* Vanilla resume. */
-
          if ((scheduler_mode == schedlock_on) ||
              (scheduler_mode == schedlock_step && step != 0))
-           target_resume (inferior_pid, step, sig);
+           resume_pid = inferior_pid;
          else
-           target_resume (-1, step, sig);
+           resume_pid = -1;
        }
+      target_resume (resume_pid, step, sig);
     }
 
   discard_cleanups (old_cleanups);
@@ -1250,8 +1241,7 @@ wait_for_inferior (void)
   thread_step_needed = 0;
 
   /* We'll update this if & when we switch to a new thread. */
-  if (may_switch_from_inferior_pid)
-    switched_from_inferior_pid = inferior_pid;
+  previous_inferior_pid = inferior_pid;
 
   overlay_cache_invalid = 1;
 
@@ -1312,8 +1302,7 @@ fetch_inferior_event (client_data)
       thread_step_needed = 0;
 
       /* We'll update this if & when we switch to a new thread. */
-      if (may_switch_from_inferior_pid)
-       switched_from_inferior_pid = inferior_pid;
+      previous_inferior_pid = inferior_pid;
 
       overlay_cache_invalid = 1;
 
@@ -1453,7 +1442,13 @@ handle_inferior_event (struct execution_control_state *ecs)
       {
        add_thread (ecs->pid);
 
+#ifdef UI_OUT
+       ui_out_text (uiout, "[New ");
+       ui_out_text (uiout, target_pid_or_tid_to_str (ecs->pid));
+       ui_out_text (uiout, "]\n");
+#else
        printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->pid));
+#endif
 
 #if 0
        /* NOTE: This block is ONLY meant to be invoked in case of a
@@ -1944,15 +1939,12 @@ handle_inferior_event (struct execution_control_state *ecs)
                               &ecs->stepping_through_solib_catchpoints,
                               &ecs->stepping_through_sigtramp);
          }
-       if (may_switch_from_inferior_pid)
-         switched_from_inferior_pid = inferior_pid;
 
        inferior_pid = ecs->pid;
 
        if (context_hook)
          context_hook (pid_to_thread_id (ecs->pid));
 
-       printf_filtered ("[Switching to %s]\n", target_pid_to_str (ecs->pid));
        flush_cached_frames ();
       }
 
@@ -3238,6 +3230,19 @@ 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 ();
+      ui_out_text (uiout, "\nProgram terminated with signal ");
+      annotate_signal_name ();
+      ui_out_field_string (uiout, "signal-name", target_signal_to_name (stop_info));
+      annotate_signal_name_end ();
+      ui_out_text (uiout, ", ");
+      annotate_signal_string ();
+      ui_out_field_string (uiout, "signal-meaning", target_signal_to_string (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 ();
@@ -3251,19 +3256,46 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
 
       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)
+       {
+         ui_out_text (uiout, "\nProgram exited with code ");
+         ui_out_field_fmt (uiout, "exit-code", "0%o", (unsigned int) stop_info);
+         ui_out_text (uiout, ".\n");
+       }
+      else
+       {
+         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 ();
+      ui_out_field_string (uiout, "signal-name", target_signal_to_name (stop_info));
+      annotate_signal_name_end ();
+      ui_out_text (uiout, ", ");
+      annotate_signal_string ();
+      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 ();
@@ -3275,6 +3307,7 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info)
       annotate_signal_string_end ();
       printf_filtered (".\n");
       gdb_flush (gdb_stdout);      
+#endif
       break;
     default:
       internal_error ("print_stop_reason: unrecognized enum value");
@@ -3300,14 +3333,13 @@ normal_stop (void)
 
      (Note that there's no point in saying anything if the inferior
      has exited!) */
-  if (may_switch_from_inferior_pid
-      && (switched_from_inferior_pid != inferior_pid)
+  if ((previous_inferior_pid != inferior_pid)
       && target_has_execution)
     {
       target_terminal_ours_for_output ();
-      printf_filtered ("[Switched to %s]\n",
+      printf_filtered ("[Switching to %s]\n",
                       target_pid_or_tid_to_str (inferior_pid));
-      switched_from_inferior_pid = inferior_pid;
+      previous_inferior_pid = inferior_pid;
     }
 
   /* Make sure that the current_frame's pc is correct.  This
@@ -3397,15 +3429,15 @@ The same program may be running in another process.\n");
              if (stop_step
                  && step_frame_address == FRAME_FP (get_current_frame ())
                  && step_start_function == find_pc_function (stop_pc))
-               source_flag = -1;   /* finished step, just print source line */
+               source_flag = SRC_LINE;   /* finished step, just print source line */
              else
-               source_flag = 1;    /* print location and source line */
+               source_flag = SRC_AND_LOC;    /* print location and source line */
              break;
            case PRINT_SRC_AND_LOC:
-             source_flag = 1;      /* print location and source line */
+             source_flag = SRC_AND_LOC;    /* print location and source line */
              break;
            case PRINT_SRC_ONLY:
-             source_flag = -1;
+             source_flag = SRC_LINE;
              break;
            case PRINT_NOTHING:
              do_frame_printing = 0;
@@ -3416,9 +3448,9 @@ The same program may be running in another process.\n");
 
          /* The behavior of this routine with respect to the source
             flag is:
-            -1: Print only source line
-            0: Print only location
-            1: Print location and source line */
+            SRC_LINE: Print only source line
+            LOCATION: Print only location
+            SRC_AND_LOC: Print location and source line */
          if (do_frame_printing)
            show_and_print_stack_frame (selected_frame, -1, source_flag);
 
This page took 0.027653 seconds and 4 git commands to generate.