Debugging optimized programs presents special problems. Optimization can change the sequence of operations, add or remove code, and perform other transformations that make it difficult to associate the generated code with the original source statements. For example, the optimizer can remove all stores to a variable and represent the value in one or more machine registers. Most debuggers are incapable of following the removal of stores to a variable, and to the debugger it appears as though that variable is never updated, or possibly even set.
If you are debugging SMP code, -qsmp=noopt ensures that the compiler performs only the minimum transformations necessary to parallelize your code and preserves maximum debug capability.
First debug your program, then recompile it with your desired optimization options, and test the optimized program before placing the program into production. If the optimized code does not produce the expected results, you can attempt to isolate the specific optimization problems in a debugging session.
The following table presents options that provide specialized information, which can be helpful during the development of optimized code.
Diagnostic options
You can also use the SNAPSHOT directive to ensure to that certain variables are visible to the debugger at points in your application.