Don't print 0x for core_addr_to_string_nz
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index 9aae86081e0cbafcfe15c1c836f399ca7513be59..a80bf0a2ceb33309e702ec4742b89a03273e178b 100644 (file)
@@ -1,6 +1,6 @@
 /* Memory-access and commands for "inferior" process, for GDB.
 
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -960,7 +960,7 @@ step_command_fsm_prepare (struct step_command_fsm *sm,
   sm->skip_subroutines = skip_subroutines;
   sm->single_inst = single_inst;
   sm->count = count;
-  sm->thread = thread->num;
+  sm->thread = thread->global_num;
 
   /* Leave the si command alone.  */
   if (!sm->single_inst || sm->skip_subroutines)
@@ -1032,7 +1032,7 @@ static int
 step_command_fsm_should_stop (struct thread_fsm *self)
 {
   struct step_command_fsm *sm = (struct step_command_fsm *) self;
-  struct thread_info *tp = find_thread_id (sm->thread);
+  struct thread_info *tp = find_thread_global_id (sm->thread);
 
   if (tp->control.stop_step)
     {
@@ -1316,8 +1316,8 @@ signal_command (char *signum_exp, int from_tty)
            {
              if (!must_confirm)
                printf_unfiltered (_("Note:\n"));
-             printf_unfiltered (_("  Thread %d previously stopped with signal %s, %s.\n"),
-                                tp->num,
+             printf_unfiltered (_("  Thread %s previously stopped with signal %s, %s.\n"),
+                                print_thread_id (tp),
                                 gdb_signal_to_name (tp->suspend.stop_signal),
                                 gdb_signal_to_string (tp->suspend.stop_signal));
              must_confirm = 1;
@@ -1325,10 +1325,10 @@ signal_command (char *signum_exp, int from_tty)
        }
 
       if (must_confirm
-         && !query (_("Continuing thread %d (the current thread) with specified signal will\n"
+         && !query (_("Continuing thread %s (the current thread) with specified signal will\n"
                       "still deliver the signals noted above to their respective threads.\n"
                       "Continue anyway? "),
-                    inferior_thread ()->num))
+                    print_thread_id (inferior_thread ())))
        error (_("Not confirmed."));
     }
 
@@ -1478,7 +1478,7 @@ until_next_command (int from_tty)
   struct symbol *func;
   struct symtab_and_line sal;
   struct thread_info *tp = inferior_thread ();
-  int thread = tp->num;
+  int thread = tp->global_num;
   struct cleanup *old_chain;
   struct until_next_fsm *sm;
 
@@ -1520,12 +1520,11 @@ until_next_command (int from_tty)
   set_longjmp_breakpoint (tp, get_frame_id (frame));
   old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
 
-  sm = new_until_next_fsm (tp->num);
+  sm = new_until_next_fsm (tp->global_num);
   tp->thread_fsm = &sm->thread_fsm;
   discard_cleanups (old_chain);
 
   proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
-
 }
 
 static void
@@ -1774,7 +1773,7 @@ finish_command_fsm_should_stop (struct thread_fsm *self)
 {
   struct finish_command_fsm *f = (struct finish_command_fsm *) self;
   struct return_value_info *rv = &f->return_value;
-  struct thread_info *tp = find_thread_id (f->thread);
+  struct thread_info *tp = find_thread_global_id (f->thread);
 
   if (f->function != NULL
       && bpstat_find_breakpoint (tp->control.stop_bpstat,
@@ -1967,7 +1966,7 @@ finish_command (char *arg, int from_tty)
 
   tp = inferior_thread ();
 
-  sm = new_finish_command_fsm (tp->num);
+  sm = new_finish_command_fsm (tp->global_num);
 
   tp->thread_fsm = &sm->thread_fsm;
 
@@ -2001,11 +2000,6 @@ finish_command (char *arg, int from_tty)
       return;
     }
 
-  /* Ignore TAILCALL_FRAME type frames, they were executed already before
-     entering THISFRAME.  */
-  while (get_frame_type (frame) == TAILCALL_FRAME)
-    frame = get_prev_frame (frame);
-
   /* Find the function we will return from.  */
 
   sm->function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
@@ -2032,7 +2026,16 @@ finish_command (char *arg, int from_tty)
   if (execution_direction == EXEC_REVERSE)
     finish_backward (sm);
   else
-    finish_forward (sm, frame);
+    {
+      /* Ignore TAILCALL_FRAME type frames, they were executed already before
+        entering THISFRAME.  */
+      frame = skip_tailcall_frames (frame);
+
+      if (frame == NULL)
+       error (_("Cannot find the caller frame."));
+
+      finish_forward (sm, frame);
+    }
 }
 \f
 
@@ -2697,8 +2700,32 @@ attach_post_wait (char *args, int from_tty, enum attach_post_wait_mode mode)
         selected thread is stopped, others may still be executing.
         Be sure to explicitly stop all threads of the process.  This
         should have no effect on already stopped threads.  */
-      if (target_is_non_stop_p ())
+      if (non_stop)
        target_stop (pid_to_ptid (inferior->pid));
+      else if (target_is_non_stop_p ())
+       {
+         struct thread_info *thread;
+         struct thread_info *lowest = inferior_thread ();
+         int pid = current_inferior ()->pid;
+
+         stop_all_threads ();
+
+         /* It's not defined which thread will report the attach
+            stop.  For consistency, always select the thread with
+            lowest GDB number, which should be the main thread, if it
+            still exists.  */
+         ALL_NON_EXITED_THREADS (thread)
+           {
+             if (ptid_get_pid (thread->ptid) == pid)
+               {
+                 if (thread->inf->num < lowest->inf->num
+                     || thread->per_inf_num < lowest->per_inf_num)
+                   lowest = thread;
+               }
+           }
+
+         switch_to_thread (lowest->ptid);
+       }
 
       /* Tell the user/frontend where we're stopped.  */
       normal_stop ();
This page took 0.026438 seconds and 4 git commands to generate.