Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

debugging and optimization on Linux

Braun__Jay
Beginner
245 Views

I am modifying someone else's code on Linux, and I get some runtime errors.  The programs are built with the -O3 option.  I wish to debug with gdb and take advantage of as many features as possible, so -debug comes to mind, possibly -traceback

What would be the best combination of options to enable use of gdb?  Would you recommend no -O options at all?

Thanks,
Jay

0 Kudos
2 Replies
Juergen_R_R
Valued Contributor I
245 Views

Turn on all checks at compile and run time, e.g. -Wall. Use one or more different compilers, e.g. NAG and/or gfortran. Check the array bounds etc. Usually -O0 is the best for debugging to avoid heavy optimisation, because optimisation oftentimes hinders the output of values and arguments of functions and subroutines in tracebacks and/or debugging sessions. 

0 Kudos
TimP
Honored Contributor III
245 Views

The advice about allowing debug to disable optimization at first is good. Eventually you may need to debug with all your optimization enabled Then you need -debug inline_debug_info but you will still find some symbols missing and some reordered operations.  -fno-inline-functions will skip some optimizations and may help with debugging while avoiding requirement for inline_debug_info.  We've seen programming errors which aren't exposed until interprocedural optimization is in use.  Bounds checking (preferably without optimization) may catch such errors.

0 Kudos
Reply