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 form of debug information cannot fully represent the complexity of the optimizations provided by the -O1/2/3 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/2/3 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 prevents instructions for a source line being generated in consecutive locations. This is particularly true for the Intel® Itanium® 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.