Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: Andrew Cagney <ac131313@ges.redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFC: ``detach remote''
Date: Sun, 11 Aug 2002 09:35:00 -0000	[thread overview]
Message-ID: <20020811163515.GA14609@nevyn.them.org> (raw)
In-Reply-To: <3D567F7B.7080502@ges.redhat.com>

On Sun, Aug 11, 2002 at 11:15:07AM -0400, Andrew Cagney wrote:
> >On Fri, Aug 09, 2002 at 01:48:25PM -0400, Andrew Cagney wrote:
> >
> >>>Hold on a second.  Gdbserver is in wide use; that may not have been
> >>>true a couple of years ago, but the reason I've invested so much time
> >>>in maintaining it is a continually growing customer demand for it.
> >>>People use this, and they are already used to its behavior.
> >
> >>
> >>[Be careful to separate the interests of the fee paying customer from 
> >>the interests of GDB and the wider GDB community.  Fee paying customers 
> >>have an unfortunate habit of being very short sighted :-( :-)]
> >
> >
> >I get more non-customer feedback on gdbserver than customer feedback,
> >actually.  Poor choice of words.
> 
> I'm told HP once did a study to determine the debug requirements of a 
> typical user.  Turns out a typical debug session looks something like:
> 
> 	$ ./a.out
> 	segmentation fault, core dumped
> 	$ gdb ./a.out
> 	(gdb) run
> 	Program received sig seg
> 	10		a = *b;
> 	(gdb) print b
> 	$1 b = 0
> 	(gdb) quit
> 
> ``Advanced users'' get to use up/down and backtrace.
> 
> Depressing, eh?

Yeah.  It's certainly not universal, though...

> >>I'm a user, and I'd prefer to be able to type:
> >>
> >>	(gdb) target remote |ssh machine gdbagent
> >>	(gdb) file foo
> >>	(gdb) run
> >>	Program exited
> >>	<doh!>
> >>	(gdb) break main
> >>	(gdb) run
> >>	...
> >>	(gdb) detach
> >>	(gdb) monitor ps
> >>	(gdb) attach
> >>	.....
> >>
> >>instead of:
> >
> >
> >Some day :)  Those are nice ideas.
> 
> It's closer then you might thing.  All you need is:
> - attach packet
> - detach packet with a correct definition
> - auto-negotiate of extended-remote

And pipe support for target remote, and an agent which can communicate
over said pipe.  Neither terribly hard...

> >>I think the command sequence would be:
> >>
> >>	target remote
> >>	attach <remote-pid>
> >>	target child -- implicit remote/pid detach
> >>	attach <local-pid>
> >>
> >>(Red Herring -- ``target sim'' is equally confused.)
> >
> >
> >The difficulty is what to call "disconnect from the agent".  I don't
> >really like the ambiguity of the target stack here... I suppose adding
> >a "target none" will suffice, but right now the behavior when unpushing
> >a running target is to ask the user if they want to kill it.  That's
> >not going to work if we use this as the method to detach and leave the
> >agent running :)  Having "target none" detach and "target child" ask
> >you if you want to kill doesn't really work either.
> >
> >What do you think of letting the target control what happens when
> >another target is selected?  Remote targets could choose to detach. 
> >That's a little better.
> 
> More background:
> 
> Looking at the code and recalling comments (some verbal), the original 
> intent was that there could be several active targets.  This allows the 
> user to switch between targets:
> 
> 	target child
> 		a live process
> 	target core
> 		now look at the core file
> 	target child
> 		back to that live process
> 
> I don't know if it works.  I've never used it.
> 
> Turns out that this ideal was corrupted along the way because the 
> implementation only allowed one target of each type.  As a consequence, 
> ``target remote'' and ``target sim'' both zap ``target child''.

It doesn't work, anyway:
(gdb) target core core
A program is being debugged already.  Kill it? (y or n) 

I think that if you really want this to work, you need to have target
instances; so that saying "target core" creates a new instance of a
core target and you can control instances individually.  This is a long
way away and it isn't a goal I'm terribly interested in implementing.

