public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [FYI/pushed v4 00/25] Step over thread clone and thread exit
@ 2023-11-13 15:04 Pedro Alves
  2023-11-13 15:04 ` [FYI/pushed v4 01/25] Add "maint info linux-lwps" command Pedro Alves
                   ` (25 more replies)
  0 siblings, 26 replies; 49+ messages in thread
From: Pedro Alves @ 2023-11-13 15:04 UTC (permalink / raw)
  To: gdb-patches

Here's v4 of the series I previously posted here:

  [PATCH 00/31] Step over thread clone and thread exit
  https://inbox.sourceware.org/gdb-patches/20221212203101.1034916-1-pedro@palves.net/

(That was v3, I had forgotten to update the subject line back then.)

As I mentioned earlier today, I've addressed all the review comments
in the remaining patches in the v3 series, and since none required any
invasive/design change, I've gone ahead with merging this.  If there's
anything that doesn't look right, please don't hesitate to raise it
and I'll try to address it.

New in v4:

  - Patches 1-2, 29-30 from v3 were already merged a while ago.

  - Addressed Andrew's comments throughout.

  - The stepi-over-clone.exp testcase is now merged into the patch
    where the test first works on native GNU/Linux.

  - Patch "[PATCH 25/31] Ignore failure to read PC when resuming" from
    v3 was dropped, for now.

Here's the series description, updated for v4:

This is a new series that replaces two different series from a couple
years ago.

The first is this series Simon and I wrote, here:

  [PATCH 00/10] Step over thread exit (PR gdb/27338)
  https://sourceware.org/pipermail/gdb-patches/2021-July/180567.html

The other is a series that coincidentally, back then, Andrew posted at
about the same time, and that addressed problems in kind of the mirror
scenario.  His patch series was about stepping over clone (creating
new threads), instead of stepping over thread exit:

  [PATCH 0/3] Stepping over clone syscall
  https://sourceware.org/pipermail/gdb-patches/2021-June/180517.html

My & Simon's solution back then involved adding a new contract between
GDB and GDBserver -- if a thread is single stepping, and it exits, the
server was supposed to report back the thread's exit to GDB.  One of
the motivations for this approach was to be able to control the
enablement of thread exit events per thread, to avoid creating
thread-exit event traffic unnecessarily, as done by
target_thread_events()/QThreadEvents.

Andrew's solution involves using the QThreadEvents mechanism, which
tells the server to report thread create and thread exit events for
all threads.  This would conflict with the desire to avoid unnecessary
traffic in the step over thread exit series.

The step over clone fixes back then also weren't yet fully complete,
as Andrew's series only addressed inline step overs.  Fixing displaced
stepping over clone syscall would still remain broken.

This new series fixes all of stepping over thread exit and clone, for
both of displaced stepping and inline step overs.  It:

- Merges both Andrew's and my/Simon's series, and then reworks both
  parts in different ways.

- Introduces clone events at the GDB core and remote protocol level.

- Gets rid of the idea of "reporting thread exit if thread is
  single-stepping", replaces it by a new mechanism GDB can use to
  explicitly enable thread clone and/or thread exit events, and other
  events in the future.  The old mechanism also only worked when the
  remote server supported hardware single-stepping.  This new approach
  has an advantage of also working on software single-step targets.

- Uses the new clone events to fix displaced stepping over clone
  syscalls too.

- Addresses an issue that Andrew alluded to in his series, and that
  coincidentally, we/AMD also ran into with AMDGPU debugging --
  currently, with "set scheduler-locking on", if you step over a
  function that spawns a thread, that thread runs free, for a bit at
  least, and then may stop or not, basically in an unspecified manner.

- Cancels next/step/until/etc. commands on thread exit event, like so:

     (gdb) n
     [Thread 0x7ffff7d89700 (LWP 3961883) exited]
     Command aborted, thread exited.
     (gdb)

- Non-trivial documentation changes have already been approved by Eli.

Tested on x86-64 Ubuntu 20.04, native and gdbserver.

Andrew Burgess (1):
  Add "maint info linux-lwps" command

