I'm using GCC 4.4.1 and GDB 7.0-ubuntu on Ubuntu 9.10. However, GCC won't generate debugger info when using any of the following switches: -g, -g3, -ggdb, or -ggdb3. So when I run the program with GDB, its as if there was no debugger information generated. I have created very simple test source files in a new, empty folder.
Here is one example:
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv)
{
char msg[4];
// allocate 4 bytes on the stack
strcpy (msg, "hello world");
// overflow
printf ("%s\n", msg);
return 0;
}
UPDATE: here is my command line sequence:
gcc -g ./mytest.c -o mytest
gdb ./mytest
UPDATE: I have previously turned on MALLOC_CHECK_=1 in order to test the stack overflow problem in the code. And this works so I get a stack trace. But the stack trace is no different whether I include the debug info or not. What I expected to see with the debugger information was a line number of a file for where the problem occurred under GDB. However this doesn't happen.