Software Methods and Tools

Kenneth M. Anderson <kena@cs.colorado.edu>

Lecture 28: Debugging and gdb

Today's Lecture

Debugging

Finding Faults

Bridging the Gap

Debugging Tools

Types of Debuggers

Two styles of use

More on Breakpoints

Implementing Breakpoints

Editing Variables

Advantages

The GNU Debugger

gdb Architecture

Gdb Arch

Preparing to use the Debugger

What’s a symbol table?

Symbol Table Example

Symbol Table Example

More on the Symbol Table

Debugging Programs

Running programs in GDB

Supplying Input to a Program

Program Crashed. Core Dumped

To Read a Core File

More on Debugging

Call Stack Example

1: main() {
2:     int i;
3:     i = 2;
4:     func(4);
5: }
6:
7: func (int i) {
8:     …
9: }
(gdb) backtrace
#0 func (i=4) at  main.c:8
#1 0x22b0 in main() at main.c:4
(gdb) print i
4
(gdb) frame 1
#1 0x22b0 in main () at main.c:4
(gdb) print i
2

Common Commands

Demo

Coming Up Next