* infcall.c (run_inferior_call): Remove references to
[deliverable/binutils-gdb.git] / gdb / infrun.c
index 2afc738010eac758e700602b9d3fa697cefff917..8466ed6bb22d5d9d9c9fdf2edbae59e4ca257e68 100644 (file)
@@ -1660,7 +1660,7 @@ infrun_thread_stop_requested_callback (struct thread_info *info, void *arg)
    Cleanup local state that assumed the PTID was to be resumed, and
    report the stop to the frontend.  */
 
-void
+static void
 infrun_thread_stop_requested (ptid_t ptid)
 {
   struct displaced_step_request *it, *next, *prev = NULL;
@@ -1737,6 +1737,46 @@ delete_step_thread_step_resume_breakpoint_cleanup (void *arg)
   delete_step_thread_step_resume_breakpoint ();
 }
 
+/* Pretty print the results of target_wait, for debugging purposes.  */
+
+static void
+print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
+                          const struct target_waitstatus *ws)
+{
+  char *status_string = target_waitstatus_to_string (ws);
+  struct ui_file *tmp_stream = mem_fileopen ();
+  char *text;
+  long len;
+
+  /* The text is split over several lines because it was getting too long.
+     Call fprintf_unfiltered (gdb_stdlog) once so that the text is still
+     output as a unit; we want only one timestamp printed if debug_timestamp
+     is set.  */
+
+  fprintf_unfiltered (tmp_stream,
+                     "infrun: target_wait (%d", PIDGET (waiton_ptid));
+  if (PIDGET (waiton_ptid) != -1)
+    fprintf_unfiltered (tmp_stream,
+                       " [%s]", target_pid_to_str (waiton_ptid));
+  fprintf_unfiltered (tmp_stream, ", status) =\n");
+  fprintf_unfiltered (tmp_stream,
+                     "infrun:   %d [%s],\n",
+                     PIDGET (result_ptid), target_pid_to_str (result_ptid));
+  fprintf_unfiltered (tmp_stream,
+                     "infrun:   %s\n",
+                     status_string);
+
+  text = ui_file_xstrdup (tmp_stream, &len);
+
+  /* This uses %s in part to handle %'s in the text, but also to avoid
+     a gcc error: the format attribute requires a string literal.  */
+  fprintf_unfiltered (gdb_stdlog, "%s", text);
+
+  xfree (status_string);
+  xfree (text);
+  ui_file_delete (tmp_stream);
+}
+
 /* Wait for control to return from inferior to debugger.
 
    If TREAT_EXEC_AS_SIGTRAP is non-zero, then handle EXEC signals
@@ -1790,14 +1830,7 @@ wait_for_inferior (int treat_exec_as_sigtrap)
        ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
 
       if (debug_infrun)
-       {
-         char *status_string = target_waitstatus_to_string (&ecs->ws);
-         fprintf_unfiltered (gdb_stdlog,
-                             "infrun: target_wait (%d, status) = %d, %s\n",
-                             PIDGET (waiton_ptid), PIDGET (ecs->ptid),
-                             status_string);
-         xfree (status_string);
-       }
+       print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
 
       if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD)
         {
@@ -1875,14 +1908,7 @@ fetch_inferior_event (void *client_data)
     ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
 
   if (debug_infrun)
-    {
-      char *status_string = target_waitstatus_to_string (&ecs->ws);
-      fprintf_unfiltered (gdb_stdlog,
-                         "infrun: target_wait (%d, status) = %d, %s\n",
-                         PIDGET (waiton_ptid), PIDGET (ecs->ptid),
-                         status_string);
-      xfree (status_string);
-    }
+    print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
 
   if (non_stop
       && ecs->ws.kind != TARGET_WAITKIND_IGNORE
@@ -4213,10 +4239,10 @@ normal_stop (void)
   if (target_has_execution)
     {
       if (!non_stop)
-       old_chain = make_cleanup (finish_thread_state_cleanup, &minus_one_ptid);
+       make_cleanup (finish_thread_state_cleanup, &minus_one_ptid);
       else if (last.kind != TARGET_WAITKIND_SIGNALLED
               && last.kind != TARGET_WAITKIND_EXITED)
-       old_chain = make_cleanup (finish_thread_state_cleanup, &inferior_ptid);
+       make_cleanup (finish_thread_state_cleanup, &inferior_ptid);
     }
 
   /* In non-stop mode, we don't want GDB to switch threads behind the
@@ -4407,11 +4433,25 @@ Further execution is probably impossible.\n"));
 
 done:
   annotate_stopped ();
-  if (!suppress_stop_observer
-      && !(target_has_execution
-          && last.kind != TARGET_WAITKIND_SIGNALLED
-          && last.kind != TARGET_WAITKIND_EXITED
-          && inferior_thread ()->step_multi))
+
+  /* Suppress the stop observer if we're in the middle of:
+
+     - a step n (n > 1), as there still more steps to be done.
+
+     - a "finish" command, as the observer will be called in
+       finish_command_continuation, so it can include the inferior
+       function's return value.
+
+     - calling an inferior function, as we pretend we inferior didn't
+       run at all.  The return value of the call is handled by the
+       expression evaluator, through call_function_by_hand.  */
+
+  if (!target_has_execution
+      || last.kind == TARGET_WAITKIND_SIGNALLED
+      || last.kind == TARGET_WAITKIND_EXITED
+      || (!inferior_thread ()->step_multi
+         && !(inferior_thread ()->stop_bpstat
+              && inferior_thread ()->proceed_to_finish)))
     {
       if (!ptid_equal (inferior_ptid, null_ptid))
        observer_notify_normal_stop (inferior_thread ()->stop_bpstat,
@@ -4637,8 +4677,8 @@ handle_command (char *args, int from_tty)
            case TARGET_SIGNAL_INT:
              if (!allsigs && !sigs[signum])
                {
-                 if (query ("%s is used by the debugger.\n\
-Are you sure you want to change it? ", target_signal_to_name ((enum target_signal) signum)))
+                 if (query (_("%s is used by the debugger.\n\
+Are you sure you want to change it? "), target_signal_to_name ((enum target_signal) signum)))
                    {
                      sigs[signum] = 1;
                    }
@@ -4848,7 +4888,7 @@ static struct lval_funcs siginfo_value_funcs =
    the current thread.  Return a void value if there's no object
    available.  */
 
-struct value *
+static struct value *
 siginfo_make_value (struct internalvar *var)
 {
   struct type *type;
This page took 0.027917 seconds and 4 git commands to generate.