This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: multiple live inferiors


On 08/11/2016 03:56 PM, taylor, david wrote:
> Currently GDB supports having multiple non-live inferiors.  But, if I try to
> add a second live inferior it wants to kill the current live inferior.

By "non-live", I assume you mean file_stratum inferiors
(executable files, etc.).  GDB does not support having multiple
core dump inferiors loaded.

gdb _does_ however support having multiple live inferiors.  It works
as long as they're all behind the same target connection.  E.g.,
multiple inferiors with the native target.  Or
multiple inferiors against gdbserver.  The simplest to get them
is to enable following forks, with "set detach-on-fork off".

You're trying to add a second target connection, which is
a bit orthogonal.

> 
> That is, I can do:
> 
>     gdb some-file.elf
>     set non-stop on
>     set target-async on
>     target extended-remote | program with some arguments

"program" here will be the server.

>     add-inferior -exec new-file.elf
>     info inferiors
>     inferior 2
>     target extended-remote | program with different arguments
> 

So here replace the second "target extended-remote"
with "attach" or "run" to start the new inferior under
control of the first server.

> at which point GDB will say:
> 
>     A program is being debugged already.  Kill it? (y or n)
> 
> I'd be okay with the question if the current inferior was live.  But, it is just an executable.
> 
> I assume that there's more to changing this than just modifying target_preopen.
> What else is likely to break or need modification?

See here:

  https://sourceware.org/gdb/wiki/MultiTarget

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]