Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)

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 80), 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 80), 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 63)) 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.
9.4.1 C and C++
Since C and C++ are so closely related, many features of GDB apply to both languages. Whenever
this is the case, we discuss those languages together.
The C++ debugging facilities are jointly implemented by the C++ compiler and GDB. Therefore,
to debug your C++ code effectively, you must compile your C++ programs with a supported C++
compiler, such as GNU g++, or the HP ANSI C++ compiler (aCC).
For best results when using GNU C++, use the stabs debugging format. You can select that format
explicitly with the g++ command-line options '-gstabs' or '-gstabs+'. Refer to section “Options
for Debugging Your Program or GNU CC” in Using GNU CC, for more information.
9.4.1.1 C and C++ operators
Operators must be defined on values of specific types. For instance, + is defined on numbers, but
not on structures. Operators are often defined on groups of types.
80 Using GDB with Different Languages