I have some trouble with gdb. This is my code in a single file named main.cpp
#include
void myfunc();
int main(){
char msg[] = \"Hello
Try to use '-Og', too. Maybe that will help, because as @KevinDTimm wrote: compiler may optimize it.
Reference:
Compile using -g
and -ggdb
flags.
Your command should be
g++ -g -ggdb -Wall main.cpp -o foo
Thank you for your answers. I found what is wrong. As jcm says my gcc is relatively new. I have update gdb to the last current version which is GNU gdb (GDB) 7.6. Now this works perfectly.
By the way, with the version g++ (Ubuntu/Linaro 4.6.4-1ubuntu1~12.04) 4.6.4, gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 works perfectly.
Thank you for all of you.