gcc -g יוצר מידע על ניפוי באגים שישמש את מאפר הבאגים של GDB.
אוֹפְּצִיָה | תיאור |
---|---|
-g0 | אין מידע על ניפוי באגים |
-g1 | מידע על ניפוי באגים מינימלי |
-ז | מידע על ניפוי באגים המוגדר כברירת מחדל |
-g3 | מידע ניפוי באגים מקסימלי |
$ gcc -glevel [options] [source files] [object files] [-o output file]
כתוב את קובץ המקור myfile.c :
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run!!\n");
}
בנה myfile.c בטרמינל והפעל את gdb כדי לנפות באגים:
$ gcc -g myfile.c -o myfile
$ gdb myfile
(gdb) run
Starting program: /home/ubuntu/myfile
Program run!!
Program exited with code 012.
(gdb) quit
$