[PATCH v2] gdb: Copy inferior properties in clone-inferior
Eli Zaretskii
eliz@gnu.org
Thu Dec 16 10:20:52 GMT 2021
> Date: Thu, 16 Dec 2021 05:06:43 -0500
> From: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
> Cc: lsix@lancelotsix.com, Lancelot SIX <lancelot.six@amd.com>
>
> Noticable Changes from V1:
> - Fix and typos.
> - Fix unfortunate use of c_str's value after free (in inferior.c).
> - Remove unnecessary copies in for-loops by using const &.
> - Reduce use of auto.
> - Improve test naming (no capital, no "test" in name, better groups).
> - Patch 2 on the original series has been dropped since it has no
> immediate use..
>
> Thanks Baris and Pedro for the reviews.
>
> ---
>
> This commit ensures that the following settings are cloned from one
> inferior to the new one when processing the clone-inferior command:
> - inferior-tty
> - environment variables
> - cwd
> - args
>
> Some of those parameters can be passed as command line arguments to GDB
> (-args and -tty), so one could expect the clone-inferior to respect
> those flags. The following debugging session illustrates that:
>
> gdb -nx -quiet -batch \
> -ex "show args" \
> -ex "show inferior-tty" \
> -ex "clone-inferior" \
> -ex "inferior 2" \
> -ex "show args" \
> -ex "show inferior-tty" \
> -tty=/some/tty \
> -args echo foo bar
> Argument list to give program being debugged when it is started is "foo bar".
> Terminal for future runs of program being debugged is "/some/tty".
> [New inferior 2]
> Added inferior 2.
> [Switching to inferior 2 [<null>] (/bin/echo)]
> Argument list to give program being debugged when it is started is "".
> Terminal for future runs of program being debugged is "".
>
> The other properties this commit copies on clone (i.e. CWD and the
> environment variables) are included since they are related (in the sense
> that they influence the runtime behavior of the program) even if they
> cannot be directly set using command line switches.
>
> There is a chance that this patch changes existing user workflow. I
> think that this change is mostly harmless. If users want to start a new
> inferior based on an existing one, they probably already propagate those
> settings to the new inferior in some way.
>
> Tested on x86_64-linux.
>
> Change-Id: I3b1f28b662f246228b37bb24c2ea1481567b363d
> ---
> gdb/NEWS | 7 ++
> gdb/doc/gdb.texinfo | 8 +-
> gdb/inferior.c | 17 +++++
> gdb/testsuite/gdb.base/inferior-clone.exp | 93 +++++++++++++++++++++++
> 4 files changed, 123 insertions(+), 2 deletions(-)
> create mode 100644 gdb/testsuite/gdb.base/inferior-clone.exp
Thanks, the documentation changes are OK.
More information about the Gdb-patches
mailing list