BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
debuglib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"

Data Structures

struct  toke
struct  trapregs
struct  handlers

Macros

#define sw_goblitz   0xc200 /* switchlib */
#define sw_goamiga   0xc201
#define sw_goqamiga   0xc202
#define sw_goblitzS   0xc206
#define sw_goqamigaS   0xc207

Functions

void donewmode (void)
 $D500 donewmode: nothing.
void dostop (void)
void dosethandler (void)
void dodetoke (void)
void doevaluate (void)
void doexecute (void)
void doquit (void)
void dofindoff (void)
void doskip (void)
void debuglib_docall (void)
 $D509 docall: calls handler 6 of the front end's table.
void debuglib_codeinit (void)
static void codefinit (void)
 Library finit: nothing.
void data (void)
void tasktrap (void)
static void douthandler_c (UBYTE c)
static void dout2_c (UWORD len, const UBYTE *s)
void dout2 (void)
static void dout3_c (const UBYTE *s)
void dout3 (void)
static void amigamode_c (void)
void amigamode (void)
static void fixmode_c (void)
void fixmode (void)
void executestate (void)
static BOOL flagclr (int bit)
static ULONG callhandler (APTR fn, ULONG *arg)
void handleflags (void)
static void codeinit_c (ULONG autorun)
 Library init: resets the debugger state and installs the trap handler.
static void dostop_c (void)
 $D501 dostop: stops the program at the next new line.
static void doevaluate_c (const char *text)
 $D504 doevaluate: evaluates an expression at the next new line.
static void doexecute_c (const char *text)
 $D505 doexecute: executes a line of Blitz code at the next new line.
static void doquit_c (void)
 $D506 doquit: ends the program at the next new line.
static void doskip_c (void)
 $D508 doskip: skips the current statement at the next new line.
static APTR dosethandler_c (UWORD *pflag, const struct handlers *tab)
 $D502 dosethandler: installs the debugger front end's handlers.
static const char * tokename (UWORD token)
static void dodetoke_c (UBYTE **p)
 $D503 dodetoke: detokenises a line (a0 -> a1).
static UWORD dofindoff_c (const UBYTE *s, UWORD pos)
 $D507 dofindoff: converts a position in a tokenised line into the position in the detokenised text.
void printlib_ref (void)

Variables

UBYTE intsoff [2]
UWORD oldmode
volatile UBYTE flags [4]
struct toke * tokens
const char * supertext
const char * usertext
const char * evaltext
const char * exectext
APTR handler
APTR statehandler
APTR superhandler
APTR userhandler
APTR waithandler
APTR evalhandler
APTR h6
APTR h7
UBYTE * procsp
UBYTE procstack []
UBYTE * intsp
UBYTE intstack []
UWORD * procflag
char statehandler_ []
char superhandler_ []
char userhandler_ []
char waithandler_ []
char evalhandler_ []
char mytrap0 []
char mytrap1 []
char mytrap2 []
char mytrap3 []
char mytrap4 []
char mytrap5 []
UWORD dirmode
APTR oldouth
UBYTE astring []
UWORD doutx
APTR oldtc
UWORD waitres
struct trapregs trapregs
UBYTE * trappc
char evaluate_ []
char execute_ []
static const char starttext [] = "Interrupted - program start"

Macro Definition Documentation

◆ sw_goamiga

#define sw_goamiga   0xc201

◆ sw_goblitz

#define sw_goblitz   0xc200 /* switchlib */

◆ sw_goblitzS

#define sw_goblitzS   0xc206

◆ sw_goqamiga

#define sw_goqamiga   0xc202

◆ sw_goqamigaS

#define sw_goqamigaS   0xc207

Function Documentation

◆ amigamode()

void amigamode ( void )

◆ amigamode_c()

void amigamode_c ( void )
static

◆ callhandler()

ULONG callhandler ( APTR fn,
ULONG * arg )
inlinestatic

