This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC 3/3] GDB/MI: Add new "--language LANG" command option.
- From: Pedro Alves <palves at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 13 Nov 2013 19:35:22 +0000
- Subject: Re: [RFC 3/3] GDB/MI: Add new "--language LANG" command option.
- Authentication-results: sourceware.org; auth=none
- References: <1384151855-12926-1-git-send-email-brobecker at adacore dot com> <1384151855-12926-3-git-send-email-brobecker at adacore dot com>
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