From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111534 invoked by alias); 26 Apr 2015 18:45:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 111524 invoked by uid 89); 26 Apr 2015 18:45:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 26 Apr 2015 18:45:09 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YmRY9-0007wP-4h for gdb-patches@sourceware.org; Sun, 26 Apr 2015 20:45:05 +0200 Received: from h86-62-88-129.ln.rinet.ru ([86.62.88.129]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Apr 2015 20:45:05 +0200 Received: from vladimir.prus by h86-62-88-129.ln.rinet.ru with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Apr 2015 20:45:05 +0200 To: gdb-patches@sourceware.org From: Vladimir Prus Subject: Re: GDB/MI interactive capability? Date: Sun, 26 Apr 2015 18:45:00 -0000 Message-ID: References: <20150422192522.GM4764@adacore.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <20150422192522.GM4764@adacore.com> X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00977.txt.bz2 Hi Joel, On 04/22/2015 10:25 PM, Joel Brobecker wrote: > 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. I think a bigger problem is that it will make the MI protocol itself stateful. Right now, we have GDB and program state, of course, but each MI command is generally independent of any other one. The above proposal will basically create interdependencies between MI commands. > 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. That would work just fine, I think. GDB can report the ambiguities it finds, and the frontend can resubmit the expression with appropriate syntax to disambiguate. I don't know whether there's appropriate syntax for Ada, in C++ a cast to appropriate type is sometimes used to select the right function, e.g.: static_cast(&C::foo) is the standard example. The downside is that GDB might have to know a bit more about language than now, or a special syntax might have to be introduced. -- Vladimir Prus CodeSourcery / Mentor Embedded http://vladimirprus.com