Debugging with GDB (September 2007)

iii
9 Using GDB with Different Languages . . . . . . 79
9.1 Switching between source languages . . . . . . . . . . . . . . . . . . . . . 79
9.1.1 List of filename extensions and languages . . . . . . . . 79
9.1.2 Setting the working language . . . . . . . . . . . . . . . . . . . 80
9.1.3 Having GDB infer the source language . . . . . . . . . . 80
9.2 Displaying the language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.3 Type and range checking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.3.1 An overview of type checking . . . . . . . . . . . . . . . . . . . 81
9.3.2 An overview of range checking . . . . . . . . . . . . . . . . . . 82
9.4 Supported languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.4.1.1 C and C++ operators . . . . . . . . . . . . . . . . . . 84
9.4.1.2 C and C++ constants . . . . . . . . . . . . . . . . . . 85
9.4.1.3 C++ expressions . . . . . . . . . . . . . . . . . . . . . . . 86
9.4.1.4 C and C++ defaults . . . . . . . . . . . . . . . . . . . 87
9.4.1.5 C and C++ typ e and range checks . . . . . . 88
9.4.1.6 GDB and C . . . . . . . . . . . . . . . . . . . . . . . . . . 88
9.4.1.7 GDB features for C++ . . . . . . . . . . . . . . . . . 88
9.4.2 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
9.4.2.1 Fortran typ e s . . . . . . . . . . . . . . . . . . . . . . . . . 90
9.4.2.2 Fortran operators . . . . . . . . . . . . . . . . . . . . . 90
9.4.2.3 Fortran special issues . . . . . . . . . . . . . . . . . . 91
10 Examining the Symbol Table . . . . . . . . . . . . . 93
11 Altering Execution . . . . . . . . . . . . . . . . . . . . . . 97
11.1 Assignment to variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
11.2 Continuing at a different address . . . . . . . . . . . . . . . . . . . . . . . 98
11.3 Giving your program a signal . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.4 Returning from a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.5 Calling program functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
11.6 Patching programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
12 GDB Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
12.1 Commands to specify files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
12.2 Specifying shared library locations. . . . . . . . . . . . . . . . . . . . . 106
12.3 Errors reading symbol files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
13 Specifying a Debugging Target . . . . . . . . . . 109
13.1 Active targets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.2 Commands for managing targets . . . . . . . . . . . . . . . . . . . . . . 109
13.3 Choosing target byte order. . . . . . . . . . . . . . . . . . . . . . . . . . . . 111