HP (Hewlett-Packard) 5992-4701 Computer Hardware User Manual


 
'.cxx',
'.c++'
'.f', '.F',
'.f90'
Fortran source file. GDB does not distinguish between Fortran 77 and Fortran
90 files.
'.s', '.S'
Assembler source file. This actually behaves almost like C, but GDB does
not skip over function prologues when stepping.
In addition, you may set the language associated with a filename extension. See
“Displaying the language” (page 103).
9.1.2 Setting the working language
If you allow GDB to set the language automatically, expressions are interpreted the
same way in your debugging session and your program.
If you wish, you may set the language manually. To do this, issue the command 'set
language lang', where lang is the name of a language, such as c. For a list of the
supported languages, type 'set language'.
Setting the language manually prevents GDB from updating the working language
automatically. This can lead to confusion if you try to debug a program when the
working language is not the same as the source language, when an expression is
acceptable to both languages―but means different things. For instance, if the current
source file was written in C, and GDB was parsing Modula-2, a command such as:
print a = b + c
might not have the effect you intended. In C, this means to add b and c and place the
result in a. The result printed would be the value of a. In Modula-2, this means to
compare a to the result of b+c, yielding a BOOLEAN value.
9.1.3 Having GDB infer the source language
To have GDB set the working language automatically, use 'set language local'
or 'set language auto'. GDB then infers the working language. That is, when your
program stops in a frame (usually by encountering a breakpoint), GDB sets the working
language to the language recorded for the function in that frame. If the language for a
frame is unknown (that is, if the function or block corresponding to the frame was
defined in a source file that does not have a recognized extension), the current working
language is not changed, and GDB issues a warning.
This may not seem necessary for most programs, which are written entirely in one
source language. However, program modules and libraries written in one source
language can be used by a main program written in a different source language. Using
'set language auto' in this case frees you from having to set the working language
manually.
102 Using GDB with Different Languages