11.6 Debugging Optimized Programs

An optimized program no longer has an exactly matching relationship between the programmer's sequence of instructions in assembly language or a high-level language and the generated sequence of machine instructions. Accordingly, the recommended practice is to inhibit or sharply curtail optimizations when using a debugger, in order to avoid confusion.

In rare instances, an unoptimized program may appear to work correctly, yet the optimized version seems to operate peculiarly. Some debugger capabilities can still be of use, such as stopping on entry to a routine or perhaps watching for changes to a variable. Optimized instruction sequences may keep variables from a high-level language in registers and update them in memory only infrequently. If you examine using the variable name instead of the appropriate register, you may see stale information. Moreover, keep in mind that a debugger cannot access a variable at all if it has been eliminated through optimization.

When you have narrowed down the possible locations of the difficulty, you can step through by machine instruction, examine register contents, and inspect the sequence of actual machine instructions. Although voluminous, a listing file containing the machine instructions can also be helpful.



ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net