Range checking, if turned on, is done on mathematical operations. Array indices are not checked, since they are often used to index a pointer that is not itself an array.

9.4.1.6GDB and C

The set print union and show print union commands apply to the union type. When set to 'on', any union that is inside a struct or class is also printed. Otherwise, it appears as '{...}'.

The @ operator aids in the debugging of dynamic arrays, formed with pointers and a memory allocation function. See “Expressions” (page 83).

9.4.1.7GDB features for C++

Some GDB commands are particularly useful with C++, and some are designed specifically for use with C++. Here is a summary:

breakpoint menus

When you want a breakpoint in a function whose

 

name is overloaded, GDB breakpoint menus help

 

you specify which function definition you want.

 

See “Breakpoint menus” (page 62).

rbreak regex

catch throw, catch catch

ptype typename

set print demangle, show print demangle, set print asm-demangle,show print asm-demangle

set print object, show print object

set print vtbl, show print vtbl

set overload-resolution on

Setting breakpoints using regular expressions is helpful for setting breakpoints on overloaded functions that are not members of any special classes. See “Setting breakpoints” (page 52).

Debug C++ exception handling using these commands. See “Setting catchpoints” (page 56).

Print inheritance relationships as well as other information for type. typename. See Chapter 10 (page 115).

Control whether C++ symbols display in their source form, both when displaying code as C++ source and when displaying disassemblies. See “Print settings” (page 90).

Choose whether to print derived (actual) or declared types of objects. See “Print settings” (page 90).

Control the format for printing virtual function tables. See “Print settings” (page 90). (The vtbl commands do not work on programs compiled with the HP ANSI C++ compiler (aCC).)

Enable overload resolution for C++ expression evaluation. The default is on. For overloaded functions, GDB evaluates the arguments and

9.4 Supported languages 111