Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
symbol
target
tty
undisplay
unset env
until
14.30.1 Debugging Optimized Code at Various Optimization Levels
The following sections describe debugging optimized code support at each optimization
level.
14.30.1.1 +O0 and +O1
At +O1 level, optimizations that affect the user visible state of a program are avoided.
Line numbers are accurately associated with each machine instruction. Global or local
variables may be examined, except for unused variables (which may be eliminated).
New values may be assigned to a global and a local variable (set <var> =
<expression>) when stepping by line (step/next/break <line>). However,
while stepping by instruction (stepi/nexti) at optimization level +O1, assign a value to
a variable only if stopped at the very first instruction. This is a must as local optimizations
are performed within a statement.
Backtrace commands (backtrace) may be used to display the current nest of function
calls, including for calls that are inlined. Note that even at +O1, C++ methods that are
defined within a class and Fortran arithmetic statement functions are implicitly inlinable
and are inlined. Other functions are not inlined, regardless of the inline pragmas or
keywords.
14.30.1.2 +O2/+O3/+O4/-ipo
Stepping by line number (step/next) and running to a breakpoint(break) moves the
state of a program forward. However, the program execution does not necessarily stop
at the given line.
You can set breakpoints (break) at the entry to a routine that is not inlined and examine
the values of parameters when the program execution stops at the entry of a routine. The
local variables can be examined within a function. However, the values of the local
variables may not be available at all code locations in the function. Assignment of new
values to formal parameters or local variables is NOT supported in code compiled with
optimization above +O1.
Optimization of code results in the reordering of the instructions and the source line-
numbers. Hence, the value of the variable, which is printed by the debugger may not
correspond to the reported source code location. The debugger may print the value of
230 HP-UX Configuration-Specific Information