Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
For expressions you use in GDB commands, you can tell GDB to treat range errors in
one of three ways: ignore them, always treat them as errors and abandon the expression,
or issue warnings but evaluate the expression anyway.
A range error can result from numerical overflow, from exceeding an array index bound,
or when you type a constant that is not a member of any type. Some languages, however,
do not treat overflows as an error. In many implementations of C, mathematical overflow
causes the result to wrap around” to lower values―for example, if m is the largest integer
value, and s is the smallest, then
m + 1 s
This, too, is specific to individual languages, and in some cases specific to individual
compilers or machines. Refer to See “Supported languages (page 98), for further details
on specific languages.
GDB provides the following additional commands for controlling the range checker:
set check range auto Set range checking on or off based on the current
working language. See “Supported languages
(page 98), for the default settings for each language.
set check range on, set
check range off
Set range checking on or off, overriding the default
setting for the current working language. A warning is
issued if the setting does not match the default language.
If a range error occurs and range checking is on, then
a message is printed and evaluation of the expression
is aborted.
set check range warn Output messages when the GDB range checker detects
a range error, but attempt to evaluate the expression
anyway. Evaluating the expression may still be
impossible for other reasons, such as accessing memory
that the process does not own (a typical example from
many Unix systems).
show range Show the current setting of the range checker, and
whether or not it is being set automatically by GDB.
9.4 Supported languages
GDB supports C, C++, and Fortran. Refer to for specific information about Fortran.
Some GDB features may be used in expressions regardless of the language you use: the
GDB @ and :: operators, and the '{type}addr' construct (see “Expressions (page 76))
can be used with the constructs of any supported language.
The following section discusses GDB support for each source language. These sections
are not meant to be language tutorials or references, but serve only as a reference guide
to what the GDB expression parser accepts, and what input and output formats should
look like for different languages.
98 Using GDB with Different Languages