haker
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Debugger

WOPR debugger in action.
WOPR debugger in action.

WOPR is an all-in-one CLI executable. One of the commands is to debug an application.

Screen Layout

As you can see above, WOPR debugger is separated into several sections.

Screen is the 80x25 virtual screen where the output of your program will be displayed. WOPR currently implements only monochrome display, which is the one shown here.

Disasmbly shows disassembly of the program. One line in this window is highlighted. Line with the inverted background is the selected line, and you can move selection up or down by pressing j or k keys. Bolded line is the next instruction, i.e. where PC register points to. Any underlined lines are where breakpoints are set.

Memory shows hex and ASCII memory dump. Inverted byte is the selected one. You can move selection by pressing j, k, h and l keys.

ES shows the evaluation stack. RS shows return stack.

Keyboard

Key Action
s step one cpu instruction
r run the program
b toggle breakpoint at the currently selected address
k, j move selection up or down
h, l move selection left or right
H, L select window to the left or right
q quit
~ toggle input mode

Toggling input

By default all keys are used by control the debugger. However, sometimes you will want to send keyboard input to your program. This is done by pressing the ~ to toggle input mode. The input mode behaves differently depending whether the program is currently running.

When in debugging mode, i.e. when program is stopped and you are stepping individual instructions, then pressing ~ will switch to input mode for exactly one key press. So the next key press will be sent verbatim to the WOPR CPU. Then the input will revert accepting debugging commands.

When in running mode, i.e. your program is executing at full speed, most of the debugger commands are disabled. While program is running, input mode is the default mode, so all key presses are sent directly to the running program. To stop the program you should first press ~ switch to the command mode, and then press r to pause program execution and switch to debugging mode.

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. Click to read license.