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


 
14.29.1 Debugging Optimized Code at Various Optimization Levels
The following sections describe debugging optimized code support at each optimization
level.
14.29.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.29.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
the variable at a source code location either before or after the reported source code
location.(If the printed value is not current with respect to the current source line, the
printed value will be the immediately previous or immediately later value for the
variable.)
Backtrace commands (backtrace) can be used to display the current nest of function
calls, including calls that are inlined. When stopped within the code for an inlined call,
the parameters and the local variables of the inlined routine are not reported or available.
The disassem command does not work for functions that have no code (because all
calls to these functions are inlined or these functions are not called at all). HP WDB 5.7
14.29 Debugging optimized code 229