0
0
Cnc-programmingHow-ToBeginner · 4 min read

How to Use Breakpoint in ARM Debugger: Simple Guide

In an ARM debugger, use the break or bkpt command to set a breakpoint at a specific address or function. When the program runs, it will pause at the breakpoint, allowing you to inspect registers and memory before continuing.
📐

Syntax

The basic syntax to set a breakpoint in an ARM debugger is:

  • break <address_or_function> - Sets a breakpoint at the specified address or function name.
  • bkpt <immediate_value> - Inserts a breakpoint instruction in assembly code with an immediate value (usually 0).
  • continue or c - Resumes program execution after hitting a breakpoint.

Use delete <breakpoint_number> to remove a breakpoint.

plaintext
(gdb) break main
(gdb) continue
(gdb) delete 1
💻

Example

This example shows setting a breakpoint at the main function, running the program, and then continuing after the breakpoint is hit.

plaintext
(gdb) break main
Breakpoint 1 at 0x08000100
(gdb) run
Starting program: ./my_arm_app

Breakpoint 1, main () at main.c:10
10      int x = 5;
(gdb) continue
Continuing.
Program exited normally.
Output
Breakpoint 1, main () at main.c:10 10 int x = 5; Continuing. Program exited normally.
⚠️

Common Pitfalls

  • Setting breakpoints at invalid addresses or symbols will cause errors or no effect.
  • For assembly debugging, use the bkpt instruction carefully; incorrect immediate values may cause unexpected behavior.
  • Remember to continue after hitting a breakpoint, or the program will stay paused.
  • Breakpoints may not work if debugging symbols are missing or optimizations remove code.
plaintext
(gdb) break 0x12345678
No symbol at 0x12345678

# Correct way:
(gdb) break main
Breakpoint 1 at 0x08000100
📊

Quick Reference

CommandDescription
break Set breakpoint at address or function
bkpt Insert breakpoint instruction in assembly
continue (c)Resume program execution
delete Remove a breakpoint
info breakpointsList all breakpoints

Key Takeaways

Use the 'break' command to set breakpoints at functions or addresses in ARM debugger.
The 'bkpt' instruction sets breakpoints in assembly code for low-level debugging.
Always continue execution after hitting a breakpoint to resume the program.
Ensure debugging symbols are present for breakpoints to work correctly.
Use 'delete' to remove breakpoints and 'info breakpoints' to list them.