Complete the code to set a breakpoint using the debugger keyword.
void main() {
int x = 5;
[1];
x = x + 1;
}In embedded C, setting a breakpoint can be done using an assembly instruction like int3 which triggers a breakpoint interrupt.
Complete the code to declare a volatile variable to help with debugging.
volatile int [1] = 0; void main() { while(1) { [1]++; } }
Declaring a variable as volatile tells the compiler not to optimize it away, which is useful for debugging.
Fix the error in the code to correctly trigger a breakpoint using inline assembly.
void trigger_breakpoint() {
__asm__ [1];
}The correct inline assembly syntax to trigger a breakpoint interrupt is __asm__("int3").
Complete the code to create a macro that triggers a breakpoint.
#define BREAKPOINT() __asm__ [1] ; void main() { BREAKPOINT(); }
The macro uses __asm__("int3"); to trigger a breakpoint with proper syntax.
Fill all three blanks to write a function that sets a breakpoint and increments a volatile counter.
volatile int [1] = 0; void set_breakpoint() { __asm__[2]; [3]++; }
The function uses a volatile variable named debug_counter and triggers a breakpoint with __asm__("int3");.