Debugging with gdb – CMPSC 311 Lecture

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

30 vocabulary flashcards covering key terms and commands from the CMPSC 311 lecture on debugging and gdb usage.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

Debugging

The process of locating, understanding, and fixing errors where a program’s behavior diverges from expectations.

2
New cards

Printing / Logging

A basic debugging technique that outputs variable or memory values (e.g., using printf) at selected points in code.

3
New cards

assert()

C standard‐library macro that aborts the program if a specified expression is false, enforcing assumptions and catching logic errors early.

4
New cards

Logic / Program Guard

An assert statement used to ensure that critical conditions (e.g., non-NULL pointers, valid indices) always hold.

5
New cards

Debugger

A tool that executes a program in a controlled environment, allowing you to pause, inspect, and modify program state interactively.

6
New cards

gdb (GNU Debugger)

The most common command-line debugger on UNIX/Linux systems for C/C++ programs.

7
New cards

lldb

A newer debugger (LLVM project) available on macOS and many Linux systems, serving as an alternative to gdb.

8
New cards

run (gdb)

Starts the program inside gdb; additional arguments after run are passed to the program.

9
New cards

list (gdb)

Displays source code (10 lines by default) around a line number or function; alias: l.

10
New cards

Breakpoint

A marked location in code where execution will stop so you can inspect program state.

11
New cards

break (b) command

Sets a breakpoint at a specified function or line number in gdb.

12
New cards

delete (d) command

Removes one or more breakpoints by their number in gdb.

13
New cards

Conditional Breakpoint

A breakpoint that only stops execution when a given Boolean expression is true.

14
New cards

cond command

Attaches a condition to an existing breakpoint: cond

15
New cards

break … if

Sets a breakpoint and condition in one step: b if .

16
New cards

info breakpoints

Lists all current breakpoints and their status in gdb.

17
New cards

info command (gdb)

A family of sub-commands (info registers, info args, etc.) that report on the program and debugger state.

18
New cards

save breakpoints

Writes current breakpoint settings to a file so they can be reused later.

19
New cards

source command

Reads gdb commands (e.g., saved breakpoints) from a file and executes them.

20
New cards

Watchpoint

A data breakpoint that stops execution whenever the value of a specified variable or memory location changes.

21
New cards

where command

Displays the current call stack showing each active function and its source line.

22
New cards

up command

Moves one frame up the call stack, letting you inspect the calling function.

23
New cards

down command

Moves one frame down the call stack toward the most recent frame.

24
New cards

print (p) command

Evaluates and displays an expression or variable value; formats can be forced with /o, /x, /d, /t, /f, /a, /i, /s.

25
New cards

x command

Examines raw memory at a given address with flexible count/format/size options: x/[num][format][size] .

26
New cards

next (n) command

Executes the next source line, stepping over function calls without entering them.

27
New cards

step (s) command

Executes the next source line, stepping into function calls so you can debug inside them.

28
New cards

continue (c) command

Resumes program execution until the next breakpoint, watchpoint, or program termination.

29
New cards

finish (fin) command

Continues execution until the current function returns, then stops at the caller.