Pedro Alves (23):
  gdb/linux: Delete all other LWPs immediately on ptrace exec event
  Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED
  Support clone events in the remote protocol
  Avoid duplicate QThreadEvents packets
  Thread options & clone events (core + remote)
  Thread options & clone events (native Linux)
  Thread options & clone events (Linux GDBserver)
  gdbserver: Hide and don't detach pending clone children
  Remove gdb/19675 kfails (displaced stepping + clone)
  all-stop/synchronous RSP support thread-exit events
  gdbserver/linux-low.cc: Ignore event_ptid if TARGET_WAITKIND_IGNORE
  Move deleting thread on TARGET_WAITKIND_THREAD_EXITED to core
  Introduce GDB_THREAD_OPTION_EXIT thread option, fix
    step-over-thread-exit
  Implement GDB_THREAD_OPTION_EXIT support for Linux GDBserver
  Implement GDB_THREAD_OPTION_EXIT support for native Linux
  gdb: clear step over information on thread exit (PR gdb/27338)
  stop_all_threads: (re-)enable async before waiting for stops
  gdbserver: Queue no-resumed event after thread exit
  Don't resume new threads if scheduler-locking is in effect
  Report thread exit event for leader if reporting thread exit events
  gdb/testsuite/lib/my-syscalls.S: Refactor new SYSCALL macro
  Document remote clone events, and QThreadOptions packet
  Cancel execution command on thread exit, when stepping, nexting, etc.

Simon Marchi (1):
  Testcases for stepping over thread exit syscall (PR gdb/27338)

 gdb/NEWS                                      |  32 +
 gdb/displaced-stepping.c                      |   7 +
 gdb/doc/gdb.texinfo                           | 136 +++-
 gdb/gdbarch-gen.h                             |   6 +-
 gdb/gdbarch_components.py                     |   4 +
 gdb/gdbthread.h                               |  16 +
 gdb/infrun.c                                  | 588 +++++++++++++++---
 gdb/linux-nat.c                               | 383 +++++++-----
 gdb/linux-nat.h                               |   4 +
 gdb/remote.c                                  | 304 +++++++--
 gdb/target-debug.h                            |   2 +
 gdb/target-delegates.c                        |  52 ++
 gdb/target.c                                  |  16 +
 gdb/target.h                                  |  15 +
 gdb/target/target.c                           |  12 +
 gdb/target/target.h                           |  20 +
 gdb/target/waitstatus.c                       |   1 +
 gdb/target/waitstatus.h                       |  31 +-
 gdb/testsuite/gdb.base/step-over-syscall.exp  |  44 +-
 .../gdb.threads/schedlock-new-thread.c        |  54 ++
 .../gdb.threads/schedlock-new-thread.exp      |  67 ++
 ...-over-thread-exit-while-stop-all-threads.c |  77 +++
 ...ver-thread-exit-while-stop-all-threads.exp |  69 ++
 .../gdb.threads/step-over-thread-exit.c       |  52 ++
 .../gdb.threads/step-over-thread-exit.exp     | 155 +++++
 gdb/testsuite/gdb.threads/stepi-over-clone.c  |  90 +++
 .../gdb.threads/stepi-over-clone.exp          | 389 ++++++++++++
 .../gdb.threads/threads-after-exec.c          |  56 ++
 .../gdb.threads/threads-after-exec.exp        |  57 ++
 gdb/testsuite/lib/my-syscalls.S               |  54 +-
 gdb/testsuite/lib/my-syscalls.h               |   5 +
 gdb/thread.c                                  |  18 +
 gdbserver/gdbthread.h                         |   3 +
 gdbserver/linux-low.cc                        | 417 ++++++++-----
 gdbserver/linux-low.h                         |  78 ++-
 gdbserver/remote-utils.cc                     |  26 +-
 gdbserver/server.cc                           | 158 ++++-
 gdbserver/target.cc                           |  15 +-
 gdbserver/target.h                            |  28 +-
 39 files changed, 2994 insertions(+), 547 deletions(-)
 create mode 100644 gdb/testsuite/gdb.threads/schedlock-new-thread.c
 create mode 100644 gdb/testsuite/gdb.threads/schedlock-new-thread.exp
 create mode 100644 gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.c
 create mode 100644 gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp
 create mode 100644 gdb/testsuite/gdb.threads/step-over-thread-exit.c
 create mode 100644 gdb/testsuite/gdb.threads/step-over-thread-exit.exp
 create mode 100644 gdb/testsuite/gdb.threads/stepi-over-clone.c
 create mode 100644 gdb/testsuite/gdb.threads/stepi-over-clone.exp
 create mode 100644 gdb/testsuite/gdb.threads/threads-after-exec.c
 create mode 100644 gdb/testsuite/gdb.threads/threads-after-exec.exp


