118
Chapter 14. Using gdb with Different Languages
14.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
, etc, and when gdb enters code compiled from one of these files, it sets the working
language to C or C
++
. Refer to Section 14.1.3
Having gdb infer the source language
, for further
details.
14.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 variables type 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
.
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.
14.4.1.6. gdb 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. Refer to Section 10.1
Expressions
.
14.4.1.7. gdb 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. Refer to Section 7.1.8
Breakpoint menus
.
rbreak
regex
Setting breakpoints using regular expressions is helpful for setting breakpoints on overloaded
functions that are not members of any special classes. Refer to Section 7.1.1
Setting breakpoints
.
catch throw
catch catch
Debug C
++
exception handling using these commands. Refer to Section 7.1.3
Setting catch-
points
.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......