Re: gdb problems with -O1 on x86_64 architecture.

Daniel Jacobowitz
2005-05-09T16:39:50Z

On Mon, May 09, 2005 at 05:11:27PM +0100, Tigran Aivazian wrote:
> Hello,
>
> I enclosed a small program which shows a bug in gdb --- it coredumps if
> you try to look at the backtrace. Here is how to reproduce it:
>
> 1. Compile with -O1 optimization option:
>
> $ gcc -g -Wall -O1 uvar.c -o uvar-O1

It is unlikely that anyone else can reproduce this, because it depends
on what your compiler is generating. What version is it? What patches
are applied?

You may have better luck if you attach a built binary.

> Also, with application compiled with -O0 everything works perfectly. But
> with -O2 I get most of the function arguments marked as "optimized away".
> Well, surely they are NOT optimized away, but the debug info is stored in
> such a way (presumably difficult to decode according to DWARF2 rules) that
> makes gdb's life very hard to decode them, right? Is there any way to get
> gdb to see function arguments for the case of -O2 optimization?

No, more likely they are optimized away - not saved because they are no
longer available. There's no way to be sure without a binary. In your
test case, they probably _are_ gone. They are never referenced after
the function calls, so there's no benefit in saving them to the stack
and restoring them later.

--
Daniel Jacobowitz
CodeSourcery, LLC