base-commit: 6b682bbf86f37982ce1d270fb47f363413490bda
-- 
2.34.1


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2024-02-08 14:58 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 15:04 [FYI/pushed v4 00/25] Step over thread clone and thread exit Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 01/25] Add "maint info linux-lwps" command Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 02/25] gdb/linux: Delete all other LWPs immediately on ptrace exec event Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 03/25] Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED Pedro Alves
2023-11-14 12:55   ` Guinevere Larsen
2023-11-14 13:26     ` Pedro Alves
2023-11-14 16:29       ` Guinevere Larsen
2023-11-14 16:44         ` Luis Machado
2023-11-14 13:28     ` Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 04/25] Support clone events in the remote protocol Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 05/25] Avoid duplicate QThreadEvents packets Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 06/25] Thread options & clone events (core + remote) Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 07/25] Thread options & clone events (native Linux) Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 08/25] Thread options & clone events (Linux GDBserver) Pedro Alves
2024-02-06 11:04   ` Luis Machado
2024-02-06 14:57     ` Tom Tromey
2024-02-06 15:12       ` Luis Machado
2024-02-07  8:59       ` Luis Machado
2024-02-07 15:43         ` Tom Tromey
2024-02-07 17:10           ` Simon Marchi
2024-02-07 18:05             ` Luis Machado
2024-02-07 18:18               ` Tom Tromey
2024-02-07 18:56                 ` Pedro Alves
2024-02-07 20:11                   ` Pedro Alves
2024-02-08  8:57                     ` Luis Machado
2024-02-08 10:53                       ` Pedro Alves
2024-02-08 11:47                         ` Luis Machado
2024-02-08 14:58                     ` Tom Tromey
2024-02-07 18:06             ` Tom Tromey
2023-11-13 15:04 ` [FYI/pushed v4 09/25] gdbserver: Hide and don't detach pending clone children Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 10/25] Remove gdb/19675 kfails (displaced stepping + clone) Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 11/25] all-stop/synchronous RSP support thread-exit events Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 12/25] gdbserver/linux-low.cc: Ignore event_ptid if TARGET_WAITKIND_IGNORE Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 13/25] Move deleting thread on TARGET_WAITKIND_THREAD_EXITED to core Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 14/25] Introduce GDB_THREAD_OPTION_EXIT thread option, fix step-over-thread-exit Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 15/25] Implement GDB_THREAD_OPTION_EXIT support for Linux GDBserver Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 16/25] Implement GDB_THREAD_OPTION_EXIT support for native Linux Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 17/25] gdb: clear step over information on thread exit (PR gdb/27338) Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 18/25] stop_all_threads: (re-)enable async before waiting for stops Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 19/25] gdbserver: Queue no-resumed event after thread exit Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 20/25] Don't resume new threads if scheduler-locking is in effect Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 21/25] Report thread exit event for leader if reporting thread exit events Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 22/25] gdb/testsuite/lib/my-syscalls.S: Refactor new SYSCALL macro Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 23/25] Testcases for stepping over thread exit syscall (PR gdb/27338) Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 24/25] Document remote clone events, and QThreadOptions packet Pedro Alves
2023-11-13 15:04 ` [FYI/pushed v4 25/25] Cancel execution command on thread exit, when stepping, nexting, etc Pedro Alves
2023-11-13 19:28 ` [FYI/pushed v4 00/25] Step over thread clone and thread exit Tom de Vries
2023-11-14 10:51   ` Pedro Alves
2023-11-14 13:39     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).