1
/*----------------------------------------------------------------------*\
5
Debugger unit in Alan interpreter ARUN
7
\*----------------------------------------------------------------------*/
13
#ifdef HAVE_SHORT_FILENAMES
16
#include "alan.version.h"
41
static void showatrs(atradr)
49
if (atradr == 0) return;
52
for (at = (AtrElem *) addrTo(atradr); !endOfTable(at); at++) {
53
sprintf(str, "$i%3ld: %ld (%s)", (long) i, (unsigned long) at->val, (char *) addrTo(at->stradr));
64
static void showobjs(void)
66
static void showobjs()
73
for (obj = OBJMIN; obj <= OBJMAX; obj++) {
74
sprintf(str, "$i%3ld: ", (long) obj);
86
static void showobj(obj)
91
#define OBJ (obj-OBJMIN)
95
sprintf(str, "Object number out of range. Between %ld and %ld, please.", (unsigned long) OBJMIN, (unsigned long) OBJMAX);
100
sprintf(str, "OBJECT %d :", obj);
104
sprintf(str, "$iLocation = %ld", (unsigned long) where(obj));
106
if (isLoc(objs[OBJ].loc))
108
else if (isCnt(objs[OBJ].loc)) {
109
if (isObj(objs[OBJ].loc)) {
112
} else if (isAct(objs[OBJ].loc)) {
113
output("carried by");
116
interpret(cnts[objs[OBJ].loc-CNTMIN].nam);
117
} else if (objs[OBJ].loc == 0)
120
output("Illegal location!");
123
output("$iAttributes =");
124
showatrs(objs[OBJ].atrs);
131
static void showcnts(void)
133
static void showcnts()
138
#define CNT (cnt-CNTMIN)
140
output("CONTAINERS:");
141
for (cnt = CNTMIN; cnt <= CNTMAX; cnt++) {
142
sprintf(str, "$i%3ld: ", (long) cnt);
144
if (cnts[CNT].nam != 0)
145
interpret(cnts[CNT].nam);
146
if (cnts[CNT].parent != 0)
147
say(cnts[CNT].parent);
159
static void showcnt(cnt)
166
#define CNT (cnt-CNTMIN)
168
if (cnt < CNTMIN || cnt > CNTMAX) {
169
sprintf(str, "Container number out of range. Between %ld and %ld, please.", (unsigned long) CNTMIN, (unsigned long) CNTMAX);
174
sprintf(str, "CONTAINER %d :", cnt);
176
if (cnts[CNT].nam != 0)
177
interpret(cnts[CNT].nam);
178
if (cnts[CNT].parent != 0) {
179
cnt = cnts[CNT].parent;
181
sprintf(str, "$iLocation = %ld", (unsigned long) where(cnt));
184
output("$iContains ");
185
for (i = OBJMIN; i <= OBJMAX; i++) {
186
if (in(i, cnt)) { /* Yes, it's in this container */
191
sprintf(str, "$t$t%d: ", i);
204
static void showlocs(void)
206
static void showlocs()
212
output("LOCATIONS:");
213
for (loc = LOCMIN; loc <= LOCMAX; loc++) {
214
sprintf(str, "$i%3ld: ", (long) loc);
226
static void showloc(loc)
234
sprintf(str, "Location number out of range. Between %ld and %ld, please.", (unsigned long) LOCMIN, (unsigned long) LOCMAX);
239
sprintf(str, "LOCATION %d :", loc);
243
output("$iAttributes =");
244
showatrs(locs[loc-LOCMIN].atrs);
249
static void showacts(void)
251
static void showacts()
258
for (act = ACTMIN; act <= ACTMAX; act++) {
259
sprintf(str, "$i%3ld:", (long) act);
271
static void showact(act)
279
sprintf(str, "Actor number out of range. Between %ld and %ld, please.", (unsigned long) ACTMIN, (unsigned long) ACTMAX);
284
sprintf(str, "ACTOR %d :", act);
286
oldstp = stpflg; stpflg = FALSE; /* Make sure not to trace this! */
290
sprintf(str, "$iLocation = %ld", (unsigned long) acts[act-ACTMIN].loc);
292
if (isLoc(acts[act-ACTMIN].loc))
293
say(acts[act-ACTMIN].loc);
294
else if (acts[act-ACTMIN].loc == 0)
297
output("Illegal location!");
299
sprintf(str, "$iScript = %ld", (unsigned long) acts[act-ACTMIN].script);
302
sprintf(str, "$iStep = %ld", (unsigned long) acts[act-ACTMIN].step);
305
output("$iAttributes =");
306
showatrs(acts[act-ACTMIN].atrs);
311
static void showevts(void)
313
static void showevts()
321
for (evt = EVTMIN; evt <= EVTMAX; evt++) {
322
sprintf(str, "$i%d (%s):", evt, (char *)addrTo(evts[evt-EVTMIN].stradr));
328
for (i = 0; i < etop; i++)
329
if ((scheduled = (eventq[i].event == evt)))
332
sprintf(str, "Scheduled for +%d, at ", eventq[i].time-cur.tick);
334
say(eventq[i].where);
336
output("Not scheduled.");
341
static Boolean trc, stp;
350
/* Save some important things */
351
trc = trcflg; trcflg = FALSE;
352
stp = stpflg; stpflg = FALSE;
353
loc = cur.loc; cur.loc = where(HERO);
357
void restoreInfo(void)
386
(void) readline(buf);
388
fgets(buf, 255, stdin);
393
sscanf(&buf[1], "%d", &i);
394
} while (buf && c == '\0');
396
switch (toUpper(c)) {
399
output(alan.longHeader);
400
output("$nABUG Commands:\
401
$iO [n] -- show object[s]\
402
$iA [n] -- show actor[s]\
403
$iL [n] -- show location[s]\
404
$iC [n] -- show container[s]\
407
$iT -- toggle trace mode\
408
$iS -- toggle step mode\
409
$iX -- exit debug mode\
415
dbgflg = FALSE; /* Fall through to 'G' */
456
printf("Trace off.");
459
output("Unknown ABUG command. ? for help.");
466
/*======================================================================
470
Say somethin, but make sure we don't disturb anything and that it is
475
void debugsay(int item)