Re: continuations and breakpoint commands

Pedro Alves
2008-05-04T21:34:49Z

Sorry, I seem to have missed this,

A Friday 02 May 2008 16:36:55, Daniel Jacobowitz wrote:
> On Wed, Apr 30, 2008 at 03:59:34PM +0100, Pedro Alves wrote:
> > > What happens to the already typed chars in the
> > > case of a prompt switch?
> >
> > No sure I understood that. When the inferior is running in
> > sync execution, any typed character goes to the inferior, while
> > in async execution the terminal stays with GDB and GDB interprets
> > any command you pass to it.
>

> I think he's asking what happens when the program hits a breakpoint
> while you're mid-typing. I assume we print some output and readline
> redraws the prompt line?

There's no prompt switch in async mode. The code comment in question
has to do with sync_execution on top of async mode, where anything
the user typed while the inferior was executing went to the inferior.

In async, if some breakpoint is hit mid-typing we just print some
output, and don't mess with the prompt, so whatever the user was
mid-typing is unaffected. The command line does gets a bit
garbled, because there's no distintion between the command line,
and other output, though.

With a source that looks like (line/code):

8 sleep (10); << stopped here.
9 sleep (10); << breakpoint here.

(gdb) c&
Continuing.
(gdb) help << "enter" not pressed yet.

(wait for breakpoint hit)

(gdb) c&
Continuing.
(gdb) helpBreakpoint 3, thread1_really () at thread.cpp:9
9 in thread.cpp

<< press "enter" now.

List of classes of commands:

aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
...

Clearly, an improvement would be for the output to be:

(gdb) c&
Continuing.
(gdb) help << "enter" not pressed yet.

(wait for breakpoint hit)

(gdb) c&
Continuing.
Breakpoint 3, thread1_really () at thread.cpp:9
9 in thread.cpp
(gdb) help

I suppose it may be possible to add some smartness to printf_*filtered
and friends to do some dance with readline for this.

There's one case where prompting may get in the way
of what the user was typing. That's when due to *_filtered,
pagination kicks in. We use a prompt for the query.

Hey, nobody's been claiming CLI is perfect in async mode yet :-)

--
Pedro Alves