[PATCH 0/2] Copy inferior properties on inferior-clone

Lancelot SIX lancelot.six@amd.com
Tue Dec 14 11:02:13 GMT 2021


When a user clones an inferior using the 'inferior-clone' command, he
looses any configuration that can influence the behavior of the program
being run.  The following session illustrates this:

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


In this series, I propose to change this by ensuring that the
clone-inferior command copies all relevant information form the original
inferior to the new one.  The properties this series currently copies
are:
  - args
  - cwd
  - tty
  - user set environment variables

This is done in patch 1.  Patch 2 adds an observable to notify attached
observers for each cloned inferior.  This patch allows target dependent
code to react to the clone-inferior event and perform any target-related
action they see fit.  At the moment, this is not used in upstream GDB,
but this extension mechanism will be used in downstream extensions of
gdb usch as the ROCm GDB[1].

All feedback are welcome.

Tested on x86_64-linux.

[1] https://github.com/ROCm-Developer-Tools/ROCgdb 

Lancelot SIX (2):
  gdb: Copy inferior properties in clone-inferior
  gdb: Add new inferior_cloned observable

 gdb/NEWS                                  |  7 ++
 gdb/doc/gdb.texinfo                       |  8 ++-
 gdb/inferior.c                            | 20 ++++++
 gdb/observable.c                          |  1 +
 gdb/observable.h                          |  6 ++
 gdb/testsuite/gdb.base/inferior-clone.exp | 86 +++++++++++++++++++++++
 6 files changed, 126 insertions(+), 2 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/inferior-clone.exp

-- 
2.25.1



More information about the Gdb-patches mailing list