Debugging Optimized Code

IDB can help debug an optimized program that is compiled with the -g option. However, some of the information about the program may be inaccurate. In particular, the locations and values of variables are often not correctly reported, because the common forms of debug information do not fully represent the complexity of the optimizations provided by the -O1, -O2 or -O3 options.

To avoid this limitation, compile the program with an Intel compiler, specifying both the -g and -debug extended options, in addition to the desired -O1, -O2 or -O3 optimization  option. This causes the generation of more advanced (but less commonly supported) debug information that enables the following:

The following limitation exists:

Optimization often causes the instructions for a source line to be generated in an order which does not match the order of the source; the instructions for a line may be mixed in with instructions from other source lines as well. This is particularly true for the IA-64 architecture. When stepping through such code, the program will tend not to stop at each source line in turn, but rather it will stop each time a change in source line occurs.