[RFC,4/8] gdb, thread: simplify print_selected_thread_frame()

Message ID 20261001102847.576880-5-markus.t.metzger@intel.com
State New
Headers
Series breakpoint handling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Skipped because it is an RFC
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Skipped because it is an RFC

Commit Message

Metzger, Markus T Oct. 1, 2026, 10:28 a.m. UTC
  Handle selections one by one in separate blocks.

This fixes an issue with forgetting a newline at the end of the output if
USER_SELECTED_THREAD is specified, USER_SELECTED_FRAME is not specified,
and the thread is not running.

Since the function is never called with just USER_SELECTED_THREAD, this
does not occur in practice.  This will change with a subsequent commit.
---
 gdb/thread.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
  

Patch

diff --git a/gdb/thread.c b/gdb/thread.c
index 0f86f6efe38..bbcd3e61cd1 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -2141,19 +2141,16 @@  print_selected_thread_frame (struct ui_out *uiout,
 	  uiout->text (target_pid_to_str (inferior_ptid));
 	  uiout->text (")]");
 	}
-    }
 
-  if (tp->state () == THREAD_RUNNING)
-    {
-      if (selection & USER_SELECTED_THREAD)
-	uiout->text ("(running)\n");
+      if (tp->state () == THREAD_RUNNING)
+	uiout->text ("(running)");
+
+      uiout->text ("\n");
     }
-  else if (selection & USER_SELECTED_FRAME)
-    {
-      if (selection & USER_SELECTED_THREAD)
-	uiout->text ("\n");
 
-      if (has_stack_frames ())
+  if (selection & USER_SELECTED_FRAME)
+    {
+      if ((tp->state () != THREAD_RUNNING) && has_stack_frames ())
 	print_stack_frame_to_uiout (uiout, get_selected_frame (),
 				    1, SRC_AND_LOC, 1);
     }