Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/47] Windows non-stop mode
@ 2025-05-19 13:22 Pedro Alves
  2025-05-19 13:22 ` [PATCH v2 01/47] Make default_gdb_exit resilient to failed closes Pedro Alves
                   ` (47 more replies)
  0 siblings, 48 replies; 101+ messages in thread
From: Pedro Alves @ 2025-05-19 13:22 UTC (permalink / raw)
  To: gdb-patches

After a long while (a year, w00t!), here is another iteration of the
Windows non-stop work.

I've pushed the series to the users/palves/windows-non-stop-v2 branch
on sourceware.org, for your convenience.

Compared to the previous version from a year ago (gasp!), here:

 https://inbox.sourceware.org/gdb-patches/20240507234233.371123-1-pedro@palves.net/

... many issues where fixed, and it should be a lot more stable.  I
think I fixed the problems Tromey found out when he ran the series
against the AdaCore testsuite, particularly around detaching.

The series is bigger, it is now 47 patches instead of 34.

These patches are new:

 + [PATCH v2 01/47] Make default_gdb_exit resilient to failed closes
 + [PATCH v2 02/47] Add test for continuing with some threads running
 + [PATCH v2 03/47] infrun: Remove unnecessary currently_stepping call
 + [PATCH v2 04/47] infrun: Split currently_stepping, fix sw watchpoints issue
 + [PATCH v2 05/47] thread_info::executing+resumed -> thread_info::internal_state
 + [PATCH v2 36/47] linux-nat: Factor out get_detach_signal code to common code
 + [PATCH v2 37/47] Windows GDB: make windows_thread_info be private thread_info data
 + [PATCH v2 38/47] Introduce windows_nat::event_code_to_string
 + [PATCH v2 40/47] Windows gdb: Eliminate invalidate_context
 + [PATCH v2 42/47] gdb_test_multiple: Anchor prompt match if -lbl
 + [PATCH v2 43/47] Windows gdb: extra thread info => show exiting
 + [PATCH v2 44/47] Add gdb.threads/leader-exit-schedlock.exp
 + [PATCH v2 45/47] infrun: with AS+NS, prefer process exit over thread exit
 + [PATCH v2 46/47] Windows gdb: Always non-stop

