[RFC,4/8] gdb, thread: simplify print_selected_thread_frame()
Checks
Commit Message
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(-)
@@ -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);
}