◆ codefinit()

void codefinit ( void )
static

Library finit: nothing.

The trap handler stays the task's: a SetInt routine can still run until intlib's finit, which comes later (finits go from the low library numbers up), and runerrlib's gosuper hands its traps to the task's handler. runerrlib's finit, the last of them, puts back the handler the program started with. (The original left its handlers in the CPU's vector table for good, #1069.)

◆ codeinit_c()

void codeinit_c ( ULONG autorun)
static

Library init: resets the debugger state and installs the trap handler.

Clears the flags, direct mode and the output redirection, resets the procedure and interrupt stacks and the default handlers, and makes tasktrap the task's trap handler (tc_TrapCode; the old one is kept in oldtc). The editor's token list (tokens) is the task's tc_UserData, which blitz2 sets for the program it runs. With d0.b = 0 the program stops at once ("Interrupted - program start"; the binary, not the source).

Fixed (#1069): the original set the vectors of TRAP #0-#5 in the VBR table (runerrlib getvbr) for the whole machine and took the token list from the old TRAP #1 vector, where blitz2 had put it.

Parameters
autorund0: low byte non zero for auto run, 0 = stop at the first line

◆ data()

void data ( void )

◆ debuglib_codeinit()

void debuglib_codeinit ( void )

◆ debuglib_docall()

void debuglib_docall ( void )

$D509 docall: calls handler 6 of the front end's table.

New in the binary (not in the source). All registers are passed through to the handler and back (a1 = the handler's address).

◆ dodetoke()

void dodetoke ( void )

◆ dodetoke_c()

void dodetoke_c ( UBYTE ** p)
static

$D503 dodetoke: detokenises a line (a0 -> a1).

A byte with bit 7 set starts a token (2 bytes, bit 15 cleared = the number), which is replaced by its name from the editor's token list ("?????" if unknown). Out: a0/a1 behind the terminating 0 (the wrapper passes them in memory: p[0] = a0, p[1] = a1).

Parameters
pa0: p[0] = the tokenised line (a0), p[1] = the destination (a1); both are returned there

◆ doevaluate()

void doevaluate ( void )

◆ doevaluate_c()

void doevaluate_c ( const char * text)
static

$D504 doevaluate: evaluates an expression at the next new line.

Sets the evaluate flag: handleflags runs "Print "+expression with the output going to astring and passes it to the eval handler. All registers kept.

Parameters
texta0: the expression

◆ doexecute()

void doexecute ( void )

◆ doexecute_c()

void doexecute_c ( const char * text)
static

$D505 doexecute: executes a line of Blitz code at the next new line.

Sets the execute flag: handleflags lets the compiler run the text in direct mode and passes any output or error message to the eval handler. All registers kept.

Parameters
texta0: the text to execute

◆ dofindoff()

void dofindoff ( void )

◆ dofindoff_c()

UWORD dofindoff_c ( const UBYTE * s,
UWORD pos )
static

$D507 dofindoff: converts a position in a tokenised line into the position in the detokenised text.

Fixed (#127): the conversion ends when the position reaches 0 or less, also after a token. The original's loop end test (BEQ at 'loop) saw the flags of the last instruction: after a normal character SUBQ #1,d0, after a token SUBQ #1,d1 (the result, not the position); the position was lowered by 2 for a token without a test, so a position right after or inside a token ran on to the end of the string.

Parameters
sa0: the tokenised line
posd0: the position in it (word)
Returns
d0: the position in the detokenised text (word; the thunk writes only the low word of the saved d0)

◆ donewmode()

void donewmode ( void )

$D500 donewmode: nothing.

◆ doquit()

void doquit ( void )

◆ doquit_c()

void doquit_c ( void )
static

$D506 doquit: ends the program at the next new line.

Sets the end flag (handleflags: exitslib's end with the program's a5). Also the default super/user error handlers. All registers kept.

◆ dosethandler()

void dosethandler ( void )

◆ dosethandler_c()

APTR dosethandler_c ( UWORD * pflag,
const struct handlers * tab )
static

$D502 dosethandler: installs the debugger front end's handlers.

C part: copies the table (state, super, user, wait, eval, -, docall, procedure) into the handler variables and remembers the procedure flag word (TRAP #4/#5 call the procedure handler while it is non zero). The assembler wrapper below also returns a0/a1/a2 (the binary, not the source).

Parameters
pflagd0: pointer to the procedure flag word
taba0: the handler table
Returns
d0: the old handler table

◆ doskip()

void doskip ( void )

◆ doskip_c()

void doskip_c ( void )
static

$D508 doskip: skips the current statement at the next new line.

Sets the skip flag: handleflags jumps over the statement if the word at trappc+6 (its distance) is not 0. All registers kept.

◆ dostop()

void dostop ( void )

◆ dostop_c()

void dostop_c ( void )
static

$D501 dostop: stops the program at the next new line.

Sets the user error flag with the text "***** Interupted *****"; all registers kept.

◆ dout2()

void dout2 ( void )

◆ dout2_c()

void dout2_c ( UWORD len,
const UBYTE * s )
static

◆ dout3()

void dout3 ( void )

◆ dout3_c()

void dout3_c ( const UBYTE * s)
static

◆ douthandler_c()

void douthandler_c ( UBYTE c)
static

◆ executestate()

void executestate ( void )

◆ fixmode()

void fixmode ( void )

◆ fixmode_c()

void fixmode_c ( void )
static

◆ flagclr()

BOOL flagclr ( int bit)
inlinestatic

◆ handleflags()

void handleflags ( void )

◆ printlib_ref()

void printlib_ref ( void )

◆ tasktrap()

void tasktrap ( void )

◆ tokename()

const char * tokename ( UWORD token)
static

Variable Documentation

◆ astring

UBYTE astring[]
extern

◆ dirmode

UWORD dirmode
extern

◆ doutx

UWORD doutx
extern

◆ evalhandler

APTR evalhandler

◆ evalhandler_

char evalhandler_[]

◆ evaltext

const char * evaltext

◆ evaluate_

char evaluate_[]
extern

◆ exectext

const char * exectext

◆ execute_

char execute_[]
extern

◆ flags

volatile UBYTE flags[4]
extern

◆ h6

APTR h6
extern

◆ h7

APTR h7

◆ handler

APTR handler
extern

◆ intsoff

UBYTE intsoff[2]
extern

◆ intsp

UBYTE* intsp
extern

◆ intstack

UBYTE intstack[]

◆ mytrap0

char mytrap0[]
extern

◆ mytrap1

char mytrap1[]

◆ mytrap2

char mytrap2[]

◆ mytrap3

char mytrap3[]

◆ mytrap4

char mytrap4[]

◆ mytrap5

char mytrap5[]

◆ oldmode

UWORD oldmode
extern

◆ oldouth

APTR oldouth
extern

◆ oldtc

APTR oldtc
extern

◆ procflag

UWORD* procflag
extern

◆ procsp

UBYTE* procsp
extern

◆ procstack

UBYTE procstack[]

◆ starttext

const char starttext[] = "Interrupted - program start"
static

◆ statehandler

APTR statehandler
extern

◆ statehandler_

char statehandler_[]
extern

◆ superhandler

APTR superhandler

◆ superhandler_

char superhandler_[]

◆ supertext

const char* supertext
extern

◆ tokens

struct toke* tokens
extern

◆ trappc

UBYTE* trappc
extern

◆ trapregs

struct trapregs trapregs
extern

◆ userhandler

APTR userhandler

◆ userhandler_

char userhandler_[]

◆ usertext

const char * usertext

◆ waithandler

APTR waithandler

◆ waithandler_

char waithandler_[]
extern

◆ waitres

UWORD waitres
extern