beautypg.com

4 c and c++ defaults, 5 c and c++ type and range checks – HP gnu source-level debugger 5992-4701 User Manual

Page 110

background image

references are often used for large structures. The address of a reference variable
is always shown, unless you have specified 'set print address off'.

5.

GDB supports the C++ name resolution operator ::―your expressions can use it
just as expressions in your program do. Since one scope may be defined in another,
you can use :: repeatedly if necessary, for example in an expression like
'scope1::scope2::name'. GDB also allows resolving name scope by reference
to source files, in both C and C++ debugging (see

“Program variables” (page 84)

).

In addition, when used with the HP aC++ compiler, GDB supports calling virtual
functions correctly, printing out virtual bases of objects, calling functions in a base
subobject, casting objects, and invoking user-defined operators.

NOTE:

GDB cannot display debugging information for classes or functions defined

in a shared library that is not compiled for debugging (with the -g0 option). GDB
displays the function with the message .

For example, after 'd3' is created by the following line:

`RWCollectableDate d3(15,5,2001);'

printing the variable or class returns:

(gdb) p d3
$3 = {}
(gdb) ptype RWCollectableDate
type = class RWCollectableDate {

9.4.1.4 C and C++ defaults

If you allow GDB to set type and range checking automatically, they both default to
off

whenever the working language changes to C or C++. This happens regardless of

whether you or GDB selects the working language.

If you allow GDB to set the language automatically, it recognizes source files whose
names end with '.c', '.C', or '.cc', and so on, and when GDB enters code compiled
from one of these files, it sets the working language to C or C++. Refer to See

“Having

GDB infer the source language” (page 102)

, for further details.

9.4.1.5 C and C++ type and range checks

By default, when GDB parses C or C++ expressions, type checking is not used. However,
if you turn type checking on, GDB considers two variable types equivalent if:

The two variables are structured and have the same structure, union, or enumerated
tag.

The two variables have the same type name, or types that have been declared
equivalent through typedef.

110

Using GDB with Different Languages