public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/25] Step over thread clone and thread exit
@ 2022-06-20 22:53 Pedro Alves
  2022-06-20 22:53 ` [PATCH 01/25] Don't use pthread_mutex_t in gdb.base/step-over-clone.c Pedro Alves
                   ` (24 more replies)
  0 siblings, 25 replies; 47+ messages in thread
From: Pedro Alves @ 2022-06-20 22:53 UTC (permalink / raw)
  To: gdb-patches

Hi!

This is a new series that replaces two different series from last
year.

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 envolves 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 aluded 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.

- Addresses Simon's review comments on the original "Step over thread
  exit" series referenced above.

There are documentation changes in the following patches:

   [PATCH 19/25] Don't resume new threads if scheduler-locking is in effect
   [PATCH 25/25] Document remote clone events, and QThreadOptions packet

I'm aware that Tankut also has patches addressing issues around
reading registers of already-exited processes, but I haven't looked at
them in any detail yet.  So I guess patch #22 ("Ignore failure to read
PC when resuming") may end up changing or be replaced by Tankut's.

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

Andrew Burgess (1):
  Add test for stepping over clone syscall

Pedro Alves (22):
  Don't use pthread_mutex_t in gdb.base/step-over-clone.c
  displaced step: pass down target_waitstatus instead of gdb_signal
  linux-nat: introduce pending_status_str
  Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED
  Support clone events in the remote protocol
  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
  Introduce GDB_TO_EXIT thread option, fix step-over-thread-exit
  Implement GDB_TO_EXIT support for Linux GDBserver
  Implement GDB_TO_EXIT support for native Linux
  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
  Tighten gdb.threads/no-unwaited-for-left.exp regexps
  Report thread exit event for leader if reporting thread exit events
  Ignore failure to read PC when resuming
  gdb/testsuite/lib/my-syscalls.S: Refactor new SYSCALL macro
  Document remote clone events, and QThreadOptions packet

Simon Marchi (2):
  gdb: clear step over information on thread exit (PR gdb/27338)
  Testcases for stepping over thread exit syscall (PR gdb/27338)

 gdb/NEWS                                      |  22 +
 gdb/displaced-stepping.c                      |  18 +-
 gdb/displaced-stepping.h                      |   2 +-
 gdb/doc/gdb.texinfo                           | 133 ++++-
 gdb/gdbarch-components.py                     |   6 +-
 gdb/gdbarch-gen.h                             |  10 +-
 gdb/gdbarch.c                                 |   4 +-
 gdb/gdbthread.h                               |  19 +
 gdb/infrun.c                                  | 510 ++++++++++++++----
 gdb/linux-nat.c                               | 383 ++++++++-----
 gdb/linux-nat.h                               |   5 +
 gdb/linux-tdep.c                              |   5 +-
 gdb/linux-tdep.h                              |   2 +-
 gdb/process-stratum-target.c                  |   4 +-
 gdb/remote.c                                  | 217 +++++++-
 gdb/target-debug.h                            |   2 +
 gdb/target-delegates.c                        |  78 +++
 gdb/target.c                                  |  41 ++
 gdb/target.h                                  |  17 +
 gdb/target/target.h                           |  14 +
 gdb/target/waitstatus.c                       |   1 +
 gdb/target/waitstatus.h                       |  20 +-
 gdb/testsuite/gdb.base/step-over-clone.c      |  69 ++-
 gdb/testsuite/gdb.base/step-over-syscall.exp  |  51 +-
 .../gdb.threads/no-unwaited-for-left.exp      |   4 +-
 .../gdb.threads/schedlock-new-thread.c        |  46 ++
 .../gdb.threads/schedlock-new-thread.exp      |  63 +++
 ...-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     | 122 +++++
 gdb/testsuite/gdb.threads/stepi-over-clone.c  |  90 ++++
 .../gdb.threads/stepi-over-clone.exp          | 392 ++++++++++++++
 gdb/testsuite/lib/my-syscalls.S               |  54 +-
 gdb/testsuite/lib/my-syscalls.h               |   5 +
 gdbserver/gdbthread.h                         |   3 +
 gdbserver/linux-low.cc                        | 403 ++++++++------
 gdbserver/linux-low.h                         |  56 +-
 gdbserver/remote-utils.cc                     |  26 +-
 gdbserver/server.cc                           | 152 +++++-
 gdbserver/target.cc                           |  15 +-
 gdbserver/target.h                            |  30 +-
 42 files changed, 2733 insertions(+), 559 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


base-commit: 0d02e70b197c786f26175b9a73f94e01d14abdab
-- 
2.36.0


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

