[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
More C++ Exceptions Issues
- Date: 2 May 1999 18:23:53 -0000
- From: ian at airs.com (Ian Lance Taylor)
- Subject: More C++ Exceptions Issues
From: "Rosimildo DaSilva" <rdasilva at connecttel.com>
Date: Sun, 2 May 1999 13:27:37 -0500
One of the problems with C++ working a very bizarre manner on RTEMS,
is the fact that I was compiling the BSP=pc386 with the options:
( Very small stack size is another problem ).
-O4 -fomit-frame-pointer
this causes C++ code to cause all kind of problems.
I have stepped in through the code and GDB shows garbage values
for some parameters, mainly in calls to C++ ctors.
This is expected behaviour. You can not easily debug code compiled
with -fomit-frame-pointer. This is documented in the gcc docs:
`-fomit-frame-pointer'
Don't keep the frame pointer in a register for functions that
don't need one. This avoids the instructions to save, set up and
restore frame pointers; it also makes an extra register available
in many functions. *It also makes debugging impossible on some
machines.*
That fact that you can not use the debugger does not mean that the
code is incorrect.
Also, doing this change makes the code to be about 15% smaller.
I really did not understand this. I really appreciate if someone could
explain whar is going on.
Is there any real reason why the flags -O4 -fomit-frame-pointer in the first
place ?
On a register-starved machine like the i386, -fomit-frame-pointer
normally produces better code because the compiler does not have to
reserve a register for use as a frame pointer.
The change in size you see between -O2 and -O4 may be arising because
at -O3 and above the compiler will automatically inline functions when
possible. This is a trade off for decreased execution time at the
cost of increased size. Using -O4 -fno-inline-functions would disable
the automatic inlining.
Ian