aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c79
1 files changed, 58 insertions, 21 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 7645340..e343647 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1932,37 +1932,74 @@ finish_command (const char *arg, int from_tty)
static void
info_program_command (const char *args, int from_tty)
{
- bpstat *bs;
- int num, stat;
- ptid_t ptid;
- process_stratum_target *proc_target;
+ scoped_restore_current_thread restore_thread;
- if (!target_has_execution ())
- {
- gdb_printf (_("The program being debugged is not being run.\n"));
- return;
- }
+ thread_info *tp;
+
+ /* In non-stop, since every thread is controlled individually, we'll
+ show execution info about the current thread. In all-stop, we'll
+ show execution info about the last stop. */
if (non_stop)
{
- ptid = inferior_ptid;
- proc_target = current_inferior ()->process_target ();
+ if (!target_has_execution ())
+ {
+ gdb_printf (_("The program being debugged is not being run.\n"));
+ return;
+ }
+
+ if (inferior_ptid == null_ptid)
+ error (_("No selected thread."));
+
+ tp = inferior_thread ();
+
+ gdb_printf (_("Selected thread %s (%s).\n"),
+ print_thread_id (tp),
+ target_pid_to_str (tp->ptid).c_str ());
+
+ if (tp->state == THREAD_EXITED)
+ {
+ gdb_printf (_("Selected thread has exited.\n"));
+ return;
+ }
+ else if (tp->state == THREAD_RUNNING)
+ {
+ gdb_printf (_("Selected thread is running.\n"));
+ return;
+ }
}
else
- get_last_target_status (&proc_target, &ptid, nullptr);
+ {
+ tp = get_previous_thread ();
+
+ if (tp == nullptr)
+ {
+ gdb_printf (_("The program being debugged is not being run.\n"));
+ return;
+ }
- if (ptid == null_ptid || ptid == minus_one_ptid)
- error (_("No selected thread."));
+ switch_to_thread (tp);
- thread_info *tp = find_thread_ptid (proc_target, ptid);
+ gdb_printf (_("Last stopped for thread %s (%s).\n"),
+ print_thread_id (tp),
+ target_pid_to_str (tp->ptid).c_str ());
- if (tp->state == THREAD_EXITED)
- error (_("Invalid selected thread."));
- else if (tp->state == THREAD_RUNNING)
- error (_("Selected thread is running."));
+ if (tp->state == THREAD_EXITED)
+ {
+ gdb_printf (_("Thread has since exited.\n"));
+ return;
+ }
+
+ if (tp->state == THREAD_RUNNING)
+ {
+ gdb_printf (_("Thread is now running.\n"));
+ return;
+ }
+ }
- bs = tp->control.stop_bpstat;
- stat = bpstat_num (&bs, &num);
+ int num;
+ bpstat *bs = tp->control.stop_bpstat;
+ int stat = bpstat_num (&bs, &num);
target_files_info ();
gdb_printf (_("Program stopped at %s.\n"),