Skip to content

Commit f2bf026

Browse files
committed
Adds URaid F command to print array block free list heads
1 parent 3fad090 commit f2bf026

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

inc/gcfinaldefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define GCFINALDEFS_H 1
33
#include "lispemul.h" /* for LispPTR, DLword */
44
void printarrayblock(LispPTR base);
5+
void printfreeblockchainn(int arlen);
56
LispPTR releasingvmempage(LispPTR ptr);
67
LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist);
78
LispPTR makefreearrayblock(LispPTR block, DLword length);

src/gcfinal.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,3 +610,30 @@ void printarrayblock(LispPTR base) {
610610
addr++;
611611
for (; addr < (LispPTR *)trailer_np + 20; addr++) printf("%16p (0x%8x) %8x\n", (void *)addr, LAddrFromNative(addr), *addr);
612612
}
613+
614+
static void printfreeblockchainhead(int index)
615+
{
616+
LispPTR fbl, freeblock;
617+
LispPTR *fbl_np;
618+
619+
fbl = POINTERMASK & ((*FreeBlockBuckets_word) + (DLWORDSPER_CELL * index));
620+
fbl_np = (LispPTR *)NativeAligned4FromLAddr(fbl);
621+
/* lisp pointer to free block on chain */
622+
freeblock = POINTERMASK & (*fbl_np);
623+
if (freeblock == NIL) { /* no blocks in chain */
624+
printf("Free block chain (bucket %d): NIL\n", index);
625+
} else {
626+
printf("Free block chain(bucket %d): 0x%x\n", index, freeblock);
627+
}
628+
}
629+
630+
void printfreeblockchainn(int arlen)
631+
{
632+
if (arlen >= 0) {
633+
printfreeblockchainhead(BucketIndex(arlen));
634+
return;
635+
} else
636+
for (int i = 0; i <= MAXBUCKETINDEX; i++) {
637+
printfreeblockchainhead(i);
638+
}
639+
}

src/uraid.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ static const char *URaid_summary2 =
168168
"\n-- Memory display commands\n\
169169
a litatom\t\tDisplays the top-level value of the litatom\n\
170170
B Xaddress\t\tPrint the contents of the arrayblock at that address.\n\
171+
F [size]\t\tPrint the head of the array free list chain for given size, or all\n\
171172
d litatom\t\tDisplays the definition cell for the litatom\n\
172173
M\t\t\tDisplays TOS,CSP,PVAR,IVAR,PC\n\
173174
m func1 func2\t\tMOVD func1 to func2\n\
@@ -201,6 +202,7 @@ l [type]\t\tDisplays backtrace for specified type of stack. (k|m|r|g|p|u|<null>)
201202
\n-- Memory display commands\n\
202203
a litatom\t\tDisplays the top-level value of the litatom\n\
203204
B Xaddress\t\tDisplays the contents of the arrayblock at that address.\n\
205+
F [size]\t\tPrint the head of the array free list chain for given size, or all\n\
204206
d litatom\t\tDisplays the definition cell of the litatom\n\
205207
M\t\t\tDisplays TOS,CSP,PVAR,IVAR,PC\n\
206208
m func1 func2\t\tMoves definition of func1 to func2 (MOVD)\n\
@@ -467,6 +469,26 @@ LispPTR uraid_commands(void) {
467469
}
468470
break;
469471

472+
case 'F': { /* print array block free list head(s) */
473+
long size;
474+
if (URaid_argnum != 1 && URaid_argnum != 2) {
475+
printf("FREE-BLOCK-CHAIN: F [block-size (cells)]\n");
476+
return (T);
477+
}
478+
if (URaid_argnum == 1) {
479+
size = -1;
480+
} else {
481+
errno = 0;
482+
size = (LispPTR)strtol(URaid_arg1, &endpointer, 0);
483+
if (errno != 0 || *endpointer != '\0') {
484+
printf("Arg not number\n");
485+
return (T);
486+
}
487+
}
488+
printfreeblockchainn(size);
489+
}
490+
break;
491+
470492
case 'd': /* DEFCELL */
471493
if (URaid_argnum != 2) {
472494
printf("GETD: d litatom\n");

0 commit comments

Comments
 (0)