Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe.

Similar presentations


Presentation on theme: "Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe."— Presentation transcript:

1 Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe

2 Some background about GDB... ● Started by RMS in 1986 ● Ported to all major OSes thereafter ● Has support for almost all popular architectures ● Supports symbolic debugging ● Primarily used for debugging C/C++ ● Supports remote debugging ● Work being done on bringing in 'Reversible debugging'

3 Getting ready... ● Compiling with debug information ● Side effects of debug information ● Readying multi-file projects for debugging ● Nifty utililies – file, nm, objdump, strip etc

4 A typical debug workflow ● Run ● Backtrace ● Break ● Step ● Inspect ● Change ● Continue

5 Preliminary usage ● The GDB executable - /usr/bin/gdb ● To start – gdb [program-name] ● To quit – quit ● Select a program to run – file ● Run a program in gdb - run ● Kill a prog in gdb – kill ● Getting help – GDB manual and online help

6 Zeroing on the function ● Backtracing - bt ● Moving between frames – up, down and frame ● Viewing arguments' addresses – info args ● Other information about the frame – info frame

7 Looking at the source ● Specifying the source file(s) – directory ● Listing the source – the many variants of list ● Searching the source – search

8 Breaking into the code ● Breakpoint on a function – b func_name, continue ● Breakpoint on a source line – b [filename:]line_no ● Listing current breakpoints – info b ● Break only the first time – tbreak ● Ignore, disable and delete breakpoints ● Watchpoints

9 Moving ahead...one step at a time ● Single stepping – step, next ● 'finish'ing a function ● Forcing a return

10 Inspecting data ● Global variables – info variables ● Local variables – info locals ● Examining values of variables – print ● Viewing arrays ● Automatic display

11 Inspecting data contd... ● Examining memory - x ● Viewing registers – info registers ● Listing functions ● Listing variables in scope of a function

12 On-site debugging ?? ● Get the pid of the process ● Attach to a running process – attach ● Loading symbol table from an external file ● Detach from a running process – detach

13 Miscellaneous stuff ● Getting runtime information ● Redirecting output ● Logging ● Shell commands ● Graphical front-ends to GDB ● Delta debugging B)

14 END OF PART I Questions welcome...


Download ppt "Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe."

Similar presentations


Ads by Google