[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Automatic -fomit-frame-pointer usage



Hello.

MiKRO has found the patch for enabling the safe usage of -68020-60, -O and -fomit-frame-pointer at the same time.

Now I would like to speak about the CAN_DEBUG_WITHOUT_FP gcc feature.

When this feature is enabled, GCC automatically enables -fomit-frame-pointer when -O is used.
When this feature is disabled, GCC will never use automatically -fomit-frame-pointer. We have to explicitly add -fomit-frame-pointer to the -O option (or -O2, -O3) in order to get the best optimization level.

The usage of the frame pointer (actually a6) allows gdb to determine precisely the call stack when a breakpoint is hit. It is very useful for debugging, that's why the frame pointer is always used when -O is not used. When some level of optimization is used, it is very hard to use the debugger, because the instructions are usually reordered, most variable values are inaccessible because they are stored in registers. And without the frame pointer, it may be impossible to know from which functions we are called.

Enabling CAN_DEBUG_WITHOUT_FP is good because using for example -O2 is enough to get the more efficient code. Enabling CAN_DEBUG_WITHOUT_FP is evil because using for example -O2 makes it impossible to enable the frame pointer (for debugging purpose)

Most targets don't use CAN_DEBUG_WITHOUT_FP, except the ones where gdb will never be used.

Do you think that CAN_DEBUG_WITHOUT_FP should be used for the MiNT target or not ?

--
Vincent Rivière