This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strip, Linux's backtrace_symbols API, and GCC optimizations levels


bgoodr3 <bgoodr@gmail.com> writes:

> Also, is there a way to have my cake and eat it too, which is to be able to
> use -O2, but still have backtrace_symbols work like it would at lower
> optimization levels?

It depends on what is missing.  backtrace_symbols will never show calls
for which the callee has been inlined.  However, it should normally be
able to show non-inlined calls regardless of the optimization level, as
long as you compile C++ or compile with the -fexceptions or
-funwind-tables option.  That said, backtrace_symbols will not work
reliably if called from a signal handler.


> If the answer is "no" (which is what I expect), then is
> there some way (via special CPP macros defined by GCC) to detect an
> optimization level inside the C code by way of a #ifdef check, so that I can
> say something pseudo-coded like this:
>
> #ifdef is_optimization_level >= 2

gcc defines the preprocessor symbol __OPTIMIZE__ when doing an
optimizing compilation.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]