Skip to content

Commit 3b1dc98

Browse files
committed
ATRONIX: Add a /dump-series refinement to STATS
This is a debugging utility to dump all series in a pool. If the pool id is negative, all series in the system will be dumped >> stats/dump-series -1; dump all series in the system ... >> stats/dump-series 4 ;dump all series in pool 4 ... (cherry picked from commit c986e5a)
1 parent 56a8a67 commit 3b1dc98

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

src/boot/natives.r

+1
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ stats: native [
941941
/profile {Returns profiler object}
942942
/timer {High resolution time difference from start}
943943
/evals {Number of values evaluated by interpreter}
944+
/dump-series pool-id [integer!] {Dump all series in pool pool-id, -1 for all pools}
944945
]
945946

946947
do-codec: native [

src/core/d-dump.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
**
2828
***********************************************************************/
2929

30+
#include <stdio.h>
3031
#include "sys-core.h"
3132

3233

@@ -49,9 +50,9 @@
4950
SERIES_REST(series),
5051
SERIES_FLAGS(series)
5152
);
52-
if (SERIES_WIDE(series) == sizeof(REBVAL))
53+
if (SERIES_WIDE(series) == sizeof(REBVAL)) {
5354
Dump_Values(BLK_HEAD(series), SERIES_TAIL(series));
54-
else
55+
} else
5556
Dump_Bytes(series->data, (SERIES_TAIL(series)+1) * SERIES_WIDE(series));
5657
}
5758

@@ -122,6 +123,7 @@
122123

123124
cp = buf;
124125
for (l = 0; l < count; l++) {
126+
REBVAL *val = (REBVAL*)bp;
125127
cp = Form_Hex_Pad(cp, l, 8);
126128

127129
*cp++ = ':';
@@ -137,8 +139,13 @@
137139
cp = Form_Hex_Pad(cp, *bp++, 8);
138140
*cp++ = ' ';
139141
}
142+
n = 0;
143+
if (IS_WORD((REBVAL*)val) || IS_GET_WORD((REBVAL*)val) || IS_SET_WORD((REBVAL*)val)) {
144+
char * name = Get_Word_Name((REBVAL*)val);
145+
n = snprintf(cp, sizeof(buf) - (cp - buf), " (%s)", name);
146+
}
140147

141-
*cp = 0;
148+
*(cp + n) = 0;
142149
Debug_Str(buf);
143150
cp = buf;
144151
}

src/core/m-pools.c

+45
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,51 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
701701
}
702702
}
703703

704+
/***********************************************************************
705+
**
706+
*/ void Dump_Series_In_Pool(int pool_id)
707+
/*
708+
** Dump all series in the pool @pool_id, -1 for all pools
709+
**
710+
***********************************************************************/
711+
{
712+
REBSEG *seg;
713+
REBSER *series;
714+
REBCNT count;
715+
REBCNT n = 0;
716+
717+
for (seg = Mem_Pools[SERIES_POOL].segs; seg; seg = seg->next) {
718+
series = (REBSER *) (seg + 1);
719+
for (count = Mem_Pools[SERIES_POOL].units; count > 0; count--) {
720+
SKIP_WALL(series);
721+
if (!SERIES_FREED(series)) {
722+
if (pool_id < 0 || FIND_POOL(SERIES_TOTAL(series)) == pool_id) {
723+
Debug_Fmt(
724+
Str_Dump[0], //"%s Series %x %s: Wide: %2d Size: %6d - Bias: %d Tail: %d Rest: %d Flags: %x"
725+
"Dump",
726+
series,
727+
(SERIES_LABEL(series) ? SERIES_LABEL(series) : "-"),
728+
SERIES_WIDE(series),
729+
SERIES_TOTAL(series),
730+
SERIES_BIAS(series),
731+
SERIES_TAIL(series),
732+
SERIES_REST(series),
733+
SERIES_FLAGS(series)
734+
);
735+
//Dump_Series(series, "Dump");
736+
if (SERIES_WIDE(series) == sizeof(REBVAL)) {
737+
Debug_Values(BLK_HEAD(series), SERIES_TAIL(series), 1024); /* FIXME limit */
738+
} else{
739+
Dump_Bytes(series->data, (SERIES_TAIL(series)+1) * SERIES_WIDE(series));
740+
}
741+
}
742+
}
743+
series++;
744+
SKIP_WALL(series);
745+
}
746+
}
747+
}
748+
704749

705750
/***********************************************************************
706751
**

src/core/n-system.c

+6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
return R_RET;
163163
}
164164

165+
if (D_REF(5)) {
166+
REBVAL *pool_id = D_ARG(6);
167+
Dump_Series_In_Pool(VAL_INT32(pool_id));
168+
return R_NONE;
169+
}
170+
165171
if (D_REF(1)) flags = 3;
166172
n = Inspect_Series(flags);
167173

0 commit comments

Comments
 (0)