Debugging With the GNU Debugger

67 %
33 %
Information about Debugging With the GNU Debugger

Published on March 5, 2014

Author: goakley123



Slides from a lecture on the debugging process and using the GDB.

GNU Debugger Glen Oakley

What is a debugger?

The Four Things ● ● ● ● Start your program Make your program stop Examine what has happened Change things in your program

Your Things ● ● ● ● ● ● Start your program Break / Watch Checkpoint Next / Step / Continue Backtrace Print


Debugging Flow ● ● ● ● ● ● ● Testing Brute-forcing Identify symptom - what happened? Identify problem - why? Locate problem Blame someone (else) Fix problem Repeat with the new problems

GDB Execution ● Run program in ‘virtual’ environment ● Run until ○ Termination ○ Breakpoint ● Flow control ● State Information

Commands ● Run ○ Execute program with args ○ Redirection ● Backtrace ○ Stack trace of your location in the program ○ Identify where crash happened

Example verbose_array.c

Commands ● Break ○ Location at which to halt the program ○ Breaks before execution of statement(s) ● Watch ○ Monitors a variable for changes ○ Requires variable to be in scope ● Clear ○ Remove breakpoints

Commands ● Checkpoint ○ Store the state of the program ○ Programs can be restarted at checkpoints ● Step ○ Step through the program line by line ● Next ○ Execute the next line in the current frame ○ Does not step through sub-functions

Example osh.c

Commands ● Print ○ ○ ○ ○ Show the state of memory/variables Works with array and struct/union notation Will assume c-strings when applicable @ can be used on arrays for grouping prints ● Set Var ○ Change memory/variables ● Continue ○ Run until another break/watch point is triggered

Example sudoku.c

Recap ● Debugging process is unavoidable ● GDB provides assistance ○ If I see one more stray printf()... ● Basic flow control commands ○ Allow tracing a stopped program ○ Set breakpoints to stop the program ○ Enable querying/modifying the program state

Thanks! @goakley123

Add a comment

Related presentations

Related pages

Debugging with GDB - Free software! Get ...

Debugging with GDB. This file documents the gnu debugger gdb. This is the Tenth Edition, of Debugging with gdb: ...
Read more

GNU Debugger – Wikipedia

GDB; Bildschirmfoto des GNU Debuggers: Basisdaten; Entwickler: GNU-Projekt: Aktuelle Version: 7.11 (24. Februar 2016) Betriebssystem: Unix-Derivate (u. a ...
Read more

GNU Debugger - Wikipedia, the free encyclopedia

The GNU Debugger, usually called just GDB and named gdb as an executable file, is the standard debugger for the GNU operating system. However ...
Read more

3.9 Options for Debugging Your Program - GCC, the GNU ...

Using the GNU Compiler Collection (GCC) ... 3.9 Options for Debugging Your Program. To tell GCC to emit extra information for use by a debugger, in almost ...
Read more

Debugging Under Unix: gdb Tutorial - Carnegie Mellon ...

Debugging Under Unix: gdb Tutorial ... to get started with using the gdb debugger. This tutorial assumes you already know how to ... the gnu package ...
Read more

Debugging with GDB: The GNU Source-Level Debugger: Richard ...

Richard M. Stallman, founder of the Free Software movement, is the original author of GDB. Roland Pesch is a professional technical writer. Stan Shebs was ...
Read more

Debugging Options - Using the GNU Compiler Collection (GCC)

Using the GNU Compiler Collection (GCC) ... 3.9 Options for Debugging Your Program or GCC. GCC has various special options that are used for debugging ...
Read more

Linux software debugging with GDB - IBM - United States

Most flavours of Linux come with the GNU debugger, or gdb to the shell. Gdb lets you see the internal structure of a program, print out variable values ...
Read more

Debugging with GDB - Free software! Get ...

The purpose of a debugger such as gdb is to allow you to ... you cannot generate optimized executables containing debugging information. gcc, the gnu C/C ...
Read more

Suchergebnis auf für: GNU Debugger: Bücher

Prime testen Bücher
Read more