gcc -g genererer debug information, der skal bruges af GDB debugger.
mulighed | beskrivelse |
---|---|
-g0 | ingen fejlretningsoplysninger |
-g1 | minimal fejlretningsinformation |
-g | standard debug information |
-g3 | maksimal debug information |
$ gcc -glevel [options] [source files] [object files] [-o output file]
Skriv kildefilen myfile.c :
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run!!\n");
}
Byg myfile.c på terminal og kør gdb for at debug:
$ gcc -g myfile.c -o myfile
$ gdb myfile
(gdb) run
Starting program: /home/ubuntu/myfile
Program run!!
Program exited with code 012.
(gdb) quit
$