I am using GCC to build my embedded C application, that I debug with GDB. The app consists on a program running on a host processor and multiple programs running on multiple accelerator DSP cores.
My host (control) program has a very simple main function with a short loop calling a bigger function that does some stuff and activates the accelerators. My problem is that when compiling with optimization, the debug is harder in terms of breakpoint location in the main function. When building w/o optimization, the other function compiles sub-optimally.
A possible solution would be to separate the host project to two source files and use different level of optimization. However, I would like to keep it in the same file.
Is there a way (pragma?) to instruct the compiler to do different level of optimization in the same source unit?
With a recent GCC (e.g. GCC 4.6), you can change optimization with function specific option pragmas, like e.g.
You can also have function attributes for the same.
IIRC, this appeared in GCC 4.5, and works much better in 4.6, so you need a recent version of GCC.