|Non-Confidential||PDF version||ARM 100748_0607_00_en|
|Home > Using Common Compiler Options > Building to aid debugging|
During application development, you must debug the image that you build. The ARM® Compiler tools have various features that provide a good debug view. There are also some features you must avoid when building an image for debugging.
To build an image for debugging, you must compile with the
option. This option allows you to specify the DWARF format to use. The
-g option is a synonym for
-gdwarf-4. You can specify DWARF 2 or DWARF 3 if necessary, for
When linking, there are several armlink options available to help improve the debug view:
--debug. This option is the default.
--no_removeto retain all input sections in the final image even if they are unused.
--bestdebug. When different input objects are compiled with different optimization levels, this option enables linking for the best debug illusion.
To build an application that gives the best debug view, it is better to use
options that give the fewest optimizations. ARM recommends using optimization level
-O1 for debugging. This option gives good code
density with a satisfactory debug view.
Higher optimization levels perform progressively more optimizations with correspondingly poorer debug views.
The compiler attempts to automatically inline functions at optimization levels
If you must use these optimization levels, disable the automatic inlining with the
-fno-inline-functions. The linker inlining is disabled by default.
The linker provides various options to support overlay-aware debuggers:
These options permit an overlay-aware debugger to track which overlay is active.
Avoid using the following in your source code:
__attribute__((always_inline))function attribute. Qualifying a function with this attribute forces the compiler to inline the function. If you also use the
-fno-inline-functionsoption, the function is inlined.
__declspec(noreturn)attribute and the
__attribute__((noreturn))function attribute. These attributes limit the ability of a debugger to display the call stack.
Avoid using the following features when building an image for debugging:
--inlineoption. This option changes the image in such a way that the debug information might not correspond to the source code.