Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "taylor, david" <david.taylor@emc.com>,
	       "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: multiple live inferiors
Date: Thu, 11 Aug 2016 17:35:00 -0000	[thread overview]
Message-ID: <593c080e-6de1-981a-5bf2-2f2abc9334f9@redhat.com> (raw)
In-Reply-To: <63F1AEE13FAE864586D589C671A6E18B06CAB4@MX203CL03.corp.emc.com>

On 08/11/2016 06:13 PM, taylor, david wrote:
>> From: Pedro Alves [mailto:palves@redhat.com]

>> 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".
> 
> The targets involved all have different elf files.  They are running on different boards
> within our box.  Neither is the ancestor / descendant of the other.

I said the simplest, not the only way.  Different processes
running different executables is fully supported.  The loaded
"executable" is per-inferior:

 add-inferior 2
 file prog2
 set remote exec-file /path/prog2
 run

A program that forks usually execs shortly after, afterall.

> 
>> 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.
> 
> Neither attach nor run is suitable.
> 
> The elf files are the kernels.  The model is one a single process consisting
> of a bunch of threads in a common address space.
> 
> The arguments to the program, which runs on the desktop, not the target,
> include a user name and password (used for authentication) and an IP address.
> The program establishes a TCP/IP connection to the GDB stub port on the board.
> It passes the user name and password to the box.  Once the connection is authenticated,
> the program just copies, without examination, remote protocol packets back and
> forth until the connection is broken (e.g., GDB disconnects).

The remote protocol's multi-process extensions make the remote protocol packets
carry process ids attached to thread ids, so that a single remote server can
debug more than one process.

So what people can do currently is make the server that runs on
the desktop multiplex the connections, not gdb.  Then each remote 
board is a different process.

You'd have to use a different way to specify the user/password/ip.
E.g., as program arguments, passed to "run", or using "monitor ..." commands.

So you'd first connect to the server with "target extended-remote | server"
and not be debugging anything yet.  

At this point, if the server can discover the list of remote boards itself,
you could also expose them as already-running processes that the user would
list with "info os process", and then attach to with "attach 1", etc.

Just some ideas that you'd have to bake a bit more.

> 
> There is no support for switching to a different board whether within the desktop
> program or within the GDB stub running on a board within the box.
> 
> I want to have multiple inferiors each with their own dedicated (extended-)remote target.

Can't have that today, as you've seen in that wiki page I pointed at.  I'd love to
see it happen, though.

> 
> While my current use case is for multiple boards within the same box, I can envision a future
> where the inferiors might be in different boxes in different buildings...
> 

Right.

Thanks,
Pedro Alves


      reply	other threads:[~2016-08-11 17:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 14:57 taylor, david
2016-08-11 15:22 ` Pedro Alves
2016-08-11 17:13   ` taylor, david
2016-08-11 17:35     ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=593c080e-6de1-981a-5bf2-2f2abc9334f9@redhat.com \
    --to=palves@redhat.com \
    --cc=david.taylor@emc.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox