gdb: tweak format of infrun debug log
[deliverable/binutils-gdb.git] / gdb / thread.c
index 54b59e22448a260e4190ffe5438b8b5c799a1cd9..02672f01fcf13aed1a5d4571d3e6d15002233e7d 100644 (file)
@@ -1488,8 +1488,16 @@ scoped_restore_current_thread::scoped_restore_current_thread ()
       else
        frame = NULL;
 
-      m_selected_frame_id = get_frame_id (frame);
-      m_selected_frame_level = frame_relative_level (frame);
+      try
+       {
+         m_selected_frame_id = get_frame_id (frame);
+         m_selected_frame_level = frame_relative_level (frame);
+       }
+      catch (const gdb_exception_error &ex)
+       {
+         m_selected_frame_id = null_frame_id;
+         m_selected_frame_level = -1;
+       }
 
       tp->incref ();
       m_thread = tp;
@@ -1563,6 +1571,14 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
                   const qcs_flags &flags)
 {
   switch_to_thread (thr);
+
+  /* The thread header is computed before running the command since
+     the command can change the inferior, which is not permitted
+     by thread_target_id_str.  */
+  std::string thr_header =
+    string_printf (_("\nThread %s (%s):\n"), print_thread_id (thr),
+                  thread_target_id_str (thr).c_str ());
+
   try
     {
       std::string cmd_result = execute_command_to_string
@@ -1570,9 +1586,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
       if (!flags.silent || cmd_result.length () > 0)
        {
          if (!flags.quiet)
-           printf_filtered (_("\nThread %s (%s):\n"),
-                            print_thread_id (thr),
-                            target_pid_to_str (inferior_ptid).c_str ());
+           printf_filtered ("%s", thr_header.c_str ());
          printf_filtered ("%s", cmd_result.c_str ());
        }
     }
@@ -1581,9 +1595,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
       if (!flags.silent)
        {
          if (!flags.quiet)
-           printf_filtered (_("\nThread %s (%s):\n"),
-                            print_thread_id (thr),
-                            target_pid_to_str (inferior_ptid).c_str ());
+           printf_filtered ("%s", thr_header.c_str ());
          if (flags.cont)
            printf_filtered ("%s\n", ex.what ());
          else
@@ -2031,7 +2043,7 @@ thread_select (const char *tidstr, thread_info *tp)
 
   /* Since the current thread may have changed, see if there is any
      exited thread we can now delete.  */
-  prune_threads ();
+  delete_exited_threads ();
 }
 
 /* Print thread and frame switch command response.  */
This page took 0.026552 seconds and 4 git commands to generate.