From 3e002e41152bab3fe5f82dbe48cc0e021ef6fd4b Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Wed, 1 Oct 2014 13:31:31 +0200 Subject: [PATCH] Basic breakpoint support. --- docs/index.rst | 91 ++++++++++++++++++++++++++++++++++++++++ py65/monitor.py | 77 ++++++++++++++++++++++++++++++++-- py65/utils/addressing.py | 12 +++++- 3 files changed, 176 insertions(+), 4 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 61244c9..845743f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -103,9 +103,70 @@ Offsets are interpreted like any other numbers. In the example above, ``start+4`` implies that the offset (``4``) uses the default radix. This could also be written as ``start+$04`` for explicit hexadecimal. +Breakpoints +----------- + +It is possible to set breakpoints to stop execution when reaching a +given address or label. Breakpoints are added using the +``add_breakpoint`` command:: + + .disassemble start:start+4 + $ff80 d8 CLD + $ff81 a2 ff LDX #$ff + $ff83 9a TXS + $ff84 a0 1c LDY #$1c + .add_breakpoint $ff84 + Breakpoint 0 added at $FF84 + .goto $ff80 + Breakpoint 0 reached. + PC AC XR YR SP NV-BDIZC + 6502: ff84 00 ff 00 ff 10110000 + +Note that a number is assigned to each breakpoint, similar to how +VICE operates. Deleting a breakpoint can be done via the +``delete_breakpoint`` command using the breakpoint identifier given +by ``add_breakpoint``:: + + .add_breakpoint $ff84 + Breakpoint 0 added at $FF84 + .delete_breakpoint 0 + Breakpoint 0 removed + +Breakpoint can be listed using the ``list_breakpoint`` command:: + + .add_breakpoint $1234 + Breakpoint 0 added at $1234 + .add_breakpoint $5678 + Breakpoint 1 added at $5678 + .add_breakpoint $9ABC + Breakpoint 2 added at $9ABC + .list_breakpoints + Breakpoint 0 : $1234 + Breakpoint 1 : $5678 + Breakpoint 2 : $9ABC + +Keep in mind that breakpoint identifiers are not recycled throughout +a session, this means that if you add three breakpoints (#0, #1, #2) +and then delete breakpoint #1, the next breakpoint you add will be +breakpoint #3, not #1. Also, invoking ``reset`` clears breakpoints +too, not just labels. + Command Reference ================= +.. describe:: add_breakpoint + + Sets a breakpoint on execution at the given address or at the + address represented by the given label:: + + .add_breakpoint $1234 + .add_label f000 start + .add_breakpoint start + + Breakpoints get a numeric identifier to be used with + ``delete_breakpoint``, the list of identifiers can be retrieved + with ``list_breakpoints``. + .. describe:: add_label