Debugger for Rex 6000 V1.0

This is a package which provides a simple debugger for Rex addins.

Installation

Copyright (C) 2002 Graham R. Cobb. The package is distributed under the GPL (see the copyright notices and the COPYING file).

Debugger For Rex 6000 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Debugger For Rex 6000 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The Debugger distribution contains three main files in the top level directory (as well as sources and some informational files):

The package also contains the source for the Debugger.

Documentation

For Debugger Version 1.0.

Calling the debugger

It is not possible to set breakpoints using this debugger. The debugger is accessed by putting calls to debugger traps in the addin being debugged. These calls may be conditional (e.g. on some error condition) or may be unconditional (so the debugger is always invoked at that point).

The debugger traps are functions which can be called from C or assembler code. They are designed to take up as little code space as possible, although the basic form (dbgtrap()) will take the least code space to call.

The three forms of the trap are:

The smallest call, from C code, is as follows:

#asm
	call dbgtrap
#endasm

If the debugger addin is not loaded, the trap will continue automatically.

Prototypes

unsigned short dbgtrap(void);
unsigned short dbgtrap_n(int a, int b, int c);
unsigned short dbgtrap_s(unsigned char *s, int b, int c);

Parameters

The dbgtrap_n form takes three integers as parameters. These are displayed at the top of the debugger screen and are useful for displaying addresses of data, numeric values or codes to indicate the breakpoint which has been trapped.

The dbgtrap_s form takes a string and two integers as parameters. These are also displayed at the top of the debugger screen.

Return Value

Whatever value the user puts (or leaves) in HL before continuing from the debugger.

Using the debugger

Entry

The debugger is entered either by an addin calling one of the traps described above or by running the debugger addin itself. The debugger addin effectively consists of a loop which calls a debugger trap and then waits for a button press before calling the trap again. The HOME button exists from this loop.

Debugger screen

When the debugger is entered, the screen is cleared (the previous screen display is lost). The debugger screen shows an entry line at the top of the screen. This shows the parameters from the trap, if any.

The next 4 lines show the CPU registers at the time of the trap: A, F, BC, DE, HL, A', F', BC', DE', HL', IX, IY, Bank1, Bank2 and PC.

The next line shows the stack pointer and the top 6 words of the stack.

The next two lines show memory contents (as ASCII and as Hex). The first two fields of line 8 are the bank number and offset of the memory location to be examined. Bank 0 is interpreted to mean the address space of the caller. So 00: 8000: means the first byte of the addin code and 00: A000: is the memory mapped by the Bank 2 register.

Modifying registers and memory

Any of the registers or memory locations can be modified by touching the numeric value on the screen. This will bring up a keyboard which can be used to enter the new value in hex.

Touching the first two fields in line 8 (the memory display) allows you to specify a different bank or offset to display. Touching the other fields in that line allows you to modify memory (if it is writeable).

Changes to the stack pointer (SP) cause the stack display to change but do not cause the caller's stack pointer to change.

All other register changes (including PC) are reflected in the caller, when it resumes. Note that because of the way the C compiler calls external routines, most register changes will be ignored, except for the PC and HL. The value of HL appears as the return value of the trap function.

Buttons

The buttons have the following effect:

When the BACK button is used to continue execution, all registers are restored to the values appearing on the screen except SP (which is not modified). The screen is cleared (DsClearScreen()) and all events are cleared (DsEventClear()).

Changes

In version 1.0

First release.


Return to Graham's Rex page

This page has been accessed Access counter times.

Graham Cobb