Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC option that can cause trouble when debugging with GDB

Tags:

gcc

flags

gdb

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 ...)

like image 520
claf Avatar asked Feb 11 '10 17:02

claf


1 Answers

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

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.

like image 59
coelhudo Avatar answered Sep 25 '22 08:09

coelhudo