Skip to content

Commit b7a45ba

Browse files
Copilotxusheng6
andcommitted
Update documentation with hardware breakpoint API usage
Co-authored-by: xusheng6 <[email protected]>
1 parent 8a18bc4 commit b7a45ba

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

docs/guide/index.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,44 @@ dbg.execute_backend_command('image list')
504504

505505
### Hardware Breakpoints/Watchpoints
506506

507-
Hardware breakpoints and watchpoints are very useful and we plan to add better support for it soon. It is tracked by
508-
this [issue](https://github.com/Vector35/debugger/issues/53). For now, we can run a backend command directly to set
509-
hardware breakpoints/watchpoints.
507+
Hardware breakpoints and watchpoints are now supported through both the debugger API and direct backend commands.
508+
509+
#### Using the Debugger API
510+
511+
Hardware breakpoints can be set using the following methods in Python:
512+
513+
```python
514+
from debugger import DebuggerController, DebugBreakpointType
515+
516+
# Get the controller for your binary view
517+
controller = DebuggerController(bv)
518+
519+
# Set hardware execution breakpoint
520+
controller.add_hardware_breakpoint(0x12345678, DebugBreakpointType.HardwareExecuteBreakpoint)
521+
522+
# Set hardware read watchpoint (1 byte)
523+
controller.add_hardware_breakpoint(0x12345678, DebugBreakpointType.HardwareReadBreakpoint, 1)
524+
525+
# Set hardware write watchpoint (4 bytes)
526+
controller.add_hardware_breakpoint(0x12345678, DebugBreakpointType.HardwareWriteBreakpoint, 4)
527+
528+
# Set hardware access (read/write) watchpoint (8 bytes)
529+
controller.add_hardware_breakpoint(0x12345678, DebugBreakpointType.HardwareAccessBreakpoint, 8)
530+
531+
# Remove hardware breakpoint
532+
controller.remove_hardware_breakpoint(0x12345678, DebugBreakpointType.HardwareExecuteBreakpoint)
533+
```
534+
535+
The supported breakpoint types are:
536+
- `SoftwareBreakpoint`: Regular software breakpoint (default)
537+
- `HardwareExecuteBreakpoint`: Hardware execution breakpoint
538+
- `HardwareReadBreakpoint`: Hardware read watchpoint
539+
- `HardwareWriteBreakpoint`: Hardware write watchpoint
540+
- `HardwareAccessBreakpoint`: Hardware read/write watchpoint
541+
542+
#### Using Backend Commands
543+
544+
For cases where you need more control or the API is not available, you can use backend commands directly.
510545

511546
#### WinDbg/DbgEng
512547

0 commit comments

Comments
 (0)