The last one above (#46) was split from the main non-stop patch so
that AS-on-NS is only activated after the new infrun changes are
merged.

Note that patches above with subject that starts with "infrun" or
"thread_info" are changes to common code.

This patch from the previous version of the series was dropped:

 -  windows_per_inferior::continue_one_thread, unify WoW64/non-WoW64 paths

... as no longer needed, since Hannes's:

  commit b2682eade4db993bc8231007ba94aec4e4728c61
  Author:     Hannes Domani <ssbssa@yahoo.de>
  AuthorDate: Fri Dec 6 14:04:00 2024 +0100

      Reduce WOW64 code duplication

The "Windows gdb: Add non-stop support" patch changed in some
important areas compared to the previous version.  Here's a summary:

 - We can't use DBG_REPLY_LATER with thread/process exit events.  For
   those, we need to use the pre-exiting pending-status mechanism.

 - When a thread that is abruptly killed has a pending DBG_REPLY_LATER
   reply queued in the kernel, we always see that queued event first
   before the thread exit event.

 - The above two points required careful handling of the
   (th->suspended == -1) state in some places.

 - windows-nat.c was in some cases deleting the thread before
   reporting TARGET_WAITKIND_THREAD_EXITED to infrun (when
   target_thread_events was active), resulting in a double free,
   because infrun deletes the thread as well.  OTOH, when
   TARGET_WAITKIND_THREAD_EXITED was reported and windows-nat.c didn't
   delete the thread, nothing was deleting the corresponding
   windows_thread_info object, resulting weird confusion in the
   windows backend, with stale threads still in the backend list.

 - TARGET_WAITKIND_NO_RESUMED is now implemented.

 - The new "Add gdb.threads/leader-exit-schedlock.exp" patch adds a
   test that exercises all the points above.  The pre-existing
   "gdb.base/ending-run.exp" testcase also covers some aspects.

 - Adjusted to new model introduced by the
   "thread_info::executing+resumed -> thread_info::internal_state"
   patch earlier in the series.

 - Adjusted to windows_thread_info being owned by the thread_info
   object.

 - The do_initial_windows_stuff run-to-initial-breakpoint loop now
   handles target_thread_events enabled correctly.

 - Fixes detaching with queued DBG_REPLY_LATER events on the kernel
   side.  The Windows kernel re-raises any exception previously
   intercepted and deferred with DBG_REPLY_LATER in the inferior after
   we detach.  We need to flush those events, otherwise the inferior
   dies immediately after the detach, due to an unhandled exception.

 - The intro text added to windows-nat.c has more paragraphs and
   sections detailing the new things I've learned along the way since
   the last time.

In the NEWS patch, I'm now mentioning scheduler-locking support too.
Previously I only mentioned non-stop.

I've added "Approved-By:" tags from last year's review, to patches
that haven't changed since.  Some of them I could have pushed back
then, but I didn't want to do that until the v2 series was complete,
in case some problems I was addressing in v2 were caused by those
preparatory patches.

The "prerequisite-patch-id" at the bottom is:

 [PATCH] Fix build when RUSAGE_THREAD is not available & add warning
 https://inbox.sourceware.org/gdb-patches/20250517213056.3251858-1-pedro@palves.net/T/#u

Here's the original intro blurb, still accurate:

This series adds non-stop mode support to the Windows native backend,
on Windows 10 and above.  Earlier Windows versions lack the necessary
feature, so those keep working in all-stop mode, only.

After the series, the Windows target backend defaults to working in
non-stop mode (as in, "maint set target-non-stop"), even if
user-visible mode is all-stop ("set non-stop off").  This is the same
as the Linux backend.

I've been testing this on Cygwin native with the GDB testsuite as I've
been developing this.  Running the testsuite on Cygwin is a pain, and
many testcases run into cascading timeouts still, and some even hang
the test run forever until you kill them manually.  I've got another
series of patches to improve such tests and skip others, and that's
what I've been testing with.  I've also tested the series with the
windows-nat backend forced to all-stop mode.

Pedro Alves (47):
  Make default_gdb_exit resilient to failed closes
  Add test for continuing with some threads running
  infrun: Remove unnecessary currently_stepping call
  infrun: Split currently_stepping, fix sw watchpoints issue
  thread_info::executing+resumed -> thread_info::internal_state
  Windows gdb: Dead code in windows_nat_target::do_initial_windows_stuff
  Windows gdb: Eliminate global current_process.dr[8] global
  Windows gdb+gdbserver: New find_thread, replaces
    thread_rec(DONT_INVALIDATE_CONTEXT)
  Windows gdb: handle_output_debug_string return type
  Windows gdb: Eliminate reload_context
  Windows gdb+gdbserver: Eliminate thread_rec(INVALIDATE_CONTEXT) calls
  Windows gdb+gdbserver: Eliminate DONT_SUSPEND
  Windows gdb+gdbserver: Eliminate windows_process_info::thread_rec
  Windows gdb: Simplify windows_nat_target::wait
  Windows gdb+gdbserver: Move suspending thread to when returning event
  Windows gdb: Introduce continue_last_debug_event_main_thread
  Windows gdb: Introduce windows_continue_flags
  Windows gdb: Factor code out of windows_nat_target::windows_continue
  Windows gdb: Pending stop and current_event
  Windows gdb+gdbserver: Elim desired_stop_thread_id / rework
    pending_stops
  Windows gdb+gdbserver: Introduce get_last_debug_event_ptid
  Windows gdb: Can't pass signal to thread other than last stopped
    thread
  Windows gdbserver: Fix scheduler-locking
  Windows gdb: Enable "set scheduler-locking on"
  Windows gdbserver: Eliminate soft-interrupt mechanism
  Windows gdb+gdbserver: Make current_event per-thread state
  Windows gdb+gdbserver: Make last_sig per-thread state
  Windows gdb+gdbserver: Make siginfo_er per-thread state
  Add backpointer from windows_thread_info to windows_process_info
  Windows gdb+gdbserver: Share $_siginfo reading code
  Windows gdb+gdbserver: Eliminate struct pending_stop
  Windows gdb: Change serial_event management
  Windows gdb: cygwin_set_dr => windows_set_dr, etc.
  Windows gdb: Avoid writing debug registers if watchpoint hit pending
  Windows gdb+gdbserver: Check whether DBG_REPLY_LATER is available
  linux-nat: Factor out get_detach_signal code to common code
  Windows GDB: make windows_thread_info be private thread_info data
  Introduce windows_nat::event_code_to_string
  Windows gdb: Add non-stop support
  Windows gdb: Eliminate invalidate_context
  Windows gdb: Watchpoints while running (internal vs external stops)
  gdb_test_multiple: Anchor prompt match if -lbl
  Windows gdb: extra thread info => show exiting
  Add gdb.threads/leader-exit-schedlock.exp
  infrun: with AS+NS, prefer process exit over thread exit
  Windows gdb: Always non-stop (default to "maint set target-non-stop
    on")
  Mention Windows scheduler-locking and non-stop support in NEWS

 gdb/NEWS                                      |    6 +
 gdb/aarch64-tdep.c                            |    2 +-
 gdb/amd-dbgapi-target.c                       |    8 +-
 gdb/breakpoint.c                              |    9 +-
 gdb/bsd-uthread.c                             |    4 +-
 gdb/fork-child.c                              |    4 +-
 gdb/frame.c                                   |    4 +-
 gdb/gcore.c                                   |    4 +-
 gdb/gdbthread.h                               |  150 +-
 gdb/i386-tdep.c                               |    4 +-
 gdb/inf-ptrace.c                              |    2 +-
 gdb/infcall.c                                 |    8 +-
 gdb/infcmd.c                                  |   39 +-
 gdb/inferior.h                                |    4 +-
 gdb/inflow.c                                  |    2 +-
 gdb/infrun.c                                  |  429 ++--
 gdb/infrun.h                                  |   13 +-
 gdb/linux-fork.c                              |    9 +-
 gdb/linux-nat.c                               |   44 +-
 gdb/linux-thread-db.c                         |    4 +-
 gdb/mi/mi-cmd-var.c                           |    4 +-
 gdb/mi/mi-interp.c                            |    2 +-
 gdb/mi/mi-main.c                              |    8 +-
 gdb/nat/windows-nat.c                         |  176 +-
 gdb/nat/windows-nat.h                         |  223 +-
 gdb/process-stratum-target.c                  |    6 +-
 gdb/python/py-infthread.c                     |    6 +-
 gdb/record-btrace.c                           |   20 +-
 gdb/record-full.c                             |    6 +-
 gdb/regcache.c                                |    2 +-
 gdb/remote.c                                  |   76 +-
 gdb/sol-thread.c                              |    4 +-
 gdb/target.c                                  |   15 +-
 .../gdb.threads/continue-some-running.c       |   76 +
 .../gdb.threads/continue-some-running.exp     |   52 +
 .../gdb.threads/leader-exit-schedlock.c       |   56 +
 .../gdb.threads/leader-exit-schedlock.exp     |  215 ++
 .../gdb.threads/step-over-process-exit.c      |   49 +
 .../gdb.threads/step-over-process-exit.exp    |   66 +
 .../sw-watchpoint-step-over-bp-with-threads.c |   64 +
 ...w-watchpoint-step-over-bp-with-threads.exp |   91 +
 gdb/testsuite/lib/gdb.exp                     |    8 +-
 gdb/thread-iter.h                             |    2 +-
 gdb/thread.c                                  |  299 ++-
 gdb/top.c                                     |    2 +-
 gdb/windows-nat.c                             | 2033 +++++++++++++----
 gdbserver/win32-low.cc                        |  450 ++--
 gdbserver/win32-low.h                         |   19 +-
 48 files changed, 3369 insertions(+), 1410 deletions(-)
 create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.c
 create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.exp
 create mode 100644 gdb/testsuite/gdb.threads/leader-exit-schedlock.c
 create mode 100644 gdb/testsuite/gdb.threads/leader-exit-schedlock.exp
 create mode 100644 gdb/testsuite/gdb.threads/step-over-process-exit.c
 create mode 100644 gdb/testsuite/gdb.threads/step-over-process-exit.exp
 create mode 100644 gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.c
 create mode 100644 gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp


base-commit: e1ec485cfa29f9c45370b9d0c12480ebb0a0be06
prerequisite-patch-id: 474281ed1de7dcad710a9f1415fe4866fe3e36cb
-- 
2.49.0


^ permalink raw reply	[flat|nested] 101+ messages in thread
[parent not found: <1549974991.1116105.1750000125453.ref@mail.yahoo.com>]

end of thread, other threads:[~2026-04-06 19:45 UTC | newest]

Thread overview: 101+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-19 13:22 [PATCH v2 00/47] Windows non-stop mode Pedro Alves
2025-05-19 13:22 ` [PATCH v2 01/47] Make default_gdb_exit resilient to failed closes Pedro Alves
2025-05-19 13:56   ` Andrew Burgess
2025-06-06 13:56     ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 02/47] Add test for continuing with some threads running Pedro Alves
2025-05-21 19:36   ` Kevin Buettner
2026-04-02 13:07     ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 03/47] infrun: Remove unnecessary currently_stepping call Pedro Alves
2025-05-21 19:44   ` Kevin Buettner
2026-04-02 13:17     ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 04/47] infrun: Split currently_stepping, fix sw watchpoints issue Pedro Alves
2026-04-02 13:33   ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 05/47] thread_info::executing+resumed -> thread_info::internal_state Pedro Alves
2026-04-06 18:01   ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 06/47] Windows gdb: Dead code in windows_nat_target::do_initial_windows_stuff Pedro Alves
2025-05-19 13:22 ` [PATCH v2 07/47] Windows gdb: Eliminate global current_process.dr[8] global Pedro Alves
2025-05-28 19:09   ` Tom Tromey
2026-04-06 19:44   ` Pedro Alves
2025-05-19 13:22 ` [PATCH v2 08/47] Windows gdb+gdbserver: New find_thread, replaces thread_rec(DONT_INVALIDATE_CONTEXT) Pedro Alves
2025-05-19 13:22 ` [PATCH v2 09/47] Windows gdb: handle_output_debug_string return type Pedro Alves
2025-05-19 13:22 ` [PATCH v2 10/47] Windows gdb: Eliminate reload_context Pedro Alves
2025-05-19 13:22 ` [PATCH v2 11/47] Windows gdb+gdbserver: Eliminate thread_rec(INVALIDATE_CONTEXT) calls Pedro Alves
2025-05-19 13:22 ` [PATCH v2 12/47] Windows gdb+gdbserver: Eliminate DONT_SUSPEND Pedro Alves
2025-05-19 13:22 ` [PATCH v2 13/47] Windows gdb+gdbserver: Eliminate windows_process_info::thread_rec Pedro Alves
2025-05-19 13:22 ` [PATCH v2 14/47] Windows gdb: Simplify windows_nat_target::wait Pedro Alves
2025-05-28 19:16   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 15/47] Windows gdb+gdbserver: Move suspending thread to when returning event Pedro Alves
2025-05-28 19:17   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 16/47] Windows gdb: Introduce continue_last_debug_event_main_thread Pedro Alves
2025-05-28 19:18   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 17/47] Windows gdb: Introduce windows_continue_flags Pedro Alves
2025-05-19 13:22 ` [PATCH v2 18/47] Windows gdb: Factor code out of windows_nat_target::windows_continue Pedro Alves
2025-05-19 13:22 ` [PATCH v2 19/47] Windows gdb: Pending stop and current_event Pedro Alves
2025-05-19 13:22 ` [PATCH v2 20/47] Windows gdb+gdbserver: Elim desired_stop_thread_id / rework pending_stops Pedro Alves
2025-05-30 20:41   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 21/47] Windows gdb+gdbserver: Introduce get_last_debug_event_ptid Pedro Alves
2025-05-28 19:21   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 22/47] Windows gdb: Can't pass signal to thread other than last stopped thread Pedro Alves
2025-05-28 19:22   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 23/47] Windows gdbserver: Fix scheduler-locking Pedro Alves
2025-05-30 20:37   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 24/47] Windows gdb: Enable "set scheduler-locking on" Pedro Alves
2025-05-19 13:22 ` [PATCH v2 25/47] Windows gdbserver: Eliminate soft-interrupt mechanism Pedro Alves
2025-05-19 13:22 ` [PATCH v2 26/47] Windows gdb+gdbserver: Make current_event per-thread state Pedro Alves
2025-05-28 19:30   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 27/47] Windows gdb+gdbserver: Make last_sig " Pedro Alves
2025-05-28 19:31   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 28/47] Windows gdb+gdbserver: Make siginfo_er " Pedro Alves
2025-05-28 19:33   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 29/47] Add backpointer from windows_thread_info to windows_process_info Pedro Alves
2025-05-19 13:22 ` [PATCH v2 30/47] Windows gdb+gdbserver: Share $_siginfo reading code Pedro Alves
2025-05-19 13:22 ` [PATCH v2 31/47] Windows gdb+gdbserver: Eliminate struct pending_stop Pedro Alves
2025-05-28 19:36   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 32/47] Windows gdb: Change serial_event management Pedro Alves
2025-05-28 19:37   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 33/47] Windows gdb: cygwin_set_dr => windows_set_dr, etc Pedro Alves
2025-05-19 13:22 ` [PATCH v2 34/47] Windows gdb: Avoid writing debug registers if watchpoint hit pending Pedro Alves
2025-05-30 20:43   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 35/47] Windows gdb+gdbserver: Check whether DBG_REPLY_LATER is available Pedro Alves
2025-05-19 13:22 ` [PATCH v2 36/47] linux-nat: Factor out get_detach_signal code to common code Pedro Alves
2025-05-28 19:44   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 37/47] Windows GDB: make windows_thread_info be private thread_info data Pedro Alves
2025-05-28 19:52   ` Tom Tromey
2025-05-19 13:22 ` [PATCH v2 38/47] Introduce windows_nat::event_code_to_string Pedro Alves
2025-05-28 19:53   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 39/47] Windows gdb: Add non-stop support Pedro Alves
2025-06-05 16:21   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 40/47] Windows gdb: Eliminate invalidate_context Pedro Alves
2025-05-28 19:54   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 41/47] Windows gdb: Watchpoints while running (internal vs external stops) Pedro Alves
2025-05-30 20:50   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 42/47] gdb_test_multiple: Anchor prompt match if -lbl Pedro Alves
2025-05-21 15:19   ` Tom de Vries
2025-05-27 22:41     ` Pedro Alves
2025-05-27 23:20       ` Pedro Alves
2025-05-28 11:59         ` [PATCH v2] of " Pedro Alves
2025-06-05 16:37           ` Pedro Alves
2025-06-05 17:20             ` [PATCH v3] " Pedro Alves
2025-06-06  9:58               ` Tom de Vries
2025-06-06 13:53                 ` Pedro Alves
2025-05-19 13:23 ` [PATCH v2 43/47] Windows gdb: extra thread info => show exiting Pedro Alves
2025-05-28 19:58   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 44/47] Add gdb.threads/leader-exit-schedlock.exp Pedro Alves
2025-05-29 16:09   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 45/47] infrun: with AS+NS, prefer process exit over thread exit Pedro Alves
2025-05-19 13:23 ` [PATCH v2 46/47] Windows gdb: Always non-stop (default to "maint set target-non-stop on") Pedro Alves
2025-05-29 16:02   ` Tom Tromey
2025-05-19 13:23 ` [PATCH v2 47/47] Mention Windows scheduler-locking and non-stop support in NEWS Pedro Alves
2025-05-19 14:07   ` Eli Zaretskii
2025-06-05 17:57 ` [PATCH v2 00/47] Windows non-stop mode Tom Tromey
2025-06-11 22:06   ` [PATCH] Improve attach on Windows (was: Re: [PATCH v2 00/47] Windows non-stop mode) Pedro Alves
2026-04-02 12:21     ` [PATCH] Improve attach on Windows Pedro Alves
2026-04-02 18:52       ` Tom Tromey
2025-06-11 23:51   ` [PATCH v2 00/47] Windows non-stop mode Pedro Alves
2025-06-12 19:23     ` Tom Tromey
2025-06-13 10:34       ` Pedro Alves
2025-06-13 14:23         ` Tom Tromey
     [not found] <1549974991.1116105.1750000125453.ref@mail.yahoo.com>
     [not found] ` <1549974991.1116105.1750000125453@mail.yahoo.com>
2025-06-25 13:31   ` [PATCH] Improve attach on Windows Pedro Alves
2025-06-29 17:38     ` Hannes Domani
2025-06-30 22:40       ` Pedro Alves
2025-07-01 16:36         ` Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox