GDB Debugger
GDB Debugger
GDB, the GNU Project debugger, allows you to see what is going on `inside' another
program while it executes -- or what another program was doing at the moment it crashed.
GDB can do four main kinds of things (plus other things in support of these) to help you
catch bugs in the act:
Start your program, specifying anything that might affect its behavior.
Make your program stop on specified conditions.
Examine what has happened, when your program has stopped.
Change things in your program, so you can experiment with correcting the effects of
one bug and go on to learn about another.
1.Install GDB
2.C program
3. Compile the program specifically for GDB by using the `-g` flag:
gcc -g first.c
Using this flag means that GDB will preserve function and variable names and line numbers
for the debugger. Normally this information is not retained in a compiled program.
4.To start the GNU debugger running your program with command line arguments you can
use:
gdb a.out
Academic Year: 2022-23 Name of Student: Afif
Semester: III Student ID:21104060
Class / Branch/ Div: SE- IT A/ B Roll No.33
Subject: Data Structure Lab Date of Submission:29-10
Name of Instructor: Sneha Miss
5. GDB will display the line of code at which the error occurred. However, it will be more
helpful to see the entire source file. To do this use the Text User Interface (TUI) mode by
typing:
layout next
Academic Year: 2022-23 Name of Student: Afif
Semester: III Student ID:21104060
Class / Branch/ Div: SE- IT A/ B Roll No.33
Subject: Data Structure Lab Date of Submission:29-10
Name of Instructor: Sneha Miss
print i