no line information when dubugging with gdb

Asked by tzvibish on 2008-07-15

Ok, I'm trying to get a simple C program to debug in GDB.

#include <stdio.h>

int main (int argc, char *argv[])
{
 printf ("Hello world!\n");

 return 0;
}

From the command-line I use

gcc main.c -o exec

to make an executable.

Then

gdb

file exec
b main

Then, when I try to print the lines of code using list, I get
(gdb) l
1 /build/buildd/glibc-2.7/build-tree/i386-libc/csu/crtn.S: No such file or directory.

Or, if i step after the breakpoint,

(gdb) l
1 /build/buildd/glibc-2.7/build-tree/i386-libc/csu/crtn.S: No such file or directory.

What am I missing here?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu kdevelop Edit question
Assignee:
No assignee Edit question
Last query:
2008-07-15
Last reply:
2008-07-15
Albert Damen (albrt) said : #1

To get debug information, you will need to use the -g switch for gcc:
gcc -g main.c -o exec

Can you help with this problem?

Provide an answer of your own, or ask tzvibish for more information if necessary.

To post a message you must log in.