Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

This PR implements comprehensive hardware breakpoint and watchpoint support across all debug adapters (LLDB, GDB RSP, Esreven, DbgEng), addressing a long-standing feature request with full UI integration.

Key Features

Standardized API

  • Added DebugBreakpointType enum with support for:
    • Software breakpoints (default, unchanged behavior)
    • Hardware execution breakpoints
    • Hardware read watchpoints
    • Hardware write watchpoints
    • Hardware access (read/write) watchpoints
  • New methods: AddHardwareBreakpoint() and RemoveHardwareBreakpoint() with size parameter support

Cross-Adapter Implementation

  • LLDB Adapter: Uses native LLDB hardware breakpoint and watchpoint APIs
  • GDB/Esreven Adapters: Uses GDB RSP protocol commands (Z1-Z4/z1-z4 for different breakpoint types)
  • DbgEng Adapter: Uses WinDbg's ba commands (ba e/r/w/a for execute/read/write/access)
  • Consistent interface across all adapters with proper error handling

Complete UI Integration

  • Hardware Breakpoint Dialog: New HardwareBreakpointDialog with address input, type selection (Execute, Read, Write, Access), size configuration for watchpoints, and contextual help
  • Enhanced Breakpoint List: Added "Type" column showing breakpoint types with color-coded display for better visual distinction
  • Improved Add Breakpoint Menu: Context menu now offers "Software Breakpoint" and "Hardware Breakpoint..." options

Python API Integration

from debugger import DebuggerController, DebugBreakpointType

# Hardware execution breakpoint
controller.add_hardware_breakpoint(0x401000, DebugBreakpointType.HardwareExecuteBreakpoint)

# Hardware write watchpoint (4 bytes)
controller.add_hardware_breakpoint(0x402000, DebugBreakpointType.HardwareWriteBreakpoint, 4)

# Hardware read watchpoint (8 bytes)
controller.add_hardware_breakpoint(0x403000, DebugBreakpointType.HardwareReadBreakpoint, 8)

Backend Command Support

For advanced users, direct backend commands remain available:

# LLDB
controller.send_command("breakpoint set --address 0x401000 -H")
controller.send_command("watchpoint set expression -w write -s 4 -- 0x402000")

# GDB RSP
controller.send_command("Z1,401000,1")  # Hardware execution breakpoint
controller.send_command("Z2,402000,4")  # Hardware write watchpoint

# DbgEng
controller.send_command("ba e1 0x401000")  # Hardware execution breakpoint
controller.send_command("ba w4 0x402000")  # Hardware write watchpoint

Implementation Details

  • Backward Compatibility: Existing software breakpoint functionality unchanged
  • Size Support: Watchpoints support 1, 2, 4, and 8 byte sizes as supported by target hardware
  • Enhanced AddBreakpoint: Existing AddBreakpoint() methods now handle hardware breakpoint types
  • FFI Layer: Full C API support for external integrations
  • UI Enhancement: Breakpoint list now displays type information with visual distinction
  • Documentation: Updated user guide with comprehensive examples and usage patterns

Files Changed

  • Core: debuggercommon.h, debugadapter.h/.cpp, ffi.cpp
  • API: debuggerapi.h, debuggercontroller.cpp, ffi.h
  • Adapters: lldbadapter.h/.cpp, gdbadapter.h/.cpp, esrevenadapter.h/.cpp, dbgengadapter.h/.cpp
  • UI: breakpointswidget.h/.cpp, hardwarebreakpointdialog.h/.cpp
  • Documentation: Updated guide with API examples and usage patterns
  • Examples: Added comprehensive example script demonstrating all functionality

The implementation provides a complete hardware breakpoint solution with intuitive UI integration while maintaining architectural consistency and ensuring all existing functionality continues to work unchanged.

Fixes #53.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Support hardware breakpoint Add comprehensive hardware breakpoint support for all debug adapters Sep 24, 2025
@Copilot Copilot AI requested a review from xusheng6 September 24, 2025 10:48
Copilot finished work on behalf of xusheng6 September 24, 2025 10:48
@xusheng6
Copy link
Member

@copilot

  1. Also add hardware breakpoint support to the DbgEng adapter
  2. Add the UI to add hardware breakpoints
  3. In the breakpoint list, show both hardware and software breakpoints, and add a new column to differentiate them

Copy link
Contributor Author

Copilot AI commented Sep 25, 2025

@copilot

  1. Also add hardware breakpoint support to the DbgEng adapter
    ...

I'll implement these three enhancements:

  1. Adding hardware breakpoint support to the DbgEng adapter using WinDbg's ba command
  2. Adding UI dialogs to set hardware breakpoints with type and size options
  3. Extending the breakpoint list to show breakpoint types with a new "Type" column

Let me implement these changes step by step.

@copilot

  1. Also add hardware breakpoint support to the DbgEng adapter
    ...

I've implemented all three requested enhancements:

1. DbgEng Adapter Hardware Breakpoint Support ✅

Added complete hardware breakpoint support using WinDbg's ba commands:

  • ba e<size> <address>: Hardware execution breakpoints
  • ba r<size> <address>: Hardware read watchpoints
  • ba w<size> <address>: Hardware write watchpoints
  • ba a<size> <address>: Hardware access watchpoints

2. Hardware Breakpoint UI Dialog ✅

Created new HardwareBreakpointDialog with:

  • Address input field (hex format)
  • Breakpoint type dropdown (Execute, Read, Write, Access)
  • Size selection for watchpoints (1, 2, 4, 8 bytes)
  • Contextual help and validation
  • Integration with "Add Breakpoint" menu

3. Enhanced Breakpoint List with Type Column ✅

Extended breakpoint list to show breakpoint types:

  • Added new "Type" column displaying: Software, Hardware Exec, Hardware Read, Hardware Write, Hardware Access
  • Color-coded types for better visual distinction
  • Updated all rendering and data structures

Here are mockups showing the UI enhancements:

Enhanced Breakpoint Widget:
Enhanced Breakpoint Widget

Hardware Breakpoint Dialog:
Hardware Breakpoint Dialog

Key Features:

  • Right-click "Add Breakpoint" now shows submenu with Software/Hardware options
  • Hardware breakpoint dialog provides full control over type and size
  • Breakpoint list clearly shows the type of each breakpoint
  • All adapters (LLDB, GDB RSP, Esreven, DbgEng) now support hardware breakpoints

Commit: 7cb6ddd

@Copilot Copilot AI changed the title Add comprehensive hardware breakpoint support for all debug adapters Add comprehensive hardware breakpoint support for all debug adapters with UI integration Sep 25, 2025
Copilot finished work on behalf of xusheng6 September 25, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support hardware breakpoint
3 participants