https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38534

--- Comment #31 from Lukas Grätz <lukas.gra...@tu-darmstadt.de> ---
(In reply to Jakub Jelinek from comment #30)
> (In reply to Lukas Grätz from comment #29)
> > Yes, when a backtrace is based on rbp, one needs -fno-omit-frame-pointer. I
> > trusted comment #10 here, as it made sense.
> 
> See PR114116.
> 
> > glibc's backtrace() function and friends only reports function names and
> > addresses. This looks like the gdb bt command. I admit, I did not take a
> > proper look into that before.
> 
> Yes, it is gdb bt.  And it is what people heavily rely on for debugging, if
> something fails an assertion or aborts etc., they want to figure out why.
> 

True.

> > I belief this could and should be somehow be fixed by adding DWARF info that
> > certain callee-saved registers (= the function parameter values) were
> > overwritten. The corrected backtrace could look something like this:
> 
> That can be arranged by emitting those .cfi_undefined directives...
>  
> > #2  0x00000000004011d2 in baz (a=42, b=43, c=44, d=<optimised out>,
> > e=<optimised out>, f=<optimised out>, g=48, h=49) at /tmp/1.c:38
> 
> ... but really will not help users to debug/fix their code.


Even when I compile a simple program with gcc -O2 -g:


#include <stdlib.h>
int main(int argc, char** argv) {
    abort();
}


I still get an "argc=<optimised out>":

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7dcd859 in __GI_abort () at abort.c:79
#2  0x0000000000401046 in main (argc=<optimised out>, argv=<optimised out>) at
simple.c:4


Yes, for a better debugging, it would be nice if optimised code would just not
be optimised... But this goes against optimization.


> > > So, I think we should limit this to -fno-unwind-tables or maybe
> > > -mcmodel=kernel.
> > Now I am confused. The optimization is limited to -fexceptions. And the
> > documentation of -funwind-tables says "Similar to -fexceptions, except". So
> > shouldn't -funwind-tables behave similar to -fexceptions? I don't see
> > anything kernel-specific here.
> 
> Given that even with -fno-asynchronous-unwind-tables (or -fno-unwind-tables)
> gcc emits
> the unwind info, just not into .eh_frame but .debug_frame, we shouldn't
> disable it
> just when not emitting .eh_frame, but should just disable it always.
> There is a reason why it has been rejected years ago.
> If anything, guard it with some non-default -m* option and explain the
> consequences to users if they use it.  Still, the guarding IMHO should be
> done on top of the PR114116
> change, because having random crashes from backtrace or gdb bt even when
> user asked for it is a bad idea.


Yes, it is a bad idea to have crashes from backtrace or gdb. But when this is
only about <optimised out>, I don't see the point about disabling it always.

Reply via email to