9.2 Displaying the language

The following commands help you find out which language is the working language, and also what language source files were written in.

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 “Information about a frame” (page 74), to identify the other

 

information listed here.

info source

Display the source language of this source file. Refer to See

 

Chapter 10 (page 115), to identify the other information listed here.

In unusual circumstances, 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

Set source files with extension .ext to be

language

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 arguments 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 “Supported languages” (page 105), 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 functions 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

9.2 Displaying the language 103