Week 12 - Debugging

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/11

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

Why is debugging important?

  • Helps trace code execution and understand lower abstraction levels.

  • Validates assumptions, verifies data, and memory.

  • Essential for finding and fixing bugs.

2
New cards

What is a debugger?

  • An external tool to inspect program execution and runtime properties, like:

    • Memory, variables, objects, threads, registers, and call stacks.

  • Requires language support (e.g., debug symbols like DWARF).

  • More efficient than using print statements.

3
New cards

When should you use a debugger vs. printing/logging?

  • Use a debugger during development to inspect code execution.

  • Use printing/logging when a debugger is unavailable (e.g., in production or on player devices).

4
New cards

What is the #1 feature of a debugger?

The ability to pause program execution at specific points using breakpoints.

Can be achieved in various ways, but typically by setting breakpoints

5
New cards

What are breakpoints?

  • Points in the source code where the debugger halts execution for introspection.

  • Useful for examining threads, variables, and call stacks.

6
New cards

What is a halted context?

The state of the program when execution is paused, allowing you to inspect:

  • Threads, call stacks, local variables, objects, and registers.

7
New cards

What is a call stack?

  • Shows how the program reached the current line of code.

  • Includes the sequence of function calls and the current thread.

8
New cards

What are watchpoints?

  • Advanced breakpoints that pause execution when:

    • Specific variables or memory accesses meet conditions (e.g., variable <= 5).

  • Supported in tools like VSCode and Chrome debugger.

9
New cards

How do breakpoints work under the hood?

  • Software Breakpoints: Replace an instruction with a trap that interrupts the program.

  • Hardware Breakpoints: Use dedicated CPU registers to halt execution.

10
New cards

What is DWARF in debugging?

(DWARF):

  • Converts program memory and addresses into source code and variables.

  • Requires compiler flags like -g for languages like C/C++, Rust, or Swift.

11
New cards

difference between breakpoint and watchpoint?

A breakpoint hits every game hits, watchpoint only hits when a condition happens


12
New cards

What are the steps a debugger can perform during a halted context?

  • Step to the next line of code.

  • Step into a function call.

  • Return to the calling function.