Debugging with GDB (September 2007)

Chapter 9: Using GDB with Different Languages 81
show language
Display the current working language. This is the language you can use with
commands such as print to build and compute expressions that may involve
variables in your program.
info frame
Display the source language for this frame. This language becomes the working
language if you use an identifier from this frame. See Section 6.6 [Information
about a frame], page 54, to identify the other information listed here.
info source
Display the source language of this source file. Refer to See Chapter 10 [Ex-
amining the Symbol Table], page 93, to identify the other information listed
here.
In unusual c ircumstances , you may have source files with extensions not in the standard
list. You can then set the extension associated with a language explicitly:
set extension-language .ext language
Set source files with extension .ext to be assumed to be in the source language
language. However, this is not valid on Unix systems.
info extensions
List all the filename extensions and the associated languages. Not valid on Unix
systems.
9.3 Type and range checking
Some languages are designed to guard you against making seemingly common errors
through a series of compile and run-time checks. These include checking the type of argu-
ments to functions and operators, and making sure mathematical overflows are caught at
run time. Checks such as these help to ensure the correctness of the program once it has
been compiled by eliminating type mismatches, and providing active checks for range errors
when your program is running.
GDB can check for conditions like the above if you wish. Although GDB does not check
the statements in your program, it can check expressions entered directly into GDB for
evaluation via the print command, for example. As with the working language, GDB
can also decide whether or not to check automatically based on your source language. See
Section 9.4 [Supported languages], page 83, for the default settings of supported languages.
9.3.1 An overview of type checking
Some languages are strongly typed, meaning that the arguments to operators and func-
tions have to be of the correct type, otherwise an error occurs. These checks prevent type
mismatch errors from causing run-time problems. For example,
1 + 2
3
but
error
1 + 2.3