GDB/MI questions

Marc Khouzam
Thu Jan 19 15:24:00 GMT 2017

> On Thu, Jan 19, 2017 at 02:30:58PM +0000, Marc Khouzam wrote:
> > > Second, from the CLI if you run the command "next", then if you hit
> > > the enter key, GDB will run the "next" command again.
> > > However, in GDB/MI if you run -interpreter-exec console "next", and then
> > > follow that with the Enter key, GDB does nothing.
> > > Is there a way to run the last command?
> ...
> > But if you really want that for some reason, you can just keep track
> > of the last command you sent in MI, and then when getting an lone
> > Enter, you could send it again.  But then you don't have the smarts
> > of GDB to know which commands should repeat and which should not.
> > I don't think this is a very good idea.
> I'm just trying to provide the same functionality I did when I was using
> annotations. This was one of the noted differences.
> Since the MI differs in this area, I've done as you suggested and
> that works well. I guess I'll see if there are any downsides here.

For the record, I'll add my voice to Pedro's suggestion to try out
the 'new-ui' command and have a separate MI channel from your CLI.
That is such a better user experience.
And it shouldn't be very hard to implement in your frontend since
you were previously handling a GDB CLI anyway.

FYI, Eclipse launches GDB in CLI mode (probably like you did before)
and let's the user interact with that CLI, while it sends MI commands on the
dedicated PTY for the MI channel.

Here is the parameters eclipse uses to launch such a GDB:

gdb.7.12 --nx -q -ex "new-ui mi <some pty>" -ex "set pagination off" -ex show version

Note that the "-q" command along with the last two -ex commands are to make 
sure GDB does not paginate before creating the MI channel, in case the terminal is 
too small to even show the version.

One very important note if you use the new-ui feature, is that you need to run
mi-async because the MI channel does not accept ^C, so you need to use
-exec-interrupt instead.  

Also, it will probably need a bit more work if you target Windows.


More information about the Gdb mailing list