Skip to content

Commit

Permalink
ATRONIX: Add a /dump-series refinement to STATS
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Oldes committed Sep 21, 2018
1 parent 56a8a67 commit 3b1dc98
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/boot/natives.r
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ stats: native [
/profile {Returns profiler object}
/timer {High resolution time difference from start}
/evals {Number of values evaluated by interpreter}
/dump-series pool-id [integer!] {Dump all series in pool pool-id, -1 for all pools}
]

do-codec: native [
Expand Down
13 changes: 10 additions & 3 deletions src/core/d-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
**
***********************************************************************/

#include <stdio.h>
#include "sys-core.h"


Expand All @@ -49,9 +50,9 @@
SERIES_REST(series),
SERIES_FLAGS(series)
);
if (SERIES_WIDE(series) == sizeof(REBVAL))
if (SERIES_WIDE(series) == sizeof(REBVAL)) {
Dump_Values(BLK_HEAD(series), SERIES_TAIL(series));
else
} else
Dump_Bytes(series->data, (SERIES_TAIL(series)+1) * SERIES_WIDE(series));
}

Expand Down Expand Up @@ -122,6 +123,7 @@

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

*cp++ = ':';
Expand All @@ -137,8 +139,13 @@
cp = Form_Hex_Pad(cp, *bp++, 8);
*cp++ = ' ';
}
n = 0;
if (IS_WORD((REBVAL*)val) || IS_GET_WORD((REBVAL*)val) || IS_SET_WORD((REBVAL*)val)) {
char * name = Get_Word_Name((REBVAL*)val);
n = snprintf(cp, sizeof(buf) - (cp - buf), " (%s)", name);
}

*cp = 0;
*(cp + n) = 0;
Debug_Str(buf);
cp = buf;
}
Expand Down
45 changes: 45 additions & 0 deletions src/core/m-pools.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,51 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
}
}

/***********************************************************************
**
*/ void Dump_Series_In_Pool(int pool_id)
/*
** Dump all series in the pool @pool_id, -1 for all pools
**
***********************************************************************/
{
REBSEG *seg;
REBSER *series;
REBCNT count;
REBCNT n = 0;

for (seg = Mem_Pools[SERIES_POOL].segs; seg; seg = seg->next) {
series = (REBSER *) (seg + 1);
for (count = Mem_Pools[SERIES_POOL].units; count > 0; count--) {
SKIP_WALL(series);
if (!SERIES_FREED(series)) {
if (pool_id < 0 || FIND_POOL(SERIES_TOTAL(series)) == pool_id) {
Debug_Fmt(
Str_Dump[0], //"%s Series %x %s: Wide: %2d Size: %6d - Bias: %d Tail: %d Rest: %d Flags: %x"
"Dump",
series,
(SERIES_LABEL(series) ? SERIES_LABEL(series) : "-"),
SERIES_WIDE(series),
SERIES_TOTAL(series),
SERIES_BIAS(series),
SERIES_TAIL(series),
SERIES_REST(series),
SERIES_FLAGS(series)
);
//Dump_Series(series, "Dump");
if (SERIES_WIDE(series) == sizeof(REBVAL)) {
Debug_Values(BLK_HEAD(series), SERIES_TAIL(series), 1024); /* FIXME limit */
} else{
Dump_Bytes(series->data, (SERIES_TAIL(series)+1) * SERIES_WIDE(series));
}
}
}
series++;
SKIP_WALL(series);
}
}
}


/***********************************************************************
**
Expand Down
6 changes: 6 additions & 0 deletions src/core/n-system.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
return R_RET;
}

if (D_REF(5)) {
REBVAL *pool_id = D_ARG(6);
Dump_Series_In_Pool(VAL_INT32(pool_id));
return R_NONE;
}

if (D_REF(1)) flags = 3;
n = Inspect_Series(flags);

Expand Down

0 comments on commit 3b1dc98

Please sign in to comment.