duckstation icon indicating copy to clipboard operation
duckstation copied to clipboard

Debugger: Add conditional data breakpoints, and a few minor bug fixes

Open mateusfavarin opened this issue 2 years ago • 1 comments

I've implemented conditional data breakpoints for variable memory sizes. Duckstation was storing the address of each breakpoint as the information to check for when an execution breakpoint is valid. I expanded this idea by creating the struct DebugAddress, which encapsulates an address, a size and a debug_mode. The user can create a DebugAddress by adding a breakpoint using the UI, and select multiple conditions for the breakpoint: read, write, changed value or execution.

The execution breakpoint that was implemented on duck had to be modified by adding an extra check for the debug_mode, so only execution breakpoints can trigger that event. The data breakpoint was implemented by adding a function that looks ahead of what the next CPU instruction is going to be, and if the next instruction matches the conditions of any DebugAddress, then the emulation is paused before the CPU executes that instruction. The UI had to be changed in order for the user to create such breakpoints.

A few minor bug fixes unrelated to that:

  • Change breakpoint list ID to reset at 1, just like it's constructed.
  • When a breakpoint is removed, decrement the ID of every other breakpoint with an ID greater than the one that were removed.
  • When breakpoints are cleared, update the breakpoint list UI to give a visual feedback to the user.
  • Fix the breakpoint not disabling when you toggle the checkbox in the breakpoint list.
  • Change instruction format to always display hexadecimal values for consistency, and also change the sll zero, zero to nop.
  • Add the possibility to edit and delete breakpoints by interacting with the mouse in the breakpoint list.

This PR addresses some of the issues mentioned at #2179.

mateusfavarin avatar Aug 03 '21 23:08 mateusfavarin

Thanks! I'll get around to reviewing this soon, super busy with work this week :(

stenzek avatar Aug 04 '21 10:08 stenzek