)]}'
{
  "commit": "1a17f7871a40a6e744a618cdbaa4366d4ebf11ba",
  "tree": "4958df1d4bce922dd3aae2db3b9ae19abc2e4ab2",
  "parents": [
    "e9fc42cf0567df6e309bfbdbaa9aed66d4ccd423"
  ],
  "author": {
    "name": "Pedro Alves",
    "email": "pedro@palves.net",
    "time": "Wed May 14 19:02:34 2025 +0100"
  },
  "committer": {
    "name": "Pedro Alves",
    "email": "pedro@palves.net",
    "time": "Thu Apr 30 18:37:32 2026 +0100"
  },
  "message": "infrun: with AS+NS, prefer process exit over thread exit\n\nThis patch fixes gdb.base/ending-run.exp for Windows when the target\nbackend supports notifying infrun about thread exit events (which is\nadded by the Windows non-stop support, later).\n\nWithout this patch, and with the Windows target in non-stop mode\n(\"maint set target-non-stop on\"), we get, when stepping out of main:\n\n (gdb) PASS: gdb.base/ending-run.exp: Step to return\n next\n 32      }\n (gdb) next\n [Thread 7956.0x2658 exited]\n [Thread 7956.0x2500 exited]\n [Thread 7956.0x2798 exited]\n Command aborted, thread exited.\n (gdb) FAIL: gdb.base/ending-run.exp: step out of main\n\nWith the patch, we get:\n\n (gdb) next\n [Thread 9424.0x40c exited]\n [Inferior 1 (process 9424) exited normally]\n (gdb) PASS: gdb.base/ending-run.exp: step out of main\n\nIn the failing case, what happens is that \"next\" enables\ntarget_thread_events.  Then, the main thread causes the whole process\nto exit.  On Windows, that makes the main thread report a thread exit\nevent, followed by thread exit events for all other threads, except\nthe last thread that happens to be the one that exits last.  That last\none reports an exit-process event instead.\n\nSince \"next\" enabled target_thread_events, the Windows target backend\nreports the main thread\u0027s exit event to infrun.  And then, since the\nthread that was stepping reported a thread-exit, GDB aborts the \"next\"\ncommand.\n\nStepping out of main is a very common thing to do, and I think\nreporting the thread exit in this case when the whole process is\nexiting isn\u0027t very useful.  I think we can do better.  So instead, if\nwe\u0027re about to report a thread exit in all-stop mode with the backend\nin non-stop mode, and while stopping all threads, we see a\nwhole-process-exit event, prefer processing that event instead of\nreporting the original thread exit.\n\nA similar issue can be triggered on GNU/Linux as well, if we step over\nan exit syscall that is called by any thread other than main.  This\nscenario is exercised by the new testcase added by this patch.\n\nWithout the patch, the testcase shows:\n\n (gdb) next\n [Thread 0x7ffff7a00640 (LWP 3207243) exited]\n warning: error removing breakpoint 0 at 0x5555555551c3\n warning: error removing breakpoint 0 at 0x5555555551c3\n warning: error removing breakpoint 0 at 0x5555555551c3\n Command aborted, thread exited.\n Cannot remove breakpoints because program is no longer writable.\n Further execution is probably impossible.\n (gdb)\n\nThis is fixed for GNU/Linux by the patch, which results in:\n\n (gdb) next\n [Thread 0x7ffff7a00640 (LWP 3230550) exited]\n warning: error removing breakpoint 0 at 0x5555555551c3\n warning: error removing breakpoint 0 at 0x5555555551c3\n warning: error removing breakpoint 0 at 0x5555555551c3\n [Inferior 1 (process 3230539) exited normally]\n (gdb)\n\nPure all-stop targets (such as GNU/Linux GDBserver unless you force\nnon-stop with \"maint set target-non-stop on\") will unfortunately still\nhave the \"Further execution is probably impossible.\" behavior, because\nGDB can\u0027t see the process-exit event until the target is re-resumed.\nThat\u0027s unfortunate, but I don\u0027t think that should prevent improving\nnon-stop targets.  (And eventually I would like remote targets to be\nalways \"maint set target-non-stop on\" by default if possible, too.)\n\nChange-Id: I56559f13e04aeafd812d15e4b408c8337bca5294\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "aed66bf844e95536ce50f9ca077ec0dfff53da4b",
      "old_mode": 33188,
      "old_path": "gdb/infrun.c",
      "new_id": "11c5d5214d647854654244f65d21763356a66987",
      "new_mode": 33188,
      "new_path": "gdb/infrun.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a9b86751596a391ce964987270c8c37b3a1ec73e",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/step-over-process-exit.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "6c98ebe3956c6acef749082f23ee3a0b42a930fb",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/step-over-process-exit.exp"
    }
  ]
}