> >Or, hey, here's a better idea.  A "disconnect" command.  Then "target"
> >can retain its current semantics (kill) and the user will have an
> >explicit way to disconnect if they want.
> 
> Hmmm!
> 
> Noteing the above -- there can be multiple active targets -- therefor 
> there does need to be a way of shutting down a specific target. 
> Presumably ``target none'' would shutdown all of them.

No, noting above, there might someday be multiple active targets. 
We're not there yet.

> Need to look at a table to see what operations are possible and then 
> figure out which map onto commands.

Tables and lists, I can do that!  Let's see what we've got.  I'll pick
a sampling of targets and operations.

Start with native debugging.  The basic things one wants are:
 - "run": create a new process.
 - "attach": Attach to a running process.
 - "detach": Detach from the current process.  Let it run.
 - "kill": End the current process.

I think we agree that the current meanings of these commands are right,
yes?

Then consider remote debugging of a simple ROM monitor.  All four of
the above commands are meaningless.  Currently, the only one of them
with meaning is "detach", which sends a D packet and disconnects.  The
ROM monitor can choose to remain stopped (most do, from what I've seen)
or resume when it sees the D packet.  It would be nice to have the
choice; I think that detach vs. disconnect is a reasonable way to
represent this.  Protocol side to be determined.  Perhaps disconnect
would send no packet at all, just close the connection?  I think that
would work.  But I digress.  Also, some ROM monitors might support
"restart", which currently gets lumped in with "run", but I believe
should be a special monitor command instead.  That might vary.

Then consider a simulator, linked in.
 - "run" means to restart the simulator
 - "kill" means to end the simulation
 - attach and detach have no apparent meaning
 - disconnect appears to have no useful meaning

Then consider a simulator, speaking a remote protocol, whichever remote
protocol it may be (I hypothesize that it should be extended-remote and
should reject some commands as inappropriate):
 - run/kill/attach/detach as above
 - disconnect now has meaning as with the ROM monitor

Now let's consider our friend the hypothetical all-singing all-dancing
remote process agent.  I think we've concluded that we want
"run"/"kill"/"attach"/"detach" to behave as with native debugging.  We
also need a couple of other commands:
 - Disconnect from the agent, leaving it in its current state, waiting
   for a new client
 - Terminate the agent

Terminating the agent can be a monitor command.  I like the idea of a
"disconnect" command.


One other thorny issue becomes what to do when the user quits or closes
the remote target etc.  Right now GDB offers the "kill" prompt as I
showed above.  For extended-remote that doesn't make a lot of sense to
me... I think that either "disconnect" or a "kill"/"terminate" sequence
makes more sense.  Thoughts?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2002-08-11 16:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-06 14:00 Daniel Jacobowitz
2002-08-06 22:17 ` Eli Zaretskii
2002-08-07 12:31 ` Andrew Cagney
2002-08-07 12:49   ` Daniel Jacobowitz
2002-08-07 15:31     ` Andrew Cagney
2002-08-08  6:24       ` Daniel Jacobowitz
2002-08-09 10:48         ` Andrew Cagney
2002-08-10 20:01           ` Daniel Jacobowitz
2002-08-11  8:15             ` Andrew Cagney
2002-08-11  9:35               ` Daniel Jacobowitz [this message]
2002-08-11  9:42                 ` Andrew Cagney
2002-08-11  9:52                   ` Daniel Jacobowitz
2002-08-11 11:02                 ` Andrew Cagney
2002-08-11 11:34                   ` Daniel Jacobowitz
2002-08-11 13:52                     ` Daniel Jacobowitz
2002-08-12  7:36                       ` Andrew Cagney
2002-08-12  7:47                         ` Daniel Jacobowitz
2002-08-29 15:07                           ` Daniel Jacobowitz
2002-09-03 14:32                             ` Andrew Cagney
2002-09-03 14:41                               ` Daniel Jacobowitz
2002-09-03 22:04                                 ` Eli Zaretskii
2002-09-03 22:04                               ` Eli Zaretskii
2002-09-03 22:14                               ` Eli Zaretskii
2002-08-12 10:29                         ` Eli Zaretskii

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=20020811163515.GA14609@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=ac131313@ges.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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