qemu/gdbstub
Ilya Leoshkevich d547e711a8 gdbstub: Implement follow-fork-mode child
Currently it's not possible to use gdbstub for debugging linux-user
code that runs in a forked child, which is normally done using the `set
follow-fork-mode child` GDB command. Purely on the protocol level, the
missing piece is the fork-events feature.

However, a deeper problem is supporting $Hg switching between different
processes - right now it can do only threads. Implementing this for the
general case would be quite complicated, but, fortunately, for the
follow-fork-mode case there are a few factors that greatly simplify
things: fork() happens in the exclusive section, there are only two
processes involved, and before one of them is resumed, the second one
is detached.

This makes it possible to implement a simplified scheme: the parent and
the child share the gdbserver socket, it's used only by one of them at
any given time, which is coordinated through a separate socketpair. The
processes can read from the gdbserver socket only one byte at a time,
which is not great for performance, but, fortunately, the
follow-fork-mode handling involves only a few messages.

Advertise the fork-events support, and remember whether GDB has it
as well. Implement the state machine that is initialized on fork(),
decides the current owner of the gdbserver socket, and is terminated
when one of the two processes is detached. The logic for the parent and
the child is the same, only the initial state is different.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20240219141628.246823-12-iii@linux.ibm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240305121005.3528075-13-alex.bennee@linaro.org>
2024-03-06 12:35:19 +00:00
..
gdbstub.c gdbstub: Introduce gdb_handle_detach_user() 2024-03-06 12:35:19 +00:00
internals.h gdbstub: Introduce gdb_handle_detach_user() 2024-03-06 12:35:19 +00:00
meson.build meson: remove config_targetos 2023-12-31 09:11:28 +01:00
syscalls.c gdbstub: Build syscall.c once 2023-03-07 20:44:09 +00:00
system.c gdbstub: use a better signal when we halt for IO reasons 2023-12-01 14:00:52 +00:00
trace-events gdbstub: Rename 'softmmu' -> 'system' 2023-10-07 19:02:59 +02:00
trace.h gdbstub: move into its own sub directory 2022-10-06 11:53:41 +01:00
user-target.c {linux,bsd}-user: Introduce get_task_state() 2024-03-06 12:35:19 +00:00
user.c gdbstub: Implement follow-fork-mode child 2024-03-06 12:35:19 +00:00