[0/6] Eliminate infrun_thread_thread_exit observer

Message ID 20221203211338.2264994-1-pedro@palves.net
Headers
Series Eliminate infrun_thread_thread_exit observer |

Message

Pedro Alves Dec. 3, 2022, 9:13 p.m. UTC
  This series started out as me realizing that I had one change in the
pending step-over-thread-exit series that was in conflict with
infrun_thread_thread_exit.  infrun_thread_thread_exit wants to clear
the last target waitstatus when that status is for the thread that
exited, while I'll need to preserve the thread exit waitstatus for
normal stop.  In the step-over-thread-exit series, I was calling
set_last_target_status again when handling a
TARGET_WAITKING_THREAD_EXIT, and that was undoing the clear that
infrun_thread_thread_exit does.

So I looked at eliminating infrun_thread_thread_exit, see if we could
make whatever is relying on it no longer rely on it.

The end result is this thread.  It ends up fixing some bugs and
improving GDB behavior such that I think it stands on its own, even
without the last patch, the one that finally eliminates
infrun_thread_thread_exit.  I kept the thread title about
infrun_thread_thread_exit because that's my end goal, but I could as
well remove the last patch and call this thread "improve 'info
program' and 'follow-fork'".

Tested on x86-64 GNU/Linux, native and extended-gdbserver.

Pedro Alves (6):
  Tweak "Using the running image of ..." output
  Convert previous_inferior_ptid to strong reference to thread_info
  Improve "info program"
  Make follow_fork not rely on get_last_target_status
  all-stop "follow-fork parent" and selecting another thread
  Remove infrun_thread_thread_exit observer

 gdb/inf-ptrace.c                              |   2 +-
 gdb/infcmd.c                                  |  84 +++++--
 gdb/infrun.c                                  | 214 +++++++++++++-----
 gdb/infrun.h                                  |   7 +
 gdb/nto-procfs.c                              |   2 +-
 gdb/procfs.c                                  |   2 +-
 gdb/target.c                                  |   5 +
 gdb/testsuite/gdb.base/catch-follow-exec.exp  |  17 +-
 gdb/testsuite/gdb.base/foll-fork.exp          |  36 ++-
 gdb/testsuite/gdb.base/info-program.c         |  66 ++++++
 gdb/testsuite/gdb.base/info-program.exp       | 131 +++++++++--
 .../gdb.threads/foll-fork-other-thread.c      |  84 +++++++
 .../gdb.threads/foll-fork-other-thread.exp    | 172 ++++++++++++++
 gdb/windows-nat.c                             |   2 +-
 14 files changed, 712 insertions(+), 112 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/info-program.c
 create mode 100644 gdb/testsuite/gdb.threads/foll-fork-other-thread.c
 create mode 100644 gdb/testsuite/gdb.threads/foll-fork-other-thread.exp


base-commit: fb699bafb5f23c2fd43d7f20495171b16903b20f
  

Comments

Pedro Alves Feb. 27, 2023, 7:12 p.m. UTC | #1
Hi!

On 2022-12-03 9:13 p.m., Pedro Alves wrote:
> This series started out as me realizing that I had one change in the
> pending step-over-thread-exit series that was in conflict with
> infrun_thread_thread_exit.  infrun_thread_thread_exit wants to clear
> the last target waitstatus when that status is for the thread that
> exited, while I'll need to preserve the thread exit waitstatus for
> normal stop.  In the step-over-thread-exit series, I was calling
> set_last_target_status again when handling a
> TARGET_WAITKING_THREAD_EXIT, and that was undoing the clear that
> infrun_thread_thread_exit does.
> 
> So I looked at eliminating infrun_thread_thread_exit, see if we could
> make whatever is relying on it no longer rely on it.
> 
> The end result is this thread.  It ends up fixing some bugs and
> improving GDB behavior such that I think it stands on its own, even
> without the last patch, the one that finally eliminates
> infrun_thread_thread_exit.  I kept the thread title about
> infrun_thread_thread_exit because that's my end goal, but I could as
> well remove the last patch and call this thread "improve 'info
> program' and 'follow-fork'".
> 
> Tested on x86-64 GNU/Linux, native and extended-gdbserver.
> 
> Pedro Alves (6):
>   Tweak "Using the running image of ..." output
>   Convert previous_inferior_ptid to strong reference to thread_info
>   Improve "info program"
>   Make follow_fork not rely on get_last_target_status
>   all-stop "follow-fork parent" and selecting another thread
>   Remove infrun_thread_thread_exit observer

FYI, I'm putting this in.