end of thread, other threads:[~2022-07-13 21:35 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 22:53 [PATCH 00/25] Step over thread clone and thread exit Pedro Alves
2022-06-20 22:53 ` [PATCH 01/25] Don't use pthread_mutex_t in gdb.base/step-over-clone.c Pedro Alves
2022-07-13 21:35   ` Pedro Alves
2022-06-20 22:53 ` [PATCH 02/25] displaced step: pass down target_waitstatus instead of gdb_signal Pedro Alves
2022-06-20 22:53 ` [PATCH 03/25] linux-nat: introduce pending_status_str Pedro Alves
2022-06-20 22:53 ` [PATCH 04/25] Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED Pedro Alves
2022-06-20 22:53 ` [PATCH 05/25] Support clone events in the remote protocol Pedro Alves
2022-06-20 22:54 ` [PATCH 06/25] Thread options & clone events (core + remote) Pedro Alves
2022-06-20 22:54 ` [PATCH 07/25] Thread options & clone events (native Linux) Pedro Alves
2022-06-20 22:54 ` [PATCH 08/25] Thread options & clone events (Linux GDBserver) Pedro Alves
2022-06-20 22:54 ` [PATCH 09/25] gdbserver: Hide and don't detach pending clone children Pedro Alves
2022-06-20 22:54 ` [PATCH 10/25] Remove gdb/19675 kfails (displaced stepping + clone) Pedro Alves
2022-06-20 22:54 ` [PATCH 11/25] Add test for stepping over clone syscall Pedro Alves
2022-06-20 22:54 ` [PATCH 12/25] all-stop/synchronous RSP support thread-exit events Pedro Alves
2022-06-20 22:54 ` [PATCH 13/25] Introduce GDB_TO_EXIT thread option, fix step-over-thread-exit Pedro Alves
2022-06-20 22:54 ` [PATCH 14/25] Implement GDB_TO_EXIT support for Linux GDBserver Pedro Alves
2022-06-20 22:54 ` [PATCH 15/25] Implement GDB_TO_EXIT support for native Linux Pedro Alves
2022-06-20 22:54 ` [PATCH 16/25] gdb: clear step over information on thread exit (PR gdb/27338) Pedro Alves
2022-06-20 22:54 ` [PATCH 17/25] stop_all_threads: (re-)enable async before waiting for stops Pedro Alves
2022-06-20 22:54 ` [PATCH 18/25] gdbserver: Queue no-resumed event after thread exit Pedro Alves
2022-06-20 22:54 ` [PATCH 19/25] Don't resume new threads if scheduler-locking is in effect Pedro Alves
2022-06-21 11:07   ` Eli Zaretskii
2022-07-11 14:20     ` Pedro Alves
2022-07-11 15:44       ` Eli Zaretskii
2022-07-11 16:09         ` Pedro Alves
2022-07-11 16:30           ` Eli Zaretskii
2022-07-11 16:38             ` Pedro Alves
2022-07-11 17:00               ` Eli Zaretskii
2022-07-11 17:48                 ` Pedro Alves
2022-07-11 17:50                   ` Eli Zaretskii
2022-07-11 18:18                     ` Pedro Alves
2022-07-11 18:29                       ` Eli Zaretskii
2022-07-11 19:39                         ` Pedro Alves
2022-07-12 16:08                           ` Eli Zaretskii
2022-07-12 17:14                             ` Pedro Alves
2022-06-20 22:54 ` [PATCH 20/25] Tighten gdb.threads/no-unwaited-for-left.exp regexps Pedro Alves
2022-07-13 21:32   ` Pedro Alves
2022-06-20 22:54 ` [PATCH 21/25] Report thread exit event for leader if reporting thread exit events Pedro Alves
2022-06-20 22:54 ` [PATCH 22/25] Ignore failure to read PC when resuming Pedro Alves
2022-06-20 22:54 ` [PATCH 23/25] gdb/testsuite/lib/my-syscalls.S: Refactor new SYSCALL macro Pedro Alves
2022-06-20 22:54 ` [PATCH 24/25] Testcases for stepping over thread exit syscall (PR gdb/27338) Pedro Alves
2022-06-20 22:54 ` [PATCH 25/25] Document remote clone events, and QThreadOptions packet Pedro Alves
2022-06-21 12:07   ` Eli Zaretskii
2022-07-11 15:19     ` Pedro Alves
2022-07-11 16:09       ` Eli Zaretskii
2022-07-11 16:54         ` Pedro Alves
2022-07-11 17:02           ` Eli Zaretskii

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).