[04/11] gdb, remote: fix "info program" after reconnect to non-stop target

Message ID 20260518183316.127043-5-mohamed.bouhaouel@intel.com
State New
Headers
Series Enable non-stop mode by default for remote targets |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Bouhaouel, Mohamed May 18, 2026, 6:33 p.m. UTC
  From: "Bouhaouel, Mohamed" <mohamed.bouhaouel@intel.com>

After reconnecting to a non-stop remote target that has stopped threads,
"info program" incorrectly reports "The program being debugged is not
being run" instead of showing the stop information. This happens because
the previous_thread global is not updated when processing initial stop
replies.

Fix by calling update_previous_thread () after set_last_target_status ()
in print_one_stopped_thread ().

Scenario:
    - Connect to non-stop remote target
    - Thread receives signal (e.g., SIGUSR1) and stops
    - Disconnect and reconnect
    - "info program" reports "not being run" (FAIL)
---
 gdb/remote.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index b7ccd72829b..a73362a26ee 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5165,6 +5165,7 @@  remote_target::print_one_stopped_thread (thread_info *thread)
 
   /* For "info program".  */
   set_last_target_status (this, thread->ptid, ws);
+  update_previous_thread ();
 
   if (ws.kind () == TARGET_WAITKIND_STOPPED)
     {