tags:

views:

215

answers:

1

Hi all,

I was wondering if I can get a list of gcc option that can cause gdb to behave strange.

Of course, we all know that using optimization options (-O3 for instance) causes weird behaviour in gdb, but what are the other options that can have such impact?

(I'm currently trying to run an mpeg2 decoder in gdb and I get weird behaviour even after removing optimization flags ...)

+4  A: 

Hello,

I think it's difficult to say what flags you should't use when calling gcc for debugging. In gcc docs it is described that the default debug flags are -g and -O2, and using -g -O0 -fno-inline disable any optimization and function inline.

In my opinion, if you really want to guaratee that nothing will mess your debugging process, you just have to compile with -g -O0 -fno-inline flags.

coelhudo
what happen if you have at the same time -O3 flag, some other flag, and "-g -O0 -fno-inline" ?
I made a simple program and use -O3 -g -O0 -fno-inline -S and I had the same output of -g -O0 -fno-inline -S. But with -g -O0 -fno-inline -O3 -S the output was different, in this case, the assembly code with -O3 was bigger than the code generated without -O3. I don`t know the implications of this result yet.
coelhudo