diff options
author | Lancelot SIX <lancelot.six@amd.com> | 2021-12-06 05:23:42 -0500 |
---|---|---|
committer | Lancelot SIX <lancelot.six@amd.com> | 2021-12-29 03:27:38 -0500 |
commit | 003aae076207dbf32f98ba846158fc32669ef85f (patch) | |
tree | 9d10c1c387f413469d7e8428096bb5e2d5ee8fde /gdb/doc | |
parent | 39907652260b9adc16958e0cbeefa9bc98e9106a (diff) | |
download | gdb-003aae076207dbf32f98ba846158fc32669ef85f.zip gdb-003aae076207dbf32f98ba846158fc32669ef85f.tar.gz gdb-003aae076207dbf32f98ba846158fc32669ef85f.tar.bz2 |
gdb: Copy inferior properties in clone-inferior
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
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/gdb.texinfo | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7da6805..77cd184 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -3331,8 +3331,12 @@ use @code{run} to spawn a local program, etc. @item clone-inferior [ -copies @var{n} ] [ @var{infno} ] Adds @var{n} inferiors ready to execute the same program as inferior @var{infno}; @var{n} defaults to 1, and @var{infno} defaults to the -number of the current inferior. This is a convenient command when you -want to run another instance of the inferior you are debugging. +number of the current inferior. This command copies the values of the +@var{args}, @w{@var{inferior-tty}} and @var{cwd} properties from the +current inferior to the new one. It also propagates changes the user +made to environment variables using the @w{@code{set environment}} and +@w{@code{unset environment}} commands. This is a convenient command +when you want to run another instance of the inferior you are debugging. @smallexample (@value{GDBP}) info inferiors |