diff options
author | Joel Brobecker <brobecker@adacore.com> | 2013-11-11 09:21:44 +0400 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2013-11-14 14:36:18 +0400 |
commit | 403cb6b138c38faf72f7abc034db3505b9bdb82f (patch) | |
tree | 9ece00d8fc7c36bff6838939d9f7f18063cbf14b /gdb/doc | |
parent | b5be8ce022f894831b133b3b424238d8058eb29e (diff) | |
download | gdb-403cb6b138c38faf72f7abc034db3505b9bdb82f.zip gdb-403cb6b138c38faf72f7abc034db3505b9bdb82f.tar.gz gdb-403cb6b138c38faf72f7abc034db3505b9bdb82f.tar.bz2 |
GDB/MI: Add new "--language LANG" command option.
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:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* 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.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 968201e..6ffdefa 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2013-11-14 Joel Brobecker <brobecker@adacore.com> + + * gdb.texinfo (Show): Add xref anchor for "show language" command. + (Context management): Place current subsection text into its own + subsubsection. Add new subsubsection describing the "--language" + command option. + 2013-11-13 Joel Brobecker <brobecker@adacore.com> * gdb.texinfo (GDB/MI Miscellaneous Commands): Delete diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 84acd5c..a164785 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -13340,6 +13340,7 @@ working language, and also what language source files were written in. @table @code @item show language +@anchor{show language} @kindex show language Display the current working language. This is the language you can use with commands such as @code{print} to @@ -28816,6 +28817,8 @@ the user interface. @node Context management @subsection Context management +@subsubsection Threads and Frames + In most cases when @value{GDBN} accesses the target, this access is done in context of a specific thread and frame (@pxref{Frames}). Often, even when accessing global data, the target requires that a thread @@ -28866,6 +28869,25 @@ all subsequent commands. No frontend is known to do this exactly right, so it is suggested to just always pass the @samp{--thread} and @samp{--frame} options. +@subsubsection Language + +The execution of several commands depends on which language is selected. +By default, the current language (@pxref{show language}) is used. +But for commands known to be language-sensitive, it is recommended +to use the @samp{--language} option. This option takes one argument, +which is the name of the language to use while executing the command. +For instance: + +@smallexample +-data-evaluate-expression --language c "sizeof (void*)" +^done,value="4" +(gdb) +@end smallexample + +The valid language names are the same names accepted by the +@samp{set language} command (@pxref{Manually}), excluding @samp{auto}, +@samp{local} or @samp{unknown}. + @node Asynchronous and non-stop modes @subsection Asynchronous command execution and non-stop mode |