Re: gdb/mi, new-ui. the console and determining when GDB is ready for the next command

Pedro Alves <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 11/2/19 10:35 AM, Robert Rossi wrote:
> Huh. Here is my setup.
> 
> $ gdb --version
> GNU gdb (GDB) 8.3.1
> 
> On terminal one with gdb I have,
>   $ gdb  -q -ex "new-ui mi /dev/pts/11" ./test_main
>   Reading symbols from ./test_main...
>   New UI allocated
>   (gdb)
> Terminal 2 shows
>   $ tty
>   /dev/pts/13
>   $ sleep 1000
>   =thread-group-added,id="i1"
>   (gdb) <--- Good
> 
> So far everything is good. Now in terminal one I make a breakpoint.
> 
> Terminal 1 shows
>   (gdb) b main
>   Breakpoint 1 at 0x4006c0: file test.cpp, line 42.
>   (gdb)
> Terminal 2 shows
>   (gdb)
> 
> =breakpoint-created,bkpt={number="1",type="breakpoint",...,original-location="main"}
> <--- No GDB prompt
> 
> However it has no gdb prompt.

A gdb prompt indicates that GDB is ready to accept commands
again.

Here you have an asynchronous notification, which can appear
at any time.  GDB never stopped accepting commands since that
initial prompt.  So no new prompt.

> Now, if I run the program,
> 
> Terminal 1 shows,
>   (gdb) r
>   Starting program:.../test_main
> 
>   Breakpoint 1, main (argc=1, argv=0x7fffffffdea8) at test.cpp:42
>   42      {
>   (gdb)
> Terminal 2 shows
>   =thread-group-started,id="i1",pid="25913"
>   =thread-created,id="1",group-id="i1"
>   =library-loaded,id=...
>   =library-loaded,id="/lib/x86_6....
>   ~"\n"
>   ~"Breakpoint 1, main (argc=1, argv=0x7fffffffdea8) at test.cpp:42\n"
>   ~"42\t{\n"
>   *stopped,reason="breakpoint-hit",...stopped-threads="all",core="0"
>   <-- No GDB prompt
> 
> In this case also there is no gdb prompt.

Same thing here.  These are all asynchronous notifications.  GDB
is accepting MI commands before and after all these notifications,
even if the CLI channel isn't.  E.g., if you run a program that
doesn't hit a breakpoint, you'll get on the CLI:

(gdb) r
Starting program: /tmp/infinite-loop
iter 1
iter 2
iter 3
iter 4
...

while on the MI channel you get:

...
*running,thread-id="all"

and you can still issue commands there, while the program
is running:

 -data-evaluate-expression 1
 ^done,value="1"
 (gdb) 


> 
> Is this expected behavior or an oversight?
> 
It's expected.

Thanks,
Pedro Alves
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.