public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: vladimir@codesourcery.com, gdb-patches@sourceware.org
Cc: Pierre-Marie de Rodat <derodat@adacore.com>
Subject: GDB/MI interactive capability?
Date: Wed, 22 Apr 2015 19:25:00 -0000	[thread overview]
Message-ID: <20150422192522.GM4764@adacore.com> (raw)

Vladimir, All,

A question that I was asked by the IDE Team at AdaCore, who is trying
to transition to using GDB/MI instead of CLI + annotations.

Consider a program where we have multiple functions having the same
name (In our case "foo"). In CLI mode, evaluating an expression
referencing one of those functions results in a multiple-choice menu
being printed, asking for the user to select the one he meant us
to call. Eg:

    (gdb) p foo(null)
    Multiple matches for foo
    [0] cancel
    [1] foo.foo at foo.adb:9
    [2] foo.foo at foo.adb:19

Ideally, we'd like to have the same behavior when using the GDB/MI
protocol, and be able to query the user. Do you think we could enhance
the protocol that way?

For instance ("->" means we send to GDB, and "<-" means we receive
from GDB):

-> -data-evaluate-expression foo(null)

<- ^user-input-needed,id=NNN,choices=[
        {number=0, description='cancel'},
        {number=1, description='foo.foo at foo.adb:9'},
        {number=2, description='foo.foo at foo.adb:19}]

The id=NNN would just be a way to identify each user query, and
would be used to identify which query the user's answer is for.
We'd answer the query as follow:

-> -user-input NNNN  ANSWER
<- ^done,[as usual]

This is just thinking out loud. I'm not even sure whether it'll be
all that easy to implement this idea, especially if we want GDB to
remain responsive (Eg, to perform other operations and therefore
send other GDB/MI commands) while waiting for the user's answer.

Another idea, which might be easier to implement, would be to use
a two-step approach where the first step is to return an error
that shows the various choices the user can choose, have the IDE
use that to query the user, and then have the IDE resubmit the
expression evaluation, this time with the choice given by the user.

WDYT?

-- 
Joel

             reply	other threads:[~2015-04-22 19:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 19:25 Joel Brobecker [this message]
2015-04-26 18:45 ` Vladimir Prus
2015-04-27  3:28   ` Matt Rice
2015-04-29 15:44   ` Joel Brobecker
2015-04-29 19:40     ` Vladimir Prus
2015-04-29 20:30       ` Vladimir Prus

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=20150422192522.GM4764@adacore.com \
    --to=brobecker@adacore.com \
    --cc=derodat@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=vladimir@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).