In This Book

Debugging Optimized Code

HP/DDE supports debugging of code compiled at optimization levels 2 and below. The following is a brief description of the compiler optimization options that are compatible with debugging:

+O0

Minimal optimization. This is the default.

+O1

Basic block level optimization.

+O2

Full optimization within each procedure in a ￿le. (Can also be

 

 

invoked with the compiler option -O.)

For more information about optimization levels, consult your compiler

documentation.

 

Ordinarily, you ￿rst compile and debug your program without optimization.

All or nearly all of the bugs in your program will show up in the unoptimized

version.

 

After eliminating all the bugs that you can ￿nd, turn on optimization (compile

with -O). If the program behaves incorrectly, scan the source code for the most

common kinds of bugs that appear for the ￿rst time in optimized code:

 

Uninitialized

variables

 

 

 

Out-of-bounds array references

 

 

Variable references based on the assumption that two variables are adjacent in memory

These kinds of problems, however, are often very di￿cult to ￿nd by examining

 

the source code. If you cannot determine the reason for the program's

 

misbehavior, you need to debug the optimized code.

 

This section provides background information on the di￿erences between

8

optimized code and unoptimized code.

 

For tutorial and task-orien ted information on ho w to debug optimized code

 

using the debugger, see the online help.

 

Debugging in Special Situations 8-17