* bug disappears if compiled with -O0
@ 2004-07-26 3:10 Baurjan Ismagulov
2004-07-26 3:55 ` Michael Chastain
2004-07-26 5:47 ` Eli Zaretskii
0 siblings, 2 replies; 6+ messages in thread
From: Baurjan Ismagulov @ 2004-07-26 3:10 UTC (permalink / raw)
To: gdb
Hello,
I'm trying to track down a problem in a dynamic library. However, the
bug doesn't show up if the code is compiled with -O0 (it is normally
compiled with -O2). Any pointers or tips on how to proceed (except
printf)?
I'm using gcc version 3.3.4 (Debian 1:3.3.4-2) and GNU gdb 6.1-debian,
configured as "i386-linux".
Thanks in advance,
Baurjan.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug disappears if compiled with -O0
2004-07-26 3:10 bug disappears if compiled with -O0 Baurjan Ismagulov
@ 2004-07-26 3:55 ` Michael Chastain
2004-07-26 21:13 ` Baurjan Ismagulov
2004-07-26 5:47 ` Eli Zaretskii
1 sibling, 1 reply; 6+ messages in thread
From: Michael Chastain @ 2004-07-26 3:55 UTC (permalink / raw)
To: ibr; +Cc: gdb
Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr> wrote:
> I'm trying to track down a problem in a dynamic library. However, the
> bug doesn't show up if the code is compiled with -O0 (it is normally
> compiled with -O2). Any pointers or tips on how to proceed (except
> printf)?
gdb can debug code generated with gcc -g -O2. However, when debugging
optimized code, things like "next" appear to skip around, and variables
sometimes don't contain the values that you think that they should.
You could try gcc 3.4.1. Just use "--prefix" to build it and you can
locate it in its own directory, so you can safely experiment with
different compilers.
You didn't mention what language your library is written in.
If the bug truly is a code generation bug, then you will need to read
assembly language to isolate the bug. Also, adding "printf"
(or other function calls) in the middle of a function can make the
bug disappear, because the results of optimization change when you
invade with a function call.
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug disappears if compiled with -O0
2004-07-26 3:10 bug disappears if compiled with -O0 Baurjan Ismagulov
2004-07-26 3:55 ` Michael Chastain
@ 2004-07-26 5:47 ` Eli Zaretskii
1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2004-07-26 5:47 UTC (permalink / raw)
To: Baurjan Ismagulov; +Cc: gdb
> Date: Mon, 26 Jul 2004 00:38:33 +0200
> From: Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr>
>
> I'm trying to track down a problem in a dynamic library. However, the
> bug doesn't show up if the code is compiled with -O0 (it is normally
> compiled with -O2). Any pointers or tips on how to proceed (except
> printf)?
Just debug as usual, GDB can debug optimized code.
In fact, I suggest to do that always, since if you debug a program
compiled without optimizations, then ship a binary compiled with -O2,
you in effect debugged and tested a similar, but quite different code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug disappears if compiled with -O0
2004-07-26 3:55 ` Michael Chastain
@ 2004-07-26 21:13 ` Baurjan Ismagulov
2004-07-26 21:19 ` Kip Macy
2004-07-27 0:52 ` Michael Chastain
0 siblings, 2 replies; 6+ messages in thread
From: Baurjan Ismagulov @ 2004-07-26 21:13 UTC (permalink / raw)
To: gdb
Hello Michael and Eli,
On Sun, Jul 25, 2004 at 11:10:33PM -0400, Michael Chastain wrote:
> gdb can debug code generated with gcc -g -O2. However, when debugging
> optimized code, things like "next" appear to skip around, and variables
> sometimes don't contain the values that you think that they should.
This was the very reason why I wanted to use -O0 :) .
> You didn't mention what language your library is written in.
C++.
> If the bug truly is a code generation bug, then you will need to read
> assembly language to isolate the bug.
I will as soon as I'm able to locate it. Could it be anything other than
an optimization bug? The problem is reported also for gcc 2.95.4 on
stable.
With kind regards,
Baurjan.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug disappears if compiled with -O0
2004-07-26 21:13 ` Baurjan Ismagulov
@ 2004-07-26 21:19 ` Kip Macy
2004-07-27 0:52 ` Michael Chastain
1 sibling, 0 replies; 6+ messages in thread
From: Kip Macy @ 2004-07-26 21:19 UTC (permalink / raw)
To: Baurjan Ismagulov; +Cc: gdb
>
> > If the bug truly is a code generation bug, then you will need to read
> > assembly language to isolate the bug.
>
> I will as soon as I'm able to locate it. Could it be anything other than
> an optimization bug? The problem is reported also for gcc 2.95.4 on
> stable.
>
Recently I hit a bug caused by a doubleword unaligned store. It only
showed up with -O2 because the compiler would otherwise generate
single-word stores. You can try different compilers, but I would take a
close look at the generated code.
-Kip
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug disappears if compiled with -O0
2004-07-26 21:13 ` Baurjan Ismagulov
2004-07-26 21:19 ` Kip Macy
@ 2004-07-27 0:52 ` Michael Chastain
1 sibling, 0 replies; 6+ messages in thread
From: Michael Chastain @ 2004-07-27 0:52 UTC (permalink / raw)
To: ibr, gdb
Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr> wrote:
> I will as soon as I'm able to locate it. Could it be anything other than
> an optimization bug? The problem is reported also for gcc 2.95.4 on
> stable.
It could be a bug in the compiler, or it could be a bug in your
program, or both the compiler and the program could be correct
and you're misinterpreting the output ... you have to get down
and dirty with the debugger to figure out what it is.
That's not very helpful, I know. :-/
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-07-27 0:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-26 3:10 bug disappears if compiled with -O0 Baurjan Ismagulov
2004-07-26 3:55 ` Michael Chastain
2004-07-26 21:13 ` Baurjan Ismagulov
2004-07-26 21:19 ` Kip Macy
2004-07-27 0:52 ` Michael Chastain
2004-07-26 5:47 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox