Ryan Mansfield(deleted)
|
Re: Using -O3 optimization and trying to get a bt
|
Ryan Mansfield(deleted)
11/28/2007 7:12 PM
post3072
|
Re: Using -O3 optimization and trying to get a bt
> -O3 does not give me a back trace ....but -O0 does ... so I needed to find the
> best option to get bt while I optimize...
Does not give you a backtrace as in no backtrace at all? Or is the backtrace incorrect?
Does -O2 give you a backtrace? If it lose the ability to backtrace between -O2 and -O3, it might be that the functions
were inlined.
For example:
int a(int x) { return x; }
int b(int x) { return a(x); }
int c(int x) { return b(x); }
int main() {
return c(3);
}
With -O3, c is never called. No stack to backtrace
With -O2 or -O3 -fno-inline-functions, a is called but b and c calls are optimized out.
#0 0x08048333 in a ()
#1 0x0804837d in main ()
With -O2 -fno-optimize-sibling-calls, a, b and c are called and therefore we can get a backtrace.
#0 0x08048333 in a ()
#1 0x08048351 in b ()
#2 0x08048371 in c ()
#3 0x0804839d in main ()
Using -O3 does not cripple GDB's ability to do a backtrace -- better optimizations just mean there might be less stack,
or no stack to backtrace.
Which function calls gcc removes is very specific to the code being compiled so generalized statements about how to get
a backtrace at O3 won't be accurate.
Regards,
Ryan Mansfield
|
|
|