From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7639 invoked by alias); 13 Nov 2013 19:35:34 -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 7627 invoked by uid 89); 13 Nov 2013 19:35:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_05,RDNS_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2013 19:35:32 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rADJZNBJ012022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Nov 2013 14:35:24 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rADJZMak013991; Wed, 13 Nov 2013 14:35:23 -0500 Message-ID: <5283D47A.4060900@redhat.com> Date: Wed, 13 Nov 2013 19:49:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [RFC 3/3] GDB/MI: Add new "--language LANG" command option. References: <1384151855-12926-1-git-send-email-brobecker@adacore.com> <1384151855-12926-3-git-send-email-brobecker@adacore.com> In-Reply-To: <1384151855-12926-3-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-11/txt/msg00353.txt.bz2 On 11/11/2013 06:37 AM, Joel Brobecker wrote: > Hello, > > Frontend sometimes need to evaluate expressions that are > language-specific. For instance, Eclipse uses the following > expression to determine the size of an address on the target: > > -data-evaluate-expression "sizeof (void*)" > > Unfortunately, if the main of the program being debugged is not C, > this may not work. For instance, if the main is in Ada, you get... > > -data-evaluate-expression "sizeof (void*)" > ^error,msg="No definition of \"sizeof\" in current context." > > ... and apparently decides to stop the debugging session as a result. > The recommendation sent was to specifically set the language to C > before trying to evaluate the expression. Something such as: > > 1. save current language > 2. set language c > 3. -data-evaluate-expression "sizeof (void*)" > 4. Restore language > > This has the same disadvantages as the ones outlined in the "Context > Management" section of the GDB/MI documentation regarding setting > the current thread or the current frame, thus recommending the use of > general command-line switches such as --frame, or --thread instead. > > This patch follows the same steps for the language, adding a similar > new command option: --language LANG. Example of use: Makes sense to me. I skimmed the patch and it looked fine. > > -data-evaluate-expression --language c "sizeof (void*)" > ^done,value="4" > > gdb/ChangeLog: > > * mi/mi-parse.h (struct mi_parse) [language]: New field. [] is used for conditionally compiled code (#if FOO). For specifying context, use <>. > * mi/mi-main.c (mi_cmd_execute): Temporarily set language to > PARSE->LANGUAGE during command execution, if set. > * mi/mi-parse.c: Add "language.h" #include. > (mi_parse): Add parsing of "--language" command option. -- Pedro Alves