Skip to content

imSrbh/gdb-learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is Debugger?

In general, debugger is utility that runs target program in controlled environment where you can control execution of program and see the state of program when program is paused.
GDB is such debugger, which is used to debug C/C++ programs.

We can tell debugger when to pause a program by setting breakpoints.

$ gdb a.out

Some Basic Commands of GDB

Set Breakpoint : In order to break the program.
(gdb) b func_name or b line_no.

Run
(gdb) r or run

List : You will see some part of your program.
(gdb) l or list

Frame: It'll show where is the curser rightnow.
(gdb) f or frame

Next : You will go to next line.
(gdb) n or next

Print : To print variables.
(gdb) p main_var or print main_var

Step : Go inside the function.
(gdb) s fun1() or step fun1()

Backtrace: It will tell from where are you coming and at what point you are currnetly in your program.
(gdb) backtrace

Info b: It will show how many brakpoint you have. (gdb) info b

Delete 1 : To delete breakpoint no. 1.
(gdb) delete 1

If you want to directly go to some function.

  • Create a breakpoint at that function.
  • (gdb) continue fun3() or c fun3()

Info Local: Print all the variable of local in that fuction in that stack.

Here is the walkthrough of some basic commands:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published