This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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: bug disappears if compiled with -O0


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


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