0
0
Embedded Cprogramming~10 mins

Setting breakpoints in embedded in Embedded C - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Setting breakpoints in embedded
Write Embedded C Code
Load Code into Debugger
Set Breakpoint at Line
Run Program
Program Stops at Breakpoint
Inspect Variables/Memory
Step Through Code or Continue
Repeat or Remove Breakpoint
End Debugging
This flow shows how to set a breakpoint in embedded C code, run the program, and pause execution to inspect and debug.
Execution Sample
Embedded C
int main() {
  int x = 0;
  x = x + 1; // breakpoint here
  return x;
}
Simple embedded C program where a breakpoint is set on the line that increments x.
Execution Table
StepActionCode LineBreakpoint Hit?Variable xDebugger State
1Start programint main() {NoundefinedReady
2Declare xint x = 0;No0Running
3Breakpoint hit before incrementx = x + 1; // breakpoint hereYes0Paused
4Inspect xN/AYes0Paused - Inspecting
5Step over incrementx = x + 1;No1Paused
6Continue executionreturn x;No1Running
7Program ends}No1Stopped
💡 Program ends after return statement, debugger stops.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 5Final
xundefined0011
Key Moments - 3 Insights
Why does the debugger pause before x is incremented?
Because the breakpoint is set on the line 'x = x + 1;', the debugger stops before executing that line, as shown in execution_table step 3.
Why is x still 0 when the breakpoint is hit?
At the breakpoint, the line hasn't executed yet, so x remains 0. After stepping over (step 5), x becomes 1.
What happens if you continue without stepping over?
The program runs to the end without pausing again, as shown in execution_table step 6 and 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of x when the breakpoint is first hit?
A0
B1
Cundefined
DCannot tell
💡 Hint
Check execution_table row 3 under 'Variable x' column.
At which step does the variable x change from 0 to 1?
AStep 4
BStep 5
CStep 3
DStep 6
💡 Hint
Look at execution_table rows 3 and 5 for 'Variable x' values.
If you remove the breakpoint, what happens to the debugger state in step 3?
APaused
BStopped
CRunning
DError
💡 Hint
Without breakpoint, program runs without pause; see 'Breakpoint Hit?' column in execution_table.
Concept Snapshot
Setting breakpoints in embedded C:
- Place breakpoint on code line to pause execution
- Run program in debugger
- Program stops before executing breakpoint line
- Inspect variables and step through code
- Continue or remove breakpoints to resume
- Helps find bugs by checking program state
Full Transcript
This visual execution shows how to set a breakpoint in embedded C code. The program starts and declares variable x as 0. When running, the debugger pauses at the breakpoint line before incrementing x. At this point, x is still 0. After stepping over the line, x becomes 1. Continuing runs the program to the end. This process helps inspect program state and debug embedded code effectively.