mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-26 16:51:46 -07:00
Correct indentation of describe output by passing depth parameter to describe functions and to writef.
Call Describe functions from test cases so that we get coverage. Copied from Perforce Change: 186000 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
4ed8190265
commit
c44f2d6a20
61 changed files with 554 additions and 545 deletions
|
|
@ -156,7 +156,7 @@ Bool ABQPeek(ABQ abq, void *elementReturn)
|
|||
|
||||
|
||||
/* ABQDescribe -- Describe an ABQ */
|
||||
Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream)
|
||||
Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Index index;
|
||||
|
|
@ -164,8 +164,8 @@ Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *strea
|
|||
if (!TESTT(ABQ, abq)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
"ABQ $P\n{\n", (WriteFP)abq,
|
||||
res = WriteF(depth, stream,
|
||||
"ABQ $P {\n", (WriteFP)abq,
|
||||
" elements: $U \n", (WriteFU)abq->elements,
|
||||
" in: $U \n", (WriteFU)abq->in,
|
||||
" out: $U \n", (WriteFU)abq->out,
|
||||
|
|
@ -175,22 +175,18 @@ Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *strea
|
|||
return res;
|
||||
|
||||
for (index = abq->out; index != abq->in; ) {
|
||||
res = (*describeElement)(ABQElement(abq, index), stream);
|
||||
res = (*describeElement)(ABQElement(abq, index), stream, depth + 2);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
index = ABQNextIndex(abq, index);
|
||||
}
|
||||
|
||||
res = WriteF(stream, "\n", NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
METER_WRITE(abq->push, stream, depth + 2);
|
||||
METER_WRITE(abq->pop, stream, depth + 2);
|
||||
METER_WRITE(abq->peek, stream, depth + 2);
|
||||
METER_WRITE(abq->delete, stream, depth + 2);
|
||||
|
||||
METER_WRITE(abq->push, stream);
|
||||
METER_WRITE(abq->pop, stream);
|
||||
METER_WRITE(abq->peek, stream);
|
||||
METER_WRITE(abq->delete, stream);
|
||||
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} ABQ $P\n", (WriteFP)abq, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
/* Prototypes */
|
||||
|
||||
typedef struct ABQStruct *ABQ;
|
||||
typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream);
|
||||
typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream, Count depth);
|
||||
typedef Bool (*ABQIterateMethod)(Bool *deleteReturn, void *element, void *closureP, Size closureS);
|
||||
|
||||
extern Res ABQInit(Arena arena, ABQ abq, void *owner, Count elements, Size elementSize);
|
||||
|
|
@ -32,7 +32,7 @@ extern void ABQFinish(Arena arena, ABQ abq);
|
|||
extern Bool ABQPush(ABQ abq, void *element);
|
||||
extern Bool ABQPop(ABQ abq, void *elementReturn);
|
||||
extern Bool ABQPeek(ABQ abq, void *elementReturn);
|
||||
extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream);
|
||||
extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream, Count depth);
|
||||
extern Bool ABQIsEmpty(ABQ abq);
|
||||
extern Bool ABQIsFull(ABQ abq);
|
||||
extern Count ABQDepth(ABQ abq);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "fmtdy.h"
|
||||
#include "fmtdytst.h"
|
||||
#include "testlib.h"
|
||||
#include "mpm.h"
|
||||
#include "mpslib.h"
|
||||
#include "mpscamc.h"
|
||||
#include "mpsavm.h"
|
||||
|
|
@ -274,6 +275,8 @@ static void test(mps_arena_t arena, mps_class_t pool_class, size_t roots_count)
|
|||
++objs;
|
||||
}
|
||||
|
||||
die(ArenaDescribe(arena, mps_lib_get_stdout(), 0), "PoolDescribe");
|
||||
|
||||
(void)mps_commit(busy_ap, busy_init, 64);
|
||||
mps_ap_destroy(busy_ap);
|
||||
mps_ap_destroy(ap);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "mpsavm.h"
|
||||
#include "mpstd.h"
|
||||
#include "mps.h"
|
||||
#include "mpm.h"
|
||||
|
||||
#include <stdio.h> /* fflush, printf */
|
||||
|
||||
|
|
@ -141,6 +142,8 @@ static void *test(void *arg, size_t haveAmbigous)
|
|||
/* create an ap, and leave it busy */
|
||||
die(mps_reserve(&busy_init, busy_ap, 64), "mps_reserve busy");
|
||||
|
||||
die(PoolDescribe(pool, mps_lib_get_stdout(), 0), "PoolDescribe");
|
||||
|
||||
objs = 0; totalSize = 0;
|
||||
while(totalSize < totalSizeMAX) {
|
||||
if (totalSize > lastStep + totalSizeSTEP) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static void arenaFreePage(Arena arena, Addr base, Pool pool);
|
|||
|
||||
/* ArenaTrivDescribe -- produce trivial description of an arena */
|
||||
|
||||
static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream)
|
||||
static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
if (!TESTT(Arena, arena)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
|
@ -47,8 +47,8 @@ static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream)
|
|||
* subclass describe method should avoid invoking
|
||||
* ARENA_SUPERCLASS()->describe. RHSK 2007-04-27.
|
||||
*/
|
||||
return WriteF(stream,
|
||||
" No class-specific description available.\n", NULL);
|
||||
return WriteF(depth, stream,
|
||||
" No class-specific description available.\n", NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ void ControlFinish(Arena arena)
|
|||
|
||||
/* ArenaDescribe -- describe the arena */
|
||||
|
||||
Res ArenaDescribe(Arena arena, mps_lib_FILE *stream)
|
||||
Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Size reserved;
|
||||
|
|
@ -436,58 +436,57 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream)
|
|||
if (!TESTT(Arena, arena)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream, "Arena $P {\n", (WriteFP)arena,
|
||||
res = WriteF(depth, stream, "Arena $P {\n", (WriteFP)arena,
|
||||
" class $P (\"$S\")\n",
|
||||
(WriteFP)arena->class, arena->class->name,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
if (arena->poolReady) {
|
||||
res = WriteF(stream,
|
||||
" controlPool $P\n", (WriteFP)&arena->controlPoolStruct,
|
||||
res = WriteF(depth + 2, stream,
|
||||
"controlPool $P\n", (WriteFP)&arena->controlPoolStruct,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
/* Note: this Describe clause calls a function */
|
||||
reserved = ArenaReserved(arena);
|
||||
res = WriteF(stream,
|
||||
" reserved $W <-- "
|
||||
res = WriteF(depth + 2, stream,
|
||||
"reserved $W <-- "
|
||||
"total size of address-space reserved\n",
|
||||
(WriteFW)reserved,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" committed $W <-- "
|
||||
res = WriteF(depth + 2, stream,
|
||||
"committed $W <-- "
|
||||
"total bytes currently stored (in RAM or swap)\n",
|
||||
(WriteFW)arena->committed,
|
||||
" commitLimit $W\n", (WriteFW)arena->commitLimit,
|
||||
" spareCommitted $W\n", (WriteFW)arena->spareCommitted,
|
||||
" spareCommitLimit $W\n", (WriteFW)arena->spareCommitLimit,
|
||||
" zoneShift $U\n", (WriteFU)arena->zoneShift,
|
||||
" alignment $W\n", (WriteFW)arena->alignment,
|
||||
"commitLimit $W\n", (WriteFW)arena->commitLimit,
|
||||
"spareCommitted $W\n", (WriteFW)arena->spareCommitted,
|
||||
"spareCommitLimit $W\n", (WriteFW)arena->spareCommitLimit,
|
||||
"zoneShift $U\n", (WriteFU)arena->zoneShift,
|
||||
"alignment $W\n", (WriteFW)arena->alignment,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" droppedMessages $U$S\n", (WriteFU)arena->droppedMessages,
|
||||
res = WriteF(depth + 2, stream,
|
||||
"droppedMessages $U$S\n", (WriteFU)arena->droppedMessages,
|
||||
(arena->droppedMessages == 0 ? "" : " -- MESSAGES DROPPED!"),
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = (*arena->class->describe)(arena, stream);
|
||||
res = (*arena->class->describe)(arena, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
/* Do not call GlobalsDescribe: it makes too much output, thanks.
|
||||
* RHSK 2007-04-27
|
||||
*/
|
||||
#if 0
|
||||
res = GlobalsDescribe(ArenaGlobals(arena), stream);
|
||||
res = WriteF(depth + 2, stream, "Globals {\n", NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = GlobalsDescribe(ArenaGlobals(arena), stream, depth + 4);
|
||||
if (res != ResOK) return res;
|
||||
#endif
|
||||
res = WriteF(depth + 2, stream, "} Globals\n", NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"} Arena $P ($U)\n", (WriteFP)arena,
|
||||
(WriteFU)arena->serial,
|
||||
NULL);
|
||||
|
|
@ -497,7 +496,7 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream)
|
|||
|
||||
/* ArenaDescribeTracts -- describe all the tracts in the arena */
|
||||
|
||||
Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream)
|
||||
Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Tract tract;
|
||||
|
|
@ -516,7 +515,7 @@ Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream)
|
|||
size = ArenaAlign(arena);
|
||||
|
||||
if (TractBase(tract) > oldLimit) {
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"[$P, $P) $W $U ---\n",
|
||||
(WriteFP)oldLimit, (WriteFP)base,
|
||||
(WriteFW)AddrOffset(oldLimit, base),
|
||||
|
|
@ -525,7 +524,7 @@ Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream)
|
|||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"[$P, $P) $W $U $P ($S)\n",
|
||||
(WriteFP)base, (WriteFP)limit,
|
||||
(WriteFW)size, (WriteFW)size,
|
||||
|
|
@ -586,14 +585,14 @@ void ControlFree(Arena arena, void* base, size_t size)
|
|||
|
||||
/* ControlDescribe -- describe the arena's control pool */
|
||||
|
||||
Res ControlDescribe(Arena arena, mps_lib_FILE *stream)
|
||||
Res ControlDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Arena, arena)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = PoolDescribe(ArenaControlPool(arena), stream);
|
||||
res = PoolDescribe(ArenaControlPool(arena), stream, depth);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,6 @@ static void testAllocAndIterate(Arena arena, Pool pool,
|
|||
}
|
||||
SegPrefExpress(&pref, SegPrefZoneSet, &zone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -363,6 +362,10 @@ static void testPageTable(ArenaClass class, Size size, Addr addr, Bool zoned)
|
|||
testAllocAndIterate(arena, pool, pageSize, tractsPerPage,
|
||||
&allocatorSegStruct);
|
||||
|
||||
die(ArenaDescribe(arena, mps_lib_get_stdout(), 0), "ArenaDescribe");
|
||||
die(ArenaDescribeTracts(arena, mps_lib_get_stdout(), 0),
|
||||
"ArenaDescribeTracts");
|
||||
|
||||
PoolDestroy(pool);
|
||||
ArenaDestroy(arena);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ static Bool VMArenaCheck(VMArena vmArena)
|
|||
|
||||
/* VMArenaDescribe -- describe the VMArena
|
||||
*/
|
||||
static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream)
|
||||
static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
VMArena vmArena;
|
||||
|
|
@ -204,7 +204,7 @@ static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream)
|
|||
*
|
||||
*/
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
" spareSize: $U\n", (WriteFU)vmArena->spareSize,
|
||||
NULL);
|
||||
if(res != ResOK)
|
||||
|
|
|
|||
|
|
@ -146,14 +146,14 @@ Bool BufferCheck(Buffer buffer)
|
|||
*
|
||||
* See <code/mpmst.h> for structure definitions. */
|
||||
|
||||
Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream)
|
||||
Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Buffer, buffer)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Buffer $P ($U) {\n",
|
||||
(WriteFP)buffer, (WriteFU)buffer->serial,
|
||||
" class $P (\"$S\")\n",
|
||||
|
|
@ -178,10 +178,10 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = buffer->class->describe(buffer, stream);
|
||||
res = buffer->class->describe(buffer, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream, "} Buffer $P ($U)\n",
|
||||
res = WriteF(depth, stream, "} Buffer $P ($U)\n",
|
||||
(WriteFP)buffer, (WriteFU)buffer->serial,
|
||||
NULL);
|
||||
return res;
|
||||
|
|
@ -1164,10 +1164,11 @@ static void bufferNoReassignSeg(Buffer buffer, Seg seg)
|
|||
|
||||
/* bufferTrivDescribe -- basic Buffer describe method */
|
||||
|
||||
static Res bufferTrivDescribe(Buffer buffer, mps_lib_FILE *stream)
|
||||
static Res bufferTrivDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
if (!TESTT(Buffer, buffer)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
UNUSED(depth);
|
||||
/* dispatching function does it all */
|
||||
return ResOK;
|
||||
}
|
||||
|
|
@ -1422,7 +1423,7 @@ static void segBufReassignSeg (Buffer buffer, Seg seg)
|
|||
|
||||
/* segBufDescribe -- describe method for SegBuf */
|
||||
|
||||
static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream)
|
||||
static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
SegBuf segbuf;
|
||||
BufferClass super;
|
||||
|
|
@ -1435,12 +1436,12 @@ static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream)
|
|||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
super = BUFFER_SUPERCLASS(SegBufClass);
|
||||
res = super->describe(buffer, stream);
|
||||
res = super->describe(buffer, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" Seg $P\n", (WriteFP)segbuf->seg,
|
||||
" rankSet $U\n", (WriteFU)segbuf->rankSet,
|
||||
res = WriteF(depth, stream,
|
||||
"Seg $P\n", (WriteFP)segbuf->seg,
|
||||
"rankSet $U\n", (WriteFU)segbuf->rankSet,
|
||||
NULL);
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ static Res cbsBlockDescribe(CBSBlock block, mps_lib_FILE *stream)
|
|||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(0, stream,
|
||||
"[$P,$P) {$U, $B}",
|
||||
(WriteFP)block->base,
|
||||
(WriteFP)block->limit,
|
||||
|
|
@ -1055,7 +1055,7 @@ Bool CBSFindLargest(Range rangeReturn, Range oldRangeReturn,
|
|||
* See <design/cbs/#function.cbs.describe>.
|
||||
*/
|
||||
|
||||
Res CBSDescribe(CBS cbs, mps_lib_FILE *stream)
|
||||
Res CBSDescribe(CBS cbs, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
|
|
@ -1064,7 +1064,7 @@ Res CBSDescribe(CBS cbs, mps_lib_FILE *stream)
|
|||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"CBS $P {\n", (WriteFP)cbs,
|
||||
" alignment: $U\n", (WriteFU)cbs->alignment,
|
||||
" blockPool: $P\n", (WriteFP)cbsBlockPool(cbs),
|
||||
|
|
@ -1074,12 +1074,13 @@ Res CBSDescribe(CBS cbs, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = SplayTreeDescribe(cbsSplay(cbs), stream, &cbsSplayNodeDescribe);
|
||||
METER_WRITE(cbs->treeSearch, stream, depth + 2);
|
||||
|
||||
res = SplayTreeDescribe(cbsSplay(cbs), stream, depth + 2,
|
||||
&cbsSplayNodeDescribe);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
METER_WRITE(cbs->treeSearch, stream);
|
||||
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} CBS $P\n", (WriteFP)cbs, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ extern Res CBSDelete(Range rangeReturn, CBS cbs, Range range);
|
|||
extern void CBSIterate(CBS cbs, CBSVisitor visitor,
|
||||
void *closureP, Size closureS);
|
||||
|
||||
extern Res CBSDescribe(CBS cbs, mps_lib_FILE *stream);
|
||||
extern Res CBSDescribe(CBS cbs, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
typedef Bool (*CBSFindMethod)(Range rangeReturn, Range oldRangeReturn,
|
||||
CBS cbs, Size size, FindDelete findDelete);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ typedef struct mps_chain_s {
|
|||
} ChainStruct;
|
||||
|
||||
|
||||
extern Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream);
|
||||
extern Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
extern Res ChainCreate(Chain *chainReturn, Arena arena, size_t genCount,
|
||||
GenParamStruct *params);
|
||||
|
|
@ -90,14 +90,14 @@ extern size_t ChainGens(Chain chain);
|
|||
extern Res ChainAlloc(Seg *segReturn, Chain chain, Serial genNr,
|
||||
SegClass class, Size size, Pool pool,
|
||||
Bool withReservoirPermit, ArgList args);
|
||||
extern Res ChainDescribe(Chain chain, mps_lib_FILE *stream);
|
||||
extern Res ChainDescribe(Chain chain, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
extern Bool PoolGenCheck(PoolGen gen);
|
||||
extern Res PoolGenInit(PoolGen gen, Chain chain, Serial nr, Pool pool);
|
||||
extern void PoolGenFinish(PoolGen gen);
|
||||
extern void PoolGenFlip(PoolGen gen);
|
||||
#define PoolGenNr(gen) ((gen)->nr)
|
||||
extern Res PoolGenDescribe(PoolGen gen, mps_lib_FILE *stream);
|
||||
extern Res PoolGenDescribe(PoolGen gen, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
|
||||
#endif /* chain_h */
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ typedef union EventClockUnion {
|
|||
(*(EventClockUnion *)&(clock)).half.high, \
|
||||
(*(EventClockUnion *)&(clock)).half.low)
|
||||
|
||||
#define EVENT_CLOCK_WRITE(stream, clock) \
|
||||
WriteF(stream, "$W$W", \
|
||||
#define EVENT_CLOCK_WRITE(depth, stream, clock) \
|
||||
WriteF(depth, stream, "$W$W", \
|
||||
(*(EventClockUnion *)&(clock)).half.high, \
|
||||
(*(EventClockUnion *)&(clock)).half.low, \
|
||||
NULL)
|
||||
|
|
@ -86,8 +86,8 @@ typedef union EventClockUnion {
|
|||
|
||||
#endif
|
||||
|
||||
#define EVENT_CLOCK_WRITE(stream, clock) \
|
||||
WriteF(stream, "$W", (WriteFW)(clock), NULL)
|
||||
#define EVENT_CLOCK_WRITE(depth, stream, clock) \
|
||||
WriteF(depth, stream, "$W", (WriteFW)(clock), NULL)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -136,8 +136,8 @@ __extension__ typedef unsigned long long EventClock;
|
|||
(unsigned long)((clock) >> 32), \
|
||||
(unsigned long)((clock) & 0xffffffff))
|
||||
|
||||
#define EVENT_CLOCK_WRITE(stream, clock) \
|
||||
WriteF(stream, "$W$W", (WriteFW)((clock) >> 32), (WriteFW)clock, NULL)
|
||||
#define EVENT_CLOCK_WRITE(depth, stream, clock) \
|
||||
WriteF(depth, stream, "$W$W", (WriteFW)((clock) >> 32), (WriteFW)clock, NULL)
|
||||
|
||||
#endif /* Intel, GCC or Clang */
|
||||
|
||||
|
|
@ -154,8 +154,8 @@ typedef mps_clock_t EventClock;
|
|||
#define EVENT_CLOCK_PRINT(stream, clock) \
|
||||
fprintf(stream, "%lu", (unsigned long)clock)
|
||||
|
||||
#define EVENT_CLOCK_WRITE(stream, clock) \
|
||||
WriteF(stream, "$W", (WriteFW)clock, NULL)
|
||||
#define EVENT_CLOCK_WRITE(depth, stream, clock) \
|
||||
WriteF(depth, stream, "$W", (WriteFW)clock, NULL)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ void EventLabelAddr(Addr addr, EventStringId id)
|
|||
" $U", (WriteFU)event->name.f##index,
|
||||
|
||||
|
||||
Res EventDescribe(Event event, mps_lib_FILE *stream)
|
||||
Res EventDescribe(Event event, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
|
|
@ -329,14 +329,14 @@ Res EventDescribe(Event event, mps_lib_FILE *stream)
|
|||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Event $P {\n", (WriteFP)event,
|
||||
" code $U\n", (WriteFU)event->any.code,
|
||||
" clock ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = EVENT_CLOCK_WRITE(stream, event->any.clock);
|
||||
res = EVENT_CLOCK_WRITE(depth, stream, event->any.clock);
|
||||
if (res != ResOK) return res;
|
||||
res = WriteF(stream, "\n size $U\n", (WriteFU)event->any.size, NULL);
|
||||
res = WriteF(depth, stream, "\n size $U\n", (WriteFU)event->any.size, NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
switch (event->any.code) {
|
||||
|
|
@ -347,7 +347,7 @@ Res EventDescribe(Event event, mps_lib_FILE *stream)
|
|||
|
||||
#define EVENT_DESC(X, name, _code, always, kind) \
|
||||
case _code: \
|
||||
res = WriteF(stream, \
|
||||
res = WriteF(depth, stream, \
|
||||
" event \"$S\"", (WriteFS)#name, \
|
||||
EVENT_##name##_PARAMS(EVENT_DESC_PARAM, name) \
|
||||
NULL); \
|
||||
|
|
@ -357,13 +357,13 @@ Res EventDescribe(Event event, mps_lib_FILE *stream)
|
|||
EVENT_LIST(EVENT_DESC, X)
|
||||
|
||||
default:
|
||||
res = WriteF(stream, " event type unknown", NULL);
|
||||
res = WriteF(depth, stream, " event type unknown", NULL);
|
||||
if (res != ResOK) return res;
|
||||
/* TODO: Hexdump unknown event contents. */
|
||||
break;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"\n} Event $P\n", (WriteFP)event,
|
||||
NULL);
|
||||
return res;
|
||||
|
|
@ -377,7 +377,7 @@ Res EventWrite(Event event, mps_lib_FILE *stream)
|
|||
if (event == NULL) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = EVENT_CLOCK_WRITE(stream, event->any.clock);
|
||||
res = EVENT_CLOCK_WRITE(0, stream, event->any.clock);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ Res EventWrite(Event event, mps_lib_FILE *stream)
|
|||
|
||||
#define EVENT_WRITE(X, name, code, always, kind) \
|
||||
case code: \
|
||||
res = WriteF(stream, " $S", #name, \
|
||||
res = WriteF(0, stream, " $S", #name, \
|
||||
EVENT_##name##_PARAMS(EVENT_WRITE_PARAM, name) \
|
||||
NULL); \
|
||||
if (res != ResOK) return res; \
|
||||
|
|
@ -396,7 +396,7 @@ Res EventWrite(Event event, mps_lib_FILE *stream)
|
|||
EVENT_LIST(EVENT_WRITE, X)
|
||||
|
||||
default:
|
||||
res = WriteF(stream, " <unknown code $U>", event->any.code, NULL);
|
||||
res = WriteF(0, stream, " <unknown code $U>", event->any.code, NULL);
|
||||
if (res != ResOK) return res;
|
||||
/* TODO: Hexdump unknown event contents. */
|
||||
break;
|
||||
|
|
@ -416,7 +416,7 @@ void EventDump(mps_lib_FILE *stream)
|
|||
/* This can happen if there's a backtrace very early in the life of
|
||||
the MPS, and will cause an access violation if we continue. */
|
||||
if (!eventInited) {
|
||||
(void)WriteF(stream, "No events\n", NULL);
|
||||
(void)WriteF(0, stream, "No events\n", NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ void EventDump(mps_lib_FILE *stream)
|
|||
/* Try to keep going even if there's an error, because this is used as a
|
||||
backtrace and we'll take what we can get. */
|
||||
(void)EventWrite(event, stream);
|
||||
(void)WriteF(stream, "\n", NULL);
|
||||
(void)WriteF(0, stream, "\n", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ void EventLabelAddr(Addr addr, Word id)
|
|||
}
|
||||
|
||||
|
||||
Res EventDescribe(Event event, mps_lib_FILE *stream)
|
||||
Res EventDescribe(Event event, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
UNUSED(event);
|
||||
UNUSED(stream);
|
||||
|
|
@ -498,7 +498,7 @@ Res EventDescribe(Event event, mps_lib_FILE *stream)
|
|||
}
|
||||
|
||||
|
||||
Res EventWrite(Event event, mps_lib_FILE *stream)
|
||||
Res EventWrite(Event event, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
UNUSED(event);
|
||||
UNUSED(stream);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ extern EventStringId EventInternString(const char *label);
|
|||
extern EventStringId EventInternGenString(size_t, const char *label);
|
||||
extern void EventLabelAddr(Addr addr, Word id);
|
||||
extern void EventFlush(EventKind kind);
|
||||
extern Res EventDescribe(Event event, mps_lib_FILE *stream);
|
||||
extern Res EventDescribe(Event event, mps_lib_FILE *stream, Count depth);
|
||||
extern Res EventWrite(Event event, mps_lib_FILE *stream);
|
||||
extern void EventDump(mps_lib_FILE *stream);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ SRCID(fbmtest, "$Id$");
|
|||
static Count NAllocateTried, NAllocateSucceeded, NDeallocateTried,
|
||||
NDeallocateSucceeded;
|
||||
|
||||
static int verbose = 0;
|
||||
static Bool verbose = FALSE;
|
||||
|
||||
typedef unsigned FBMType;
|
||||
enum {
|
||||
|
|
@ -81,10 +81,12 @@ static Index (indexOfAddr)(FBMState state, Addr a)
|
|||
static void describe(FBMState state) {
|
||||
switch (state->type) {
|
||||
case FBMTypeCBS:
|
||||
die(CBSDescribe(state->the.cbs, mps_lib_get_stdout()), "CBSDescribe");
|
||||
die(CBSDescribe(state->the.cbs, mps_lib_get_stdout(), 0),
|
||||
"CBSDescribe");
|
||||
break;
|
||||
case FBMTypeFreelist:
|
||||
die(FreelistDescribe(state->the.fl, mps_lib_get_stdout()), "FreelistDescribe");
|
||||
die(FreelistDescribe(state->the.fl, mps_lib_get_stdout(), 0),
|
||||
"FreelistDescribe");
|
||||
break;
|
||||
default:
|
||||
cdie(0, "invalid state->type");
|
||||
|
|
@ -542,6 +544,8 @@ static void test(FBMState state, unsigned n) {
|
|||
}
|
||||
if ((i + 1) % 1000 == 0)
|
||||
check(state);
|
||||
if (i == 100)
|
||||
describe(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,11 +193,11 @@ Arena FormatArena(Format format)
|
|||
|
||||
/* FormatDescribe -- describe a format */
|
||||
|
||||
Res FormatDescribe(Format format, mps_lib_FILE *stream)
|
||||
Res FormatDescribe(Format format, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Format $P ($U) {\n", (WriteFP)format, (WriteFU)format->serial,
|
||||
" arena $P ($U)\n",
|
||||
(WriteFP)format->arena, (WriteFU)format->arena->serial,
|
||||
|
|
|
|||
|
|
@ -551,14 +551,14 @@ static Bool freelistDescribeIterateMethod(Bool *deleteReturn, Range range,
|
|||
{
|
||||
Res res;
|
||||
mps_lib_FILE *stream = closureP;
|
||||
Count depth = closureS;
|
||||
|
||||
AVER(deleteReturn != NULL);
|
||||
AVERT(Range, range);
|
||||
AVER(stream != NULL);
|
||||
UNUSED(closureS);
|
||||
|
||||
res = WriteF(stream,
|
||||
" [$P,", (WriteFP)RangeBase(range),
|
||||
res = WriteF(depth, stream,
|
||||
"[$P,", (WriteFP)RangeBase(range),
|
||||
"$P)", (WriteFP)RangeLimit(range),
|
||||
" {$U}\n", (WriteFU)RangeSize(range),
|
||||
NULL);
|
||||
|
|
@ -568,22 +568,22 @@ static Bool freelistDescribeIterateMethod(Bool *deleteReturn, Range range,
|
|||
}
|
||||
|
||||
|
||||
Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream)
|
||||
Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Freelist, fl)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Freelist $P {\n", (WriteFP)fl,
|
||||
" alignment = $U\n", (WriteFU)fl->alignment,
|
||||
" listSize = $U\n", (WriteFU)fl->listSize,
|
||||
NULL);
|
||||
|
||||
FreelistIterate(fl, freelistDescribeIterateMethod, stream, 0);
|
||||
FreelistIterate(fl, freelistDescribeIterateMethod, stream, depth + 2);
|
||||
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} Freelist $P\n", (WriteFP)fl, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ extern void FreelistFinish(Freelist fl);
|
|||
|
||||
extern Res FreelistInsert(Range rangeReturn, Freelist fl, Range range);
|
||||
extern Res FreelistDelete(Range rangeReturn, Freelist fl, Range range);
|
||||
extern Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream);
|
||||
extern Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
extern void FreelistIterate(Freelist abq, FreelistIterateMethod iterate,
|
||||
void *closureP, Size closureS);
|
||||
|
|
|
|||
|
|
@ -1034,7 +1034,7 @@ Ref ArenaRead(Arena arena, Ref *p)
|
|||
|
||||
/* GlobalsDescribe -- describe the arena globals */
|
||||
|
||||
Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream)
|
||||
Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Arena arena;
|
||||
|
|
@ -1047,85 +1047,83 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream)
|
|||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
arena = GlobalsArena(arenaGlobals);
|
||||
res = WriteF(stream,
|
||||
" mpsVersion $S\n", arenaGlobals->mpsVersionString,
|
||||
" lock $P\n", (WriteFP)arenaGlobals->lock,
|
||||
" pollThreshold $U kB\n",
|
||||
res = WriteF(depth, stream,
|
||||
"mpsVersion $S\n", arenaGlobals->mpsVersionString,
|
||||
"lock $P\n", (WriteFP)arenaGlobals->lock,
|
||||
"pollThreshold $U kB\n",
|
||||
(WriteFU)(arenaGlobals->pollThreshold / 1024),
|
||||
arenaGlobals->insidePoll ? "inside poll\n" : "outside poll\n",
|
||||
arenaGlobals->clamped ? "clamped\n" : "released\n",
|
||||
" fillMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->fillMutatorSize / 1024),
|
||||
" emptyMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->emptyMutatorSize / 1024),
|
||||
" allocMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->allocMutatorSize / 1024),
|
||||
" fillInternalSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->fillInternalSize / 1024),
|
||||
" emptyInternalSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->emptyInternalSize / 1024),
|
||||
" poolSerial $U\n", (WriteFU)arenaGlobals->poolSerial,
|
||||
" rootSerial $U\n", (WriteFU)arenaGlobals->rootSerial,
|
||||
" formatSerial $U\n", (WriteFU)arena->formatSerial,
|
||||
" threadSerial $U\n", (WriteFU)arena->threadSerial,
|
||||
"fillMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->fillMutatorSize / 1024),
|
||||
"emptyMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->emptyMutatorSize / 1024),
|
||||
"allocMutatorSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->allocMutatorSize / 1024),
|
||||
"fillInternalSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->fillInternalSize / 1024),
|
||||
"emptyInternalSize $U kB\n",
|
||||
(WriteFU)(arenaGlobals->emptyInternalSize / 1024),
|
||||
"poolSerial $U\n", (WriteFU)arenaGlobals->poolSerial,
|
||||
"rootSerial $U\n", (WriteFU)arenaGlobals->rootSerial,
|
||||
"formatSerial $U\n", (WriteFU)arena->formatSerial,
|
||||
"threadSerial $U\n", (WriteFU)arena->threadSerial,
|
||||
arena->insideShield ? "inside shield\n" : "outside shield\n",
|
||||
" busyTraces $B\n", (WriteFB)arena->busyTraces,
|
||||
" flippedTraces $B\n", (WriteFB)arena->flippedTraces,
|
||||
" epoch $U\n", (WriteFU)arena->epoch,
|
||||
"busyTraces $B\n", (WriteFB)arena->busyTraces,
|
||||
"flippedTraces $B\n", (WriteFB)arena->flippedTraces,
|
||||
"epoch $U\n", (WriteFU)arena->epoch,
|
||||
"prehistory = $B\n", (WriteFB)arena->prehistory,
|
||||
"history {\n",
|
||||
" [note: indices are raw, not rotated]\n",
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
for(i=0; i < LDHistoryLENGTH; ++ i) {
|
||||
res = WriteF(stream,
|
||||
" history[$U] = $B\n", i, arena->history[i],
|
||||
res = WriteF(depth + 2, stream,
|
||||
"[$U] = $B\n", i, arena->history[i],
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
" [note: indices are raw, not rotated]\n"
|
||||
" prehistory = $B\n", (WriteFB)arena->prehistory,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" suspended $S\n", arena->suspended ? "YES" : "NO",
|
||||
" shDepth $U\n", arena->shDepth,
|
||||
" shCacheI $U\n", arena->shCacheI,
|
||||
res = WriteF(depth, stream,
|
||||
"} history\n",
|
||||
"suspended $S\n", arena->suspended ? "YES" : "NO",
|
||||
"shDepth $U\n", arena->shDepth,
|
||||
"shCacheI $U\n", arena->shCacheI,
|
||||
/* @@@@ should SegDescribe the cached segs? */
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = RootsDescribe(arenaGlobals, stream);
|
||||
res = RootsDescribe(arenaGlobals, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
RING_FOR(node, &arenaGlobals->poolRing, nextNode) {
|
||||
Pool pool = RING_ELT(Pool, arenaRing, node);
|
||||
res = PoolDescribe(pool, stream);
|
||||
res = PoolDescribe(pool, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
RING_FOR(node, &arena->formatRing, nextNode) {
|
||||
Format format = RING_ELT(Format, arenaRing, node);
|
||||
res = FormatDescribe(format, stream);
|
||||
res = FormatDescribe(format, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
RING_FOR(node, &arena->threadRing, nextNode) {
|
||||
Thread thread = ThreadRingThread(node);
|
||||
res = ThreadDescribe(thread, stream);
|
||||
res = ThreadDescribe(thread, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
RING_FOR(node, &arena->chainRing, nextNode) {
|
||||
Chain chain = RING_ELT(Chain, chainRing, node);
|
||||
res = ChainDescribe(chain, stream);
|
||||
res = ChainDescribe(chain, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
TRACE_SET_ITER(ti, trace, TraceSetUNIV, arena)
|
||||
if (TraceSetIsMember(arena->busyTraces, trace)) {
|
||||
res = TraceDescribe(trace, stream);
|
||||
res = TraceDescribe(trace, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
TRACE_SET_ITER_END(ti, trace, TraceSetUNIV, arena);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ static Size GenDescTotalSize(GenDesc gen)
|
|||
|
||||
/* GenDescDescribe -- describe a generation in a chain */
|
||||
|
||||
Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream)
|
||||
Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Ring node, nextNode;
|
||||
|
|
@ -136,22 +136,22 @@ Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream)
|
|||
if (!TESTT(GenDesc, gen)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"GenDesc $P {\n", (WriteFP)gen,
|
||||
"zones $B\n", (WriteFB)gen->zones,
|
||||
"capacity $U\n", (WriteFU)gen->capacity,
|
||||
"mortality $D\n", (WriteFD)gen->mortality,
|
||||
"proflow $D\n", (WriteFD)gen->proflow,
|
||||
" zones $B\n", (WriteFB)gen->zones,
|
||||
" capacity $U\n", (WriteFU)gen->capacity,
|
||||
" mortality $D\n", (WriteFD)gen->mortality,
|
||||
" proflow $D\n", (WriteFD)gen->proflow,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
RING_FOR(node, &gen->locusRing, nextNode) {
|
||||
PoolGen pgen = RING_ELT(PoolGen, genRing, node);
|
||||
res = PoolGenDescribe(pgen, stream);
|
||||
res = PoolGenDescribe(pgen, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, "} GenDesc $P\n", (WriteFP)gen, NULL);
|
||||
res = WriteF(depth, stream, "} GenDesc $P\n", (WriteFP)gen, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ void ChainEndGC(Chain chain, Trace trace)
|
|||
|
||||
/* ChainDescribe -- describe a chain */
|
||||
|
||||
Res ChainDescribe(Chain chain, mps_lib_FILE *stream)
|
||||
Res ChainDescribe(Chain chain, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
size_t i;
|
||||
|
|
@ -451,19 +451,19 @@ Res ChainDescribe(Chain chain, mps_lib_FILE *stream)
|
|||
if (!TESTT(Chain, chain)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Chain $P {\n", (WriteFP)chain,
|
||||
"arena $P\n", (WriteFP)chain->arena,
|
||||
"activeTraces $B\n", (WriteFB)chain->activeTraces,
|
||||
" arena $P\n", (WriteFP)chain->arena,
|
||||
" activeTraces $B\n", (WriteFB)chain->activeTraces,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
for (i = 0; i < chain->genCount; ++i) {
|
||||
res = GenDescDescribe(&chain->gens[i], stream);
|
||||
res = GenDescDescribe(&chain->gens[i], stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"} Chain $P\n", (WriteFP)chain,
|
||||
NULL);
|
||||
return res;
|
||||
|
|
@ -525,14 +525,14 @@ Bool PoolGenCheck(PoolGen gen)
|
|||
|
||||
/* PoolGenDescribe -- describe a PoolGen */
|
||||
|
||||
Res PoolGenDescribe(PoolGen pgen, mps_lib_FILE *stream)
|
||||
Res PoolGenDescribe(PoolGen pgen, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(PoolGen, pgen)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"PoolGen $P ($U) {\n", (WriteFP)pgen, (WriteFU)pgen->nr,
|
||||
"pool $P ($U) \"$S\"\n",
|
||||
(WriteFP)pgen->pool, (WriteFU)pgen->pool->serial,
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ void MeterAccumulate(Meter meter, Size amount)
|
|||
|
||||
/* MeterWrite -- describe method for meters */
|
||||
|
||||
Res MeterWrite(Meter meter, mps_lib_FILE *stream)
|
||||
Res MeterWrite(Meter meter, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res = ResOK;
|
||||
|
||||
res = WriteF(stream,
|
||||
"meter $S {", meter->name,
|
||||
res = WriteF(depth, stream,
|
||||
"meter \"$S\" {", meter->name,
|
||||
"count: $U", meter->count,
|
||||
NULL);
|
||||
if (res != ResOK)
|
||||
|
|
@ -77,7 +77,7 @@ Res MeterWrite(Meter meter, mps_lib_FILE *stream)
|
|||
if (meter->count > 0) {
|
||||
double mean = meter->total / (double)meter->count;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(0, stream,
|
||||
", total: $D", meter->total,
|
||||
", max: $U", meter->max,
|
||||
", min: $U", meter->min,
|
||||
|
|
@ -87,7 +87,7 @@ Res MeterWrite(Meter meter, mps_lib_FILE *stream)
|
|||
if (res != ResOK)
|
||||
return res;
|
||||
}
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(0, stream, "}\n", NULL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ Res MeterWrite(Meter meter, mps_lib_FILE *stream)
|
|||
void MeterEmit(Meter meter)
|
||||
{
|
||||
EVENT6(MeterValues, meter, meter->total, meter->meanSquared,
|
||||
meter->count, meter->max, meter->min);
|
||||
meter->count, meter->max, meter->min);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ typedef struct MeterStruct
|
|||
|
||||
extern void MeterInit(Meter meter, const char *name, void *owner);
|
||||
extern void MeterAccumulate(Meter meter, Size amount);
|
||||
extern Res MeterWrite(Meter meter, mps_lib_FILE *stream);
|
||||
extern Res MeterWrite(Meter meter, mps_lib_FILE *stream, Count depth);
|
||||
extern void MeterEmit(Meter meter);
|
||||
|
||||
#define METER_DECL(meter) STATISTIC_DECL(struct MeterStruct meter)
|
||||
|
|
@ -45,12 +45,12 @@ extern void MeterEmit(Meter meter);
|
|||
#define METER_ACC(meter, delta) \
|
||||
STATISTIC(MeterAccumulate(&(meter), delta))
|
||||
#if defined(STATISTICS)
|
||||
#define METER_WRITE(meter, stream) BEGIN \
|
||||
Res _res = MeterWrite(&(meter), (stream)); \
|
||||
#define METER_WRITE(meter, stream, depth) BEGIN \
|
||||
Res _res = MeterWrite(&(meter), (stream), (depth)); \
|
||||
if (_res != ResOK) return _res; \
|
||||
END
|
||||
#elif defined(STATISTICS_NONE)
|
||||
#define METER_WRITE(meter, stream) NOOP
|
||||
#define METER_WRITE(meter, stream, depth) NOOP
|
||||
#else
|
||||
#error "No statistics configured."
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -430,34 +430,35 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
|
|||
* .writef.check: See .check.writef.
|
||||
*/
|
||||
|
||||
Res WriteF(mps_lib_FILE *stream, ...)
|
||||
Res WriteF(Count depth, mps_lib_FILE *stream, ...)
|
||||
{
|
||||
Res res;
|
||||
va_list args;
|
||||
|
||||
va_start(args, stream);
|
||||
res = WriteF_v(stream, args);
|
||||
res = WriteF_v(depth, stream, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
Res WriteF_v(mps_lib_FILE *stream, va_list args)
|
||||
Res WriteF_v(Count depth, mps_lib_FILE *stream, va_list args)
|
||||
{
|
||||
const char *firstformat;
|
||||
Res res;
|
||||
|
||||
firstformat = va_arg(args, const char *);
|
||||
res = WriteF_firstformat_v(stream, firstformat, args);
|
||||
res = WriteF_firstformat_v(depth, stream, firstformat, args);
|
||||
return res;
|
||||
}
|
||||
|
||||
Res WriteF_firstformat_v(mps_lib_FILE *stream,
|
||||
Res WriteF_firstformat_v(Count depth, mps_lib_FILE *stream,
|
||||
const char *firstformat, va_list args)
|
||||
{
|
||||
const char *format;
|
||||
int r;
|
||||
size_t i;
|
||||
Res res;
|
||||
Bool start_of_line = TRUE;
|
||||
|
||||
AVER(stream != NULL);
|
||||
|
||||
|
|
@ -468,9 +469,18 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream,
|
|||
break;
|
||||
|
||||
while(*format != '\0') {
|
||||
if (start_of_line) {
|
||||
for (i = 0; i < depth; ++i) {
|
||||
mps_lib_fputc(' ', stream);
|
||||
}
|
||||
start_of_line = FALSE;
|
||||
}
|
||||
if (*format != '$') {
|
||||
r = mps_lib_fputc(*format, stream); /* Could be more efficient */
|
||||
if (r == mps_lib_EOF) return ResIO;
|
||||
if (*format == '\n') {
|
||||
start_of_line = TRUE;
|
||||
}
|
||||
} else {
|
||||
++format;
|
||||
AVER(*format != '\0');
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ extern Bool (WordIsP2)(Word word);
|
|||
|
||||
/* Formatted Output -- see <design/writef/>, <code/mpm.c> */
|
||||
|
||||
extern Res WriteF(mps_lib_FILE *stream, ...);
|
||||
extern Res WriteF_v(mps_lib_FILE *stream, va_list args);
|
||||
extern Res WriteF_firstformat_v(mps_lib_FILE *stream,
|
||||
extern Res WriteF(Count depth, mps_lib_FILE *stream, ...);
|
||||
extern Res WriteF_v(Count depth, mps_lib_FILE *stream, va_list args);
|
||||
extern Res WriteF_firstformat_v(Count depth, mps_lib_FILE *stream,
|
||||
const char *firstformat, va_list args);
|
||||
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ extern Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args);
|
|||
extern void PoolFinish(Pool pool);
|
||||
extern Bool PoolClassCheck(PoolClass class);
|
||||
extern Bool PoolCheck(Pool pool);
|
||||
extern Res PoolDescribe(Pool pool, mps_lib_FILE *stream);
|
||||
extern Res PoolDescribe(Pool pool, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
/* Must be thread-safe. See <design/interface-c/#thread-safety>. */
|
||||
#define PoolArena(pool) ((pool)->arena)
|
||||
|
|
@ -239,7 +239,7 @@ extern void PoolNoBufferEmpty(Pool pool, Buffer buffer,
|
|||
Addr init, Addr limit);
|
||||
extern void PoolTrivBufferEmpty(Pool pool, Buffer buffer,
|
||||
Addr init, Addr limit);
|
||||
extern Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream);
|
||||
extern Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream, Count depth);
|
||||
extern Res PoolNoTraceBegin(Pool pool, Trace trace);
|
||||
extern Res PoolTrivTraceBegin(Pool pool, Trace trace);
|
||||
extern Res PoolNoAccess(Pool pool, Seg seg, Addr addr,
|
||||
|
|
@ -397,7 +397,7 @@ extern void TraceSegAccess(Arena arena, Seg seg, AccessSet mode);
|
|||
|
||||
extern void TraceQuantum(Trace trace);
|
||||
extern Res TraceStartCollectAll(Trace *traceReturn, Arena arena, int why);
|
||||
extern Res TraceDescribe(Trace trace, mps_lib_FILE *stream);
|
||||
extern Res TraceDescribe(Trace trace, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
/* traceanc.c -- Trace Ancillary */
|
||||
|
||||
|
|
@ -493,8 +493,8 @@ extern void ArenaDestroy(Arena arena);
|
|||
extern Res ArenaInit(Arena arena, ArenaClass class, Align alignment,
|
||||
ArgList args);
|
||||
extern void ArenaFinish(Arena arena);
|
||||
extern Res ArenaDescribe(Arena arena, mps_lib_FILE *stream);
|
||||
extern Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream);
|
||||
extern Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth);
|
||||
extern Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream, Count depth);
|
||||
extern Bool ArenaAccess(Addr addr, AccessSet mode, MutatorFaultContext context);
|
||||
extern Res ArenaFreeCBSInsert(Arena arena, Addr base, Addr limit);
|
||||
extern void ArenaFreeCBSDelete(Arena arena, Addr base, Addr limit);
|
||||
|
|
@ -505,7 +505,7 @@ extern Res GlobalsInit(Globals arena);
|
|||
extern void GlobalsFinish(Globals arena);
|
||||
extern Res GlobalsCompleteCreate(Globals arenaGlobals);
|
||||
extern void GlobalsPrepareToDestroy(Globals arenaGlobals);
|
||||
extern Res GlobalsDescribe(Globals arena, mps_lib_FILE *stream);
|
||||
extern Res GlobalsDescribe(Globals arena, mps_lib_FILE *stream, Count depth);
|
||||
extern Ring GlobalsRememberedSummaryRing(Globals);
|
||||
|
||||
#define ArenaGlobals(arena) (&(arena)->globals)
|
||||
|
|
@ -557,7 +557,7 @@ extern void ControlFinish(Arena arena);
|
|||
extern Res ControlAlloc(void **baseReturn, Arena arena, size_t size,
|
||||
Bool withReservoirPermit);
|
||||
extern void ControlFree(Arena arena, void *base, size_t size);
|
||||
extern Res ControlDescribe(Arena arena, mps_lib_FILE *stream);
|
||||
extern Res ControlDescribe(Arena arena, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
|
||||
/* Peek/Poke
|
||||
|
|
@ -666,7 +666,7 @@ extern Res SegMerge(Seg *mergedSegReturn, Seg segLo, Seg segHi,
|
|||
Bool withReservoirPermit);
|
||||
extern Res SegSplit(Seg *segLoReturn, Seg *segHiReturn, Seg seg, Addr at,
|
||||
Bool withReservoirPermit);
|
||||
extern Res SegDescribe(Seg seg, mps_lib_FILE *stream);
|
||||
extern Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
extern void SegSetSummary(Seg seg, RefSet summary);
|
||||
extern Buffer SegBuffer(Seg seg);
|
||||
extern void SegSetBuffer(Seg seg, Buffer buffer);
|
||||
|
|
@ -725,7 +725,7 @@ extern Res BufferCreate(Buffer *bufferReturn, BufferClass class,
|
|||
extern void BufferDestroy(Buffer buffer);
|
||||
extern Bool BufferCheck(Buffer buffer);
|
||||
extern Bool SegBufCheck(SegBuf segbuf);
|
||||
extern Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream);
|
||||
extern Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth);
|
||||
extern Res BufferReserve(Addr *pReturn, Buffer buffer, Size size,
|
||||
Bool withReservoirPermit);
|
||||
/* macro equivalent for BufferReserve, keep in sync with <code/buffer.c> */
|
||||
|
|
@ -824,7 +824,7 @@ extern Bool FormatCheck(Format format);
|
|||
extern Res FormatCreate(Format *formatReturn, Arena arena, ArgList args);
|
||||
extern void FormatDestroy(Format format);
|
||||
extern Arena FormatArena(Format format);
|
||||
extern Res FormatDescribe(Format format, mps_lib_FILE *stream);
|
||||
extern Res FormatDescribe(Format format, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
|
||||
/* Reference Interface -- see <code/ref.c> */
|
||||
|
|
@ -969,8 +969,8 @@ extern Res RootCreateFun(Root *rootReturn, Arena arena,
|
|||
extern void RootDestroy(Root root);
|
||||
extern Bool RootModeCheck(RootMode mode);
|
||||
extern Bool RootCheck(Root root);
|
||||
extern Res RootDescribe(Root root, mps_lib_FILE *stream);
|
||||
extern Res RootsDescribe(Globals arenaGlobals, mps_lib_FILE *stream);
|
||||
extern Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth);
|
||||
extern Res RootsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth);
|
||||
extern Rank RootRank(Root root);
|
||||
extern AccessSet RootPM(Root root);
|
||||
extern RefSet RootSummary(Root root);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ typedef void (*ArenaFreeMethod)(Addr base, Size size, Pool pool);
|
|||
typedef Res (*ArenaChunkInitMethod)(Chunk chunk, BootBlock boot);
|
||||
typedef void (*ArenaChunkFinishMethod)(Chunk chunk);
|
||||
typedef void (*ArenaCompactMethod)(Arena arena, Trace trace);
|
||||
typedef Res (*ArenaDescribeMethod)(Arena arena, mps_lib_FILE *stream);
|
||||
typedef Res (*ArenaDescribeMethod)(Arena arena, mps_lib_FILE *stream, Count depth);
|
||||
typedef Res (*ArenaPagesMarkAllocatedMethod)(Arena arena, Chunk chunk,
|
||||
Index baseIndex, Count pages,
|
||||
Pool pool);
|
||||
|
|
@ -165,7 +165,7 @@ typedef void (*SegSetRankSummaryMethod)(Seg seg, RankSet rankSet,
|
|||
typedef void (*SegSetSummaryMethod)(Seg seg, RefSet summary);
|
||||
typedef Buffer (*SegBufferMethod)(Seg seg);
|
||||
typedef void (*SegSetBufferMethod)(Seg seg, Buffer buffer);
|
||||
typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream);
|
||||
typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
typedef Res (*SegMergeMethod)(Seg seg, Seg segHi,
|
||||
Addr base, Addr mid, Addr limit,
|
||||
Bool withReservoirPermit);
|
||||
|
|
@ -185,7 +185,7 @@ typedef Seg (*BufferSegMethod)(Buffer buffer);
|
|||
typedef RankSet (*BufferRankSetMethod)(Buffer buffer);
|
||||
typedef void (*BufferSetRankSetMethod)(Buffer buffer, RankSet rankSet);
|
||||
typedef void (*BufferReassignSegMethod)(Buffer buffer, Seg seg);
|
||||
typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream);
|
||||
typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
|
||||
/* Pool*Method -- see <design/class-interface/> */
|
||||
|
|
@ -232,7 +232,7 @@ typedef void (*PoolWalkMethod)(Pool pool, Seg seg,
|
|||
void *v, size_t s);
|
||||
typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockStepMethod f, void *p);
|
||||
typedef BufferClass (*PoolBufferClassMethod)(void);
|
||||
typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream);
|
||||
typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream, Count depth);
|
||||
typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,22 +4,19 @@
|
|||
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include "mpstd.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "mpscmvt.h"
|
||||
#include "mpm.h"
|
||||
#include "mps.h"
|
||||
|
||||
typedef mps_word_t mps_count_t; /* machine word (target dep.) */
|
||||
|
||||
#include "mpslib.h"
|
||||
#include "mpsavm.h"
|
||||
#include "mpscmvt.h"
|
||||
#include "mpslib.h"
|
||||
#include "mpstd.h"
|
||||
#include "testlib.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* expdev() -- exponentially distributed random deviates
|
||||
*
|
||||
* From <http://cfatab.harvard.edu/nr/bookcpdf/c7-2.pdf>
|
||||
|
|
@ -116,6 +113,9 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
|
|||
printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ",
|
||||
(ulongest_t)ps[i], (ulongest_t)ss[i]);
|
||||
}
|
||||
if (i == 100) {
|
||||
PoolDescribe(pool, mps_lib_get_stdout(), 0);
|
||||
}
|
||||
}
|
||||
if (verbose) {
|
||||
putchar('\n');
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ Bool NailboardIsResRange(Nailboard board, Addr base, Addr limit)
|
|||
}
|
||||
|
||||
|
||||
Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream)
|
||||
Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Index i, j;
|
||||
Res res;
|
||||
|
|
@ -413,7 +413,7 @@ Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream)
|
|||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Nailboard $P\n{\n", (WriteFP)board,
|
||||
" base: $P\n", (WriteFP)RangeBase(&board->range),
|
||||
" limit: $P\n", (WriteFP)RangeLimit(&board->range),
|
||||
|
|
@ -427,21 +427,21 @@ Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream)
|
|||
for(i = 0; i < board->levels; ++i) {
|
||||
Count levelNails = nailboardLevelBits(nailboardNails(board), i);
|
||||
Count resetNails = BTCountResRange(board->level[i], 0, levelNails);
|
||||
res = WriteF(stream, " Level $U ($U bits, $U set): ",
|
||||
res = WriteF(depth + 2, stream, "Level $U ($U bits, $U set): ",
|
||||
i, levelNails, levelNails - resetNails, NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
for (j = 0; j < levelNails; ++j) {
|
||||
char c = BTGet(board->level[i], j) ? '*' : '.';
|
||||
res = WriteF(stream, "$C", c, NULL);
|
||||
res = WriteF(0, stream, "$C", c, NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
}
|
||||
res = WriteF(stream, "\n", NULL);
|
||||
res = WriteF(0, stream, "\n", NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
}
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} Nailboard $P\n", (WriteFP)board, NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ extern Bool NailboardSet(Nailboard board, Addr addr);
|
|||
extern void NailboardSetRange(Nailboard board, Addr base, Addr limit);
|
||||
extern Bool NailboardIsSetRange(Nailboard board, Addr base, Addr limit);
|
||||
extern Bool NailboardIsResRange(Nailboard board, Addr base, Addr limit);
|
||||
extern Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream);
|
||||
extern Res NailboardDescribe(Nailboard board, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
#endif /* nailboard.h */
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ static void test(mps_arena_t arena)
|
|||
"NailboardIsResRange");
|
||||
}
|
||||
}
|
||||
|
||||
die(NailboardDescribe(board, mps_lib_get_stdout(), 0), "NailboardDescribe");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p)
|
|||
|
||||
/* PoolDescribe -- describe a pool */
|
||||
|
||||
Res PoolDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
Res PoolDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Ring node, nextNode;
|
||||
|
|
@ -530,7 +530,7 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (!TESTT(Pool, pool)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Pool $P ($U) {\n", (WriteFP)pool, (WriteFU)pool->serial,
|
||||
" class $P (\"$S\")\n",
|
||||
(WriteFP)pool->class, pool->class->name,
|
||||
|
|
@ -540,31 +540,31 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
if (NULL != pool->format) {
|
||||
res = FormatDescribe(pool->format, stream);
|
||||
res = FormatDescribe(pool->format, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(stream,
|
||||
" fillMutatorSize $UKb\n",
|
||||
(WriteFU)(pool->fillMutatorSize / 1024),
|
||||
" emptyMutatorSize $UKb\n",
|
||||
(WriteFU)(pool->emptyMutatorSize / 1024),
|
||||
" fillInternalSize $UKb\n",
|
||||
(WriteFU)(pool->fillInternalSize / 1024),
|
||||
" emptyInternalSize $UKb\n",
|
||||
(WriteFU)(pool->emptyInternalSize / 1024),
|
||||
res = WriteF(depth + 2, stream,
|
||||
"fillMutatorSize $UKb\n",
|
||||
(WriteFU)(pool->fillMutatorSize / 1024),
|
||||
"emptyMutatorSize $UKb\n",
|
||||
(WriteFU)(pool->emptyMutatorSize / 1024),
|
||||
"fillInternalSize $UKb\n",
|
||||
(WriteFU)(pool->fillInternalSize / 1024),
|
||||
"emptyInternalSize $UKb\n",
|
||||
(WriteFU)(pool->emptyInternalSize / 1024),
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = (*pool->class->describe)(pool, stream);
|
||||
res = (*pool->class->describe)(pool, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
RING_FOR(node, &pool->bufferRing, nextNode) {
|
||||
Buffer buffer = RING_ELT(Buffer, poolRing, node);
|
||||
res = BufferDescribe(buffer, stream);
|
||||
res = BufferDescribe(buffer, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"} Pool $P ($U)\n", (WriteFP)pool, (WriteFU)pool->serial,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
|
|
|||
|
|
@ -311,11 +311,13 @@ void PoolTrivBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
|
|||
}
|
||||
|
||||
|
||||
Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
AVERT(Pool, pool);
|
||||
AVER(stream != NULL);
|
||||
return WriteF(stream, " No class-specific description available.\n", NULL);
|
||||
return WriteF(depth, stream,
|
||||
"No class-specific description available.\n",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ static void AMCSegSketch(Seg seg, char *pbSketch, size_t cbSketch)
|
|||
*
|
||||
* See <design/poolamc/#seg-describe>.
|
||||
*/
|
||||
static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
||||
static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Pool pool;
|
||||
|
|
@ -246,7 +246,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
super = SEG_SUPERCLASS(amcSegClass);
|
||||
res = super->describe(seg, stream);
|
||||
res = super->describe(seg, stream, depth);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
p = AddrAdd(base, pool->format->headerSize);
|
||||
limit = SegLimit(seg);
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"AMC seg $P [$A,$A){\n",
|
||||
(WriteFP)seg, (WriteFA)base, (WriteFA)limit,
|
||||
NULL);
|
||||
|
|
@ -266,16 +266,17 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
return res;
|
||||
|
||||
if(amcSegHasNailboard(seg)) {
|
||||
res = WriteF(stream, " Boarded\n", NULL);
|
||||
res = WriteF(depth + 2, stream, "Boarded\n", NULL);
|
||||
} else if(SegNailed(seg) == TraceSetEMPTY) {
|
||||
res = WriteF(stream, " Mobile\n", NULL);
|
||||
res = WriteF(depth + 2, stream, "Mobile\n", NULL);
|
||||
} else {
|
||||
res = WriteF(stream, " Stuck\n", NULL);
|
||||
res = WriteF(depth + 2, stream, "Stuck\n", NULL);
|
||||
}
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, " Map: *===:object @+++:nails bbbb:buffer\n", NULL);
|
||||
res = WriteF(depth + 2, stream,
|
||||
"Map: *===:object @+++:nails bbbb:buffer\n", NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -288,7 +289,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
Addr j;
|
||||
char c;
|
||||
|
||||
res = WriteF(stream, " $A ", i, NULL);
|
||||
res = WriteF(depth + 2, stream, "$A ", i, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -308,22 +309,22 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
c = (nailed ? '+' : '=');
|
||||
}
|
||||
}
|
||||
res = WriteF(stream, "$C", c, NULL);
|
||||
res = WriteF(0, stream, "$C", c, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, "\n", NULL);
|
||||
res = WriteF(0, stream, "\n", NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
||||
AMCSegSketch(seg, abzSketch, NELEMS(abzSketch));
|
||||
res = WriteF(stream, " Sketch: $S\n", (WriteFS)abzSketch, NULL);
|
||||
res = WriteF(depth + 2, stream, "Sketch: $S\n", (WriteFS)abzSketch, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, "} AMC Seg $P\n", (WriteFP)seg, NULL);
|
||||
res = WriteF(depth, stream, "} AMC Seg $P\n", (WriteFP)seg, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -707,22 +708,22 @@ static void amcGenDestroy(amcGen gen)
|
|||
|
||||
/* amcGenDescribe -- describe an AMC generation */
|
||||
|
||||
static Res amcGenDescribe(amcGen gen, mps_lib_FILE *stream)
|
||||
static Res amcGenDescribe(amcGen gen, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if(!TESTT(amcGen, gen))
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
" amcGen $P ($U) {\n",
|
||||
res = WriteF(depth, stream,
|
||||
"amcGen $P ($U) {\n",
|
||||
(WriteFP)gen, (WriteFU)amcGenNr(gen),
|
||||
" buffer $P\n", gen->forward,
|
||||
" segs $U, totalSize $U, newSize $U\n",
|
||||
" buffer $P\n", gen->forward,
|
||||
" segs $U, totalSize $U, newSize $U\n",
|
||||
(WriteFU)gen->segs,
|
||||
(WriteFU)gen->pgen.totalSize,
|
||||
(WriteFU)gen->pgen.newSize,
|
||||
" } amcGen\n", NULL);
|
||||
"} amcGen $P\n", (WriteFP)gen, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -2262,7 +2263,7 @@ static Res AMCAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr)
|
|||
*
|
||||
* See <design/poolamc/#describe>.
|
||||
*/
|
||||
static Res AMCDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res AMCDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
AMC amc;
|
||||
|
|
@ -2277,7 +2278,7 @@ static Res AMCDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if(stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
(amc->rankSet == RankSetEMPTY) ? "AMCZ" : "AMC",
|
||||
" $P {\n", (WriteFP)amc, " pool $P ($U)\n",
|
||||
(WriteFP)AMC2Pool(amc), (WriteFU)AMC2Pool(amc)->serial,
|
||||
|
|
@ -2286,29 +2287,25 @@ static Res AMCDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
return res;
|
||||
|
||||
switch(amc->rampMode) {
|
||||
|
||||
#define RAMP_DESCRIBE(e, s) \
|
||||
case e: \
|
||||
rampmode = s; \
|
||||
break;
|
||||
|
||||
RAMP_RELATION(RAMP_DESCRIBE)
|
||||
#undef RAMP_DESCRIBE
|
||||
|
||||
default:
|
||||
rampmode = "unknown ramp mode";
|
||||
break;
|
||||
|
||||
}
|
||||
res = WriteF(stream,
|
||||
" ", rampmode, " ($U)\n", (WriteFU)amc->rampCount,
|
||||
res = WriteF(depth + 2, stream,
|
||||
rampmode, " ($U)\n", (WriteFU)amc->rampCount,
|
||||
NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
RING_FOR(node, &amc->genRing, nextNode) {
|
||||
amcGen gen = RING_ELT(amcGen, amcRing, node);
|
||||
res = amcGenDescribe(gen, stream);
|
||||
res = amcGenDescribe(gen, stream, depth + 2);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
|
@ -2317,13 +2314,13 @@ static Res AMCDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
/* SegDescribes */
|
||||
RING_FOR(node, &AMC2Pool(amc)->segRing, nextNode) {
|
||||
Seg seg = RING_ELT(Seg, poolRing, node);
|
||||
res = AMCSegDescribe(seg, stream);
|
||||
res = AMCSegDescribe(seg, stream, depth + 2);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
res = WriteF(stream, "} AMC $P\n", (WriteFP)amc, NULL);
|
||||
res = WriteF(depth, stream, "} AMC $P\n", (WriteFP)amc, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -525,12 +525,12 @@ failCreateTablesLo:
|
|||
BEGIN \
|
||||
if ((buffer) != NULL \
|
||||
&& (i) == AMS_ADDR_INDEX(seg, accessor(buffer))) { \
|
||||
Res _res = WriteF(stream, char, NULL); \
|
||||
Res _res = WriteF(0, stream, char, NULL); \
|
||||
if (_res != ResOK) return _res; \
|
||||
} \
|
||||
END
|
||||
|
||||
static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream)
|
||||
static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
AMSSeg amsseg;
|
||||
|
|
@ -545,30 +545,30 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
super = SEG_SUPERCLASS(AMSSegClass);
|
||||
res = super->describe(seg, stream);
|
||||
res = super->describe(seg, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
buffer = SegBuffer(seg);
|
||||
|
||||
res = WriteF(stream,
|
||||
" AMS $P\n", (WriteFP)amsseg->ams,
|
||||
" grains $W\n", (WriteFW)amsseg->grains,
|
||||
res = WriteF(depth, stream,
|
||||
"AMS $P\n", (WriteFP)amsseg->ams,
|
||||
"grains $W\n", (WriteFW)amsseg->grains,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
if (amsseg->allocTableInUse)
|
||||
res = WriteF(stream,
|
||||
" alloctable $P\n", (WriteFP)amsseg->allocTable,
|
||||
res = WriteF(depth, stream,
|
||||
"alloctable $P\n", (WriteFP)amsseg->allocTable,
|
||||
NULL);
|
||||
else
|
||||
res = WriteF(stream,
|
||||
" firstFree $W\n", (WriteFW)amsseg->firstFree,
|
||||
res = WriteF(depth, stream,
|
||||
"firstFree $W\n", (WriteFW)amsseg->firstFree,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = WriteF(stream,
|
||||
" tables: nongrey $P, nonwhite $P\n",
|
||||
res = WriteF(depth, stream,
|
||||
"tables: nongrey $P, nonwhite $P\n",
|
||||
(WriteFP)amsseg->nongreyTable,
|
||||
(WriteFP)amsseg->nonwhiteTable,
|
||||
" map: \n",
|
||||
"map:",
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
|
|
@ -576,7 +576,9 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
char c = 0;
|
||||
|
||||
if (i % 64 == 0) {
|
||||
res = WriteF(stream, "\n ", NULL);
|
||||
res = WriteF(0, stream, "\n", NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = WriteF(depth, stream, " ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
|
|
@ -598,7 +600,7 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
c = '.';
|
||||
} else
|
||||
c = ' ';
|
||||
res = WriteF(stream, "$C", c, NULL);
|
||||
res = WriteF(0, stream, "$C", c, NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -606,8 +608,7 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
WRITE_BUFFER_LIMIT(stream, seg, i+1, buffer, BufferLimit, "]");
|
||||
}
|
||||
|
||||
res = WriteF(stream, "\n", NULL);
|
||||
return res;
|
||||
return ResOK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -627,8 +628,6 @@ DEFINE_CLASS(AMSSegClass, class)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* AMSPoolRing -- the ring of segments in the pool */
|
||||
|
||||
static Ring AMSPoolRing(AMS ams, RankSet rankSet, Size size)
|
||||
|
|
@ -1648,7 +1647,7 @@ static void AMSFreeWalk(Pool pool, FreeBlockStepMethod f, void *p)
|
|||
*
|
||||
* Iterates over the segments, describing all of them.
|
||||
*/
|
||||
static Res AMSDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
AMS ams;
|
||||
Ring node, nextNode;
|
||||
|
|
@ -1659,7 +1658,7 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (!TESTT(AMS, ams)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"AMS $P {\n", (WriteFP)ams,
|
||||
" pool $P ($U)\n",
|
||||
(WriteFP)pool, (WriteFU)pool->serial,
|
||||
|
|
@ -1671,21 +1670,19 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" segments\n"
|
||||
" * = black, + = grey, - = white, . = alloc, ! = bad\n"
|
||||
" buffers: [ = base, < = scan limit, | = init,\n"
|
||||
" > = alloc, ] = limit\n",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"segments: * black + grey - white . alloc ! bad\n"
|
||||
"buffers: [ base < scan limit | init > alloc ] limit\n",
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
RING_FOR(node, &ams->segRing, nextNode) {
|
||||
AMSSeg amsseg = RING_ELT(AMSSeg, segRing, node);
|
||||
res = SegDescribe(AMSSeg2Seg(amsseg), stream);
|
||||
res = SegDescribe(AMSSeg2Seg(amsseg), stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, "} AMS $P\n",(WriteFP)ams, NULL);
|
||||
res = WriteF(depth, stream, "} AMS $P\n",(WriteFP)ams, NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ static void MFSFree(Pool pool, Addr old, Size size)
|
|||
}
|
||||
|
||||
|
||||
static Res MFSDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res MFSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
MFS mfs;
|
||||
Res res;
|
||||
|
|
@ -322,12 +322,12 @@ static Res MFSDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
|
||||
AVER(stream != NULL);
|
||||
|
||||
res = WriteF(stream,
|
||||
" unrounded unit size $W\n", (WriteFW)mfs->unroundedUnitSize,
|
||||
" unit size $W\n", (WriteFW)mfs->unitSize,
|
||||
" extent size $W\n", (WriteFW)mfs->extendBy,
|
||||
" free list begins at $P\n", (WriteFP)mfs->freeList,
|
||||
" tract list begin at $P\n", (WriteFP)mfs->tractList,
|
||||
res = WriteF(depth, stream,
|
||||
"unrounded unit size $W\n", (WriteFW)mfs->unroundedUnitSize,
|
||||
"unit size $W\n", (WriteFW)mfs->unitSize,
|
||||
"extent size $W\n", (WriteFW)mfs->extendBy,
|
||||
"free list begins at $P\n", (WriteFP)mfs->freeList,
|
||||
"tract list begin at $P\n", (WriteFP)mfs->tractList,
|
||||
NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -792,7 +792,7 @@ Res MRGDeregister(Pool pool, Ref obj)
|
|||
* This could be improved by implementing MRGSegDescribe
|
||||
* and having MRGDescribe iterate over all the pool's segments.
|
||||
*/
|
||||
static Res MRGDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res MRGDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
MRG mrg;
|
||||
Arena arena;
|
||||
|
|
@ -806,13 +806,13 @@ static Res MRGDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
arena = PoolArena(pool);
|
||||
res = WriteF(stream, " extendBy $W\n", mrg->extendBy, NULL);
|
||||
res = WriteF(depth, stream, " extendBy $W\n", mrg->extendBy, NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = WriteF(stream, " Entry queue:\n", NULL);
|
||||
res = WriteF(depth, stream, " Entry queue:\n", NULL);
|
||||
if (res != ResOK) return res;
|
||||
RING_FOR(node, &mrg->entryRing, nextNode) {
|
||||
refPart = MRGRefPartOfLink(linkOfRing(node), arena);
|
||||
res = WriteF(stream, " at $A Ref $A\n",
|
||||
res = WriteF(depth, stream, " at $A Ref $A\n",
|
||||
(WriteFA)refPart, (WriteFA)MRGRefPartRef(arena, refPart),
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ static PoolDebugMixin MVDebugMixin(Pool pool)
|
|||
}
|
||||
|
||||
|
||||
static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
MV mv;
|
||||
|
|
@ -687,15 +687,15 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if(!TESTT(MV, mv)) return ResFAIL;
|
||||
if(stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
" blockPool $P ($U)\n",
|
||||
res = WriteF(depth, stream,
|
||||
"blockPool $P ($U)\n",
|
||||
(WriteFP)mvBlockPool(mv), (WriteFU)mvBlockPool(mv)->serial,
|
||||
" spanPool $P ($U)\n",
|
||||
"spanPool $P ($U)\n",
|
||||
(WriteFP)mvSpanPool(mv), (WriteFU)mvSpanPool(mv)->serial,
|
||||
" extendBy $W\n", (WriteFW)mv->extendBy,
|
||||
" avgSize $W\n", (WriteFW)mv->avgSize,
|
||||
" maxSize $W\n", (WriteFW)mv->maxSize,
|
||||
" space $P\n", (WriteFP)mv->space,
|
||||
"extendBy $W\n", (WriteFW)mv->extendBy,
|
||||
"avgSize $W\n", (WriteFW)mv->avgSize,
|
||||
"maxSize $W\n", (WriteFW)mv->maxSize,
|
||||
"space $P\n", (WriteFP)mv->space,
|
||||
NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
|
|
@ -707,29 +707,28 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
Addr i, j;
|
||||
MVBlock block;
|
||||
span = RING_ELT(MVSpan, spans, node);
|
||||
res = WriteF(stream, "MVSpan $P {\n", (WriteFP)span, NULL);
|
||||
res = WriteF(depth, stream, "MVSpan $P {\n", (WriteFP)span, NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" span $P\n", (WriteFP)span,
|
||||
" tract $P\n", (WriteFP)span->tract,
|
||||
" space $W\n", (WriteFW)span->space,
|
||||
" blocks $U\n", (WriteFU)span->blockCount,
|
||||
" largest ",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"span $P\n", (WriteFP)span,
|
||||
"tract $P\n", (WriteFP)span->tract,
|
||||
"space $W\n", (WriteFW)span->space,
|
||||
"blocks $U\n", (WriteFU)span->blockCount,
|
||||
"largest ",
|
||||
NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
if (span->largestKnown) /* .design.largest */
|
||||
res = WriteF(stream, "$W\n", (WriteFW)span->largest, NULL);
|
||||
res = WriteF(0, stream, "$W\n", (WriteFW)span->largest, NULL);
|
||||
else
|
||||
res = WriteF(stream, "unknown\n", NULL);
|
||||
|
||||
res = WriteF(0, stream, "unknown\n", NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
block = span->blocks;
|
||||
|
||||
for(i = span->base.base; i < span->limit.limit; i = AddrAdd(i, length)) {
|
||||
res = WriteF(stream, " $A ", i, NULL);
|
||||
res = WriteF(depth + 2, stream, "$A ", i, NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
for(j = i;
|
||||
|
|
@ -752,12 +751,14 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
c = ']';
|
||||
else /* j > block->base && j < block->limit */
|
||||
c = '=';
|
||||
res = WriteF(stream, "$C", c, NULL);
|
||||
res = WriteF(0, stream, "$C", c, NULL);
|
||||
if(res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(stream, "\n", NULL);
|
||||
res = WriteF(0, stream, "\n", NULL);
|
||||
if(res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(depth, stream, "} MVSpan $P\n", (WriteFP)span, NULL);
|
||||
if(res != ResOK) return res;
|
||||
}
|
||||
|
||||
return ResOK;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static Res MVTBufferFill(Addr *baseReturn, Addr *limitReturn,
|
|||
Bool withReservoirPermit);
|
||||
static void MVTBufferEmpty(Pool pool, Buffer buffer, Addr base, Addr limit);
|
||||
static void MVTFree(Pool pool, Addr base, Size size);
|
||||
static Res MVTDescribe(Pool pool, mps_lib_FILE *stream);
|
||||
static Res MVTDescribe(Pool pool, mps_lib_FILE *stream, Count depth);
|
||||
static Res MVTSegAlloc(Seg *segReturn, MVT mvt, Size size,
|
||||
Bool withReservoirPermit);
|
||||
|
||||
|
|
@ -1003,7 +1003,7 @@ static void MVTFree(Pool pool, Addr base, Size size)
|
|||
|
||||
/* MVTDescribe -- describe an MVT pool */
|
||||
|
||||
static Res MVTDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res MVTDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
MVT mvt;
|
||||
|
|
@ -1013,68 +1013,69 @@ static Res MVTDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (!TESTT(MVT, mvt)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
"MVT $P\n{\n", (WriteFP)mvt,
|
||||
" minSize: $U \n", (WriteFU)mvt->minSize,
|
||||
" meanSize: $U \n", (WriteFU)mvt->meanSize,
|
||||
" maxSize: $U \n", (WriteFU)mvt->maxSize,
|
||||
" fragLimit: $U \n", (WriteFU)mvt->fragLimit,
|
||||
" reuseSize: $U \n", (WriteFU)mvt->reuseSize,
|
||||
" fillSize: $U \n", (WriteFU)mvt->fillSize,
|
||||
" availLimit: $U \n", (WriteFU)mvt->availLimit,
|
||||
" abqOverflow: $S \n", mvt->abqOverflow?"TRUE":"FALSE",
|
||||
" splinter: $S \n", mvt->splinter?"TRUE":"FALSE",
|
||||
" splinterBase: $A \n", (WriteFA)mvt->splinterBase,
|
||||
" splinterLimit: $A \n", (WriteFU)mvt->splinterLimit,
|
||||
" size: $U \n", (WriteFU)mvt->size,
|
||||
" allocated: $U \n", (WriteFU)mvt->allocated,
|
||||
" available: $U \n", (WriteFU)mvt->available,
|
||||
" unavailable: $U \n", (WriteFU)mvt->unavailable,
|
||||
res = WriteF(depth, stream,
|
||||
"MVT $P {\n", (WriteFP)mvt,
|
||||
" minSize: $U\n", (WriteFU)mvt->minSize,
|
||||
" meanSize: $U\n", (WriteFU)mvt->meanSize,
|
||||
" maxSize: $U\n", (WriteFU)mvt->maxSize,
|
||||
" fragLimit: $U\n", (WriteFU)mvt->fragLimit,
|
||||
" reuseSize: $U\n", (WriteFU)mvt->reuseSize,
|
||||
" fillSize: $U\n", (WriteFU)mvt->fillSize,
|
||||
" availLimit: $U\n", (WriteFU)mvt->availLimit,
|
||||
" abqOverflow: $S\n", mvt->abqOverflow?"TRUE":"FALSE",
|
||||
" splinter: $S\n", mvt->splinter?"TRUE":"FALSE",
|
||||
" splinterBase: $A\n", (WriteFA)mvt->splinterBase,
|
||||
" splinterLimit: $A\n", (WriteFU)mvt->splinterLimit,
|
||||
" size: $U\n", (WriteFU)mvt->size,
|
||||
" allocated: $U\n", (WriteFU)mvt->allocated,
|
||||
" available: $U\n", (WriteFU)mvt->available,
|
||||
" unavailable: $U\n", (WriteFU)mvt->unavailable,
|
||||
NULL);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
res = CBSDescribe(MVTCBS(mvt), stream);
|
||||
res = CBSDescribe(MVTCBS(mvt), stream, depth + 2);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
res = ABQDescribe(MVTABQ(mvt), (ABQDescribeElement)RangeDescribe, stream);
|
||||
res = ABQDescribe(MVTABQ(mvt), (ABQDescribeElement)RangeDescribe, stream,
|
||||
depth + 2);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
res = FreelistDescribe(MVTFreelist(mvt), stream);
|
||||
res = FreelistDescribe(MVTFreelist(mvt), stream, depth + 2);
|
||||
if(res != ResOK) return res;
|
||||
|
||||
METER_WRITE(mvt->segAllocs, stream);
|
||||
METER_WRITE(mvt->segFrees, stream);
|
||||
METER_WRITE(mvt->bufferFills, stream);
|
||||
METER_WRITE(mvt->bufferEmpties, stream);
|
||||
METER_WRITE(mvt->poolFrees, stream);
|
||||
METER_WRITE(mvt->poolSize, stream);
|
||||
METER_WRITE(mvt->poolAllocated, stream);
|
||||
METER_WRITE(mvt->poolAvailable, stream);
|
||||
METER_WRITE(mvt->poolUnavailable, stream);
|
||||
METER_WRITE(mvt->poolUtilization, stream);
|
||||
METER_WRITE(mvt->finds, stream);
|
||||
METER_WRITE(mvt->overflows, stream);
|
||||
METER_WRITE(mvt->underflows, stream);
|
||||
METER_WRITE(mvt->refills, stream);
|
||||
METER_WRITE(mvt->refillPushes, stream);
|
||||
METER_WRITE(mvt->returns, stream);
|
||||
METER_WRITE(mvt->perfectFits, stream);
|
||||
METER_WRITE(mvt->firstFits, stream);
|
||||
METER_WRITE(mvt->secondFits, stream);
|
||||
METER_WRITE(mvt->failures, stream);
|
||||
METER_WRITE(mvt->emergencyContingencies, stream);
|
||||
METER_WRITE(mvt->fragLimitContingencies, stream);
|
||||
METER_WRITE(mvt->contingencySearches, stream);
|
||||
METER_WRITE(mvt->contingencyHardSearches, stream);
|
||||
METER_WRITE(mvt->splinters, stream);
|
||||
METER_WRITE(mvt->splintersUsed, stream);
|
||||
METER_WRITE(mvt->splintersDropped, stream);
|
||||
METER_WRITE(mvt->sawdust, stream);
|
||||
METER_WRITE(mvt->exceptions, stream);
|
||||
METER_WRITE(mvt->exceptionSplinters, stream);
|
||||
METER_WRITE(mvt->exceptionReturns, stream);
|
||||
METER_WRITE(mvt->segAllocs, stream, depth + 2);
|
||||
METER_WRITE(mvt->segFrees, stream, depth + 2);
|
||||
METER_WRITE(mvt->bufferFills, stream, depth + 2);
|
||||
METER_WRITE(mvt->bufferEmpties, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolFrees, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolSize, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolAllocated, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolAvailable, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolUnavailable, stream, depth + 2);
|
||||
METER_WRITE(mvt->poolUtilization, stream, depth + 2);
|
||||
METER_WRITE(mvt->finds, stream, depth + 2);
|
||||
METER_WRITE(mvt->overflows, stream, depth + 2);
|
||||
METER_WRITE(mvt->underflows, stream, depth + 2);
|
||||
METER_WRITE(mvt->refills, stream, depth + 2);
|
||||
METER_WRITE(mvt->refillPushes, stream, depth + 2);
|
||||
METER_WRITE(mvt->returns, stream, depth + 2);
|
||||
METER_WRITE(mvt->perfectFits, stream, depth + 2);
|
||||
METER_WRITE(mvt->firstFits, stream, depth + 2);
|
||||
METER_WRITE(mvt->secondFits, stream, depth + 2);
|
||||
METER_WRITE(mvt->failures, stream, depth + 2);
|
||||
METER_WRITE(mvt->emergencyContingencies, stream, depth + 2);
|
||||
METER_WRITE(mvt->fragLimitContingencies, stream, depth + 2);
|
||||
METER_WRITE(mvt->contingencySearches, stream, depth + 2);
|
||||
METER_WRITE(mvt->contingencyHardSearches, stream, depth + 2);
|
||||
METER_WRITE(mvt->splinters, stream, depth + 2);
|
||||
METER_WRITE(mvt->splintersUsed, stream, depth + 2);
|
||||
METER_WRITE(mvt->splintersDropped, stream, depth + 2);
|
||||
METER_WRITE(mvt->sawdust, stream, depth + 2);
|
||||
METER_WRITE(mvt->exceptions, stream, depth + 2);
|
||||
METER_WRITE(mvt->exceptionSplinters, stream, depth + 2);
|
||||
METER_WRITE(mvt->exceptionReturns, stream, depth + 2);
|
||||
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} MVT $P\n", (WriteFP)mvt, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ static PoolDebugMixin MVFFDebugMixin(Pool pool)
|
|||
|
||||
/* MVFFDescribe -- describe an MVFF pool */
|
||||
|
||||
static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
MVFF mvff;
|
||||
|
|
@ -679,7 +679,7 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (!TESTT(MVFF, mvff)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"MVFF $P {\n", (WriteFP)mvff,
|
||||
" pool $P ($U)\n",
|
||||
(WriteFP)pool, (WriteFU)pool->serial,
|
||||
|
|
@ -691,15 +691,15 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = CBSDescribe(CBSOfMVFF(mvff), stream);
|
||||
res = CBSDescribe(CBSOfMVFF(mvff), stream, depth + 2);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = FreelistDescribe(FreelistOfMVFF(mvff), stream);
|
||||
res = FreelistDescribe(FreelistOfMVFF(mvff), stream, depth + 2);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, "}\n", NULL);
|
||||
res = WriteF(depth, stream, "} MVFF $P\n", (WriteFP)mvff, NULL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static void NBufferEmpty(Pool pool, Buffer buffer,
|
|||
|
||||
/* NDescribe -- describe method for class N */
|
||||
|
||||
static Res NDescribe(Pool pool, mps_lib_FILE *stream)
|
||||
static Res NDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
PoolN poolN;
|
||||
|
||||
|
|
@ -142,6 +142,7 @@ static Res NDescribe(Pool pool, mps_lib_FILE *stream)
|
|||
AVERT(PoolN, poolN);
|
||||
|
||||
UNUSED(stream); /* TODO: should output something here */
|
||||
UNUSED(depth);
|
||||
|
||||
return ResOK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
#include "mpm.h"
|
||||
#include "pooln.h"
|
||||
#include "mpsavm.h"
|
||||
#include "testlib.h"
|
||||
#include "mpslib.h"
|
||||
#include "pooln.h"
|
||||
#include "testlib.h"
|
||||
|
||||
#include <stdio.h> /* printf */
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ static void testit(ArenaClass class, ArgList args)
|
|||
error("Error: Unexpectedly succeeded in"
|
||||
"allocating block from PoolN\n");
|
||||
}
|
||||
PoolDescribe(pool, mps_lib_get_stdout(), 0);
|
||||
PoolDestroy(pool);
|
||||
ArenaDestroy(arena);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,19 +39,19 @@ void RangeFinish(Range range)
|
|||
range->sig = SigInvalid;
|
||||
}
|
||||
|
||||
Res RangeDescribe(Range range, mps_lib_FILE *stream)
|
||||
Res RangeDescribe(Range range, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
AVERT(Range, range);
|
||||
AVER(stream != NULL);
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Range $P\n{\n", (WriteFP)range,
|
||||
" base: $P\n", (WriteFP)RangeBase(range),
|
||||
" limit: $P\n", (WriteFP)RangeLimit(range),
|
||||
" size: $U\n", (WriteFU)RangeSize(range),
|
||||
"}\n", NULL);
|
||||
"} Range $P\n", (WriteFP)range, NULL);
|
||||
if (res != ResOK) {
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ typedef struct RangeStruct *Range;
|
|||
|
||||
extern void RangeInit(Range range, Addr base, Addr limit);
|
||||
extern void RangeFinish(Range range);
|
||||
extern Res RangeDescribe(Range range, mps_lib_FILE *stream);
|
||||
extern Res RangeDescribe(Range range, mps_lib_FILE *stream, Count depth);
|
||||
extern Bool RangeCheck(Range range);
|
||||
extern Bool RangeIsAligned(Range range, Align align);
|
||||
extern Bool RangesOverlap(Range range1, Range range2);
|
||||
|
|
|
|||
|
|
@ -580,14 +580,14 @@ Res RootsIterate(Globals arena, RootIterateFn f, void *p)
|
|||
|
||||
/* RootDescribe -- describe a root */
|
||||
|
||||
Res RootDescribe(Root root, mps_lib_FILE *stream)
|
||||
Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Root, root)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Root $P ($U) {\n", (WriteFP)root, (WriteFU)root->serial,
|
||||
" arena $P ($U)\n", (WriteFP)root->arena,
|
||||
(WriteFU)root->arena->serial,
|
||||
|
|
@ -599,15 +599,16 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
|
|||
|
||||
switch(root->var) {
|
||||
case RootTABLE:
|
||||
res = WriteF(stream,
|
||||
" table base $A limit $A\n",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"table base $A limit $A\n",
|
||||
root->the.table.base, root->the.table.limit,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
break;
|
||||
|
||||
case RootTABLE_MASKED:
|
||||
res = WriteF(stream, " table base $A limit $A mask $B\n",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"table base $A limit $A mask $B\n",
|
||||
root->the.tableMasked.base, root->the.tableMasked.limit,
|
||||
root->the.tableMasked.mask,
|
||||
NULL);
|
||||
|
|
@ -615,26 +616,26 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
|
|||
break;
|
||||
|
||||
case RootFUN:
|
||||
res = WriteF(stream,
|
||||
" scan function $F\n", (WriteFF)root->the.fun.scan,
|
||||
" environment p $P s $W\n",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"scan function $F\n", (WriteFF)root->the.fun.scan,
|
||||
"environment p $P s $W\n",
|
||||
root->the.fun.p, (WriteFW)root->the.fun.s,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
break;
|
||||
|
||||
case RootREG:
|
||||
res = WriteF(stream,
|
||||
" thread $P\n", (WriteFP)root->the.reg.thread,
|
||||
" environment p $P", root->the.reg.p,
|
||||
res = WriteF(depth + 2, stream,
|
||||
"thread $P\n", (WriteFP)root->the.reg.thread,
|
||||
"environment p $P", root->the.reg.p,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
break;
|
||||
|
||||
case RootFMT:
|
||||
res = WriteF(stream,
|
||||
" scan function $F\n", (WriteFF)root->the.fmt.scan,
|
||||
" format base $A limit $A\n",
|
||||
res = WriteF(depth + 2, stream,
|
||||
"scan function $F\n", (WriteFF)root->the.fmt.scan,
|
||||
"format base $A limit $A\n",
|
||||
root->the.fmt.base, root->the.fmt.limit,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
|
@ -644,7 +645,7 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
|
|||
NOTREACHED;
|
||||
}
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"} Root $P ($U)\n", (WriteFP)root, (WriteFU)root->serial,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
|
@ -655,14 +656,14 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
|
|||
|
||||
/* RootsDescribe -- describe all roots */
|
||||
|
||||
Res RootsDescribe(Globals arenaGlobals, mps_lib_FILE *stream)
|
||||
Res RootsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res = ResOK;
|
||||
Ring node, next;
|
||||
|
||||
RING_FOR(node, &arenaGlobals->rootRing, next) {
|
||||
Root root = RING_ELT(Root, arenaRing, node);
|
||||
res = RootDescribe(root, stream); /* this outputs too much */
|
||||
res = RootDescribe(root, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ void SegSetBuffer(Seg seg, Buffer buffer)
|
|||
|
||||
/* SegDescribe -- describe a segment */
|
||||
|
||||
Res SegDescribe(Seg seg, mps_lib_FILE *stream)
|
||||
Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Pool pool;
|
||||
|
|
@ -365,7 +365,7 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
|
||||
pool = SegPool(seg);
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Segment $P [$A,$A) {\n", (WriteFP)seg,
|
||||
(WriteFA)SegBase(seg), (WriteFA)SegLimit(seg),
|
||||
" class $P (\"$S\")\n",
|
||||
|
|
@ -375,11 +375,13 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = seg->class->describe(seg, stream);
|
||||
res = seg->class->describe(seg, stream, depth + 2);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream, "\n",
|
||||
"} Segment $P\n", (WriteFP)seg, NULL);
|
||||
res = WriteF(0, stream, "\n", NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(depth, stream, "} Segment $P\n", (WriteFP)seg, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1023,59 +1025,30 @@ static Res segTrivSplit(Seg seg, Seg segHi,
|
|||
|
||||
/* segTrivDescribe -- Basic Seg description method */
|
||||
|
||||
static Res segTrivDescribe(Seg seg, mps_lib_FILE *stream)
|
||||
static Res segTrivDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Seg, seg)) return ResFAIL;
|
||||
if (stream == NULL) return ResFAIL;
|
||||
|
||||
res = WriteF(stream,
|
||||
" shield depth $U\n", (WriteFU)seg->depth,
|
||||
" protection mode:",
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
if (SegPM(seg) & AccessREAD) {
|
||||
res = WriteF(stream, " read", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
if (SegPM(seg) & AccessWRITE) {
|
||||
res = WriteF(stream, " write", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(stream, "\n shield mode:", NULL);
|
||||
if (res != ResOK) return res;
|
||||
if (SegSM(seg) & AccessREAD) {
|
||||
res = WriteF(stream, " read", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
if (SegSM(seg) & AccessWRITE) {
|
||||
res = WriteF(stream, " write", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(stream, "\n ranks:", NULL);
|
||||
if (res != ResOK) return res;
|
||||
/* This bit ought to be in a RankSetDescribe in ref.c. */
|
||||
if (RankSetIsMember(seg->rankSet, RankAMBIG)) {
|
||||
res = WriteF(stream, " ambiguous", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
if (RankSetIsMember(seg->rankSet, RankEXACT)) {
|
||||
res = WriteF(stream, " exact", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
if (RankSetIsMember(seg->rankSet, RankFINAL)) {
|
||||
res = WriteF(stream, " final", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
if (RankSetIsMember(seg->rankSet, RankWEAK)) {
|
||||
res = WriteF(stream, " weak", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
res = WriteF(stream, "\n",
|
||||
" white $B\n", (WriteFB)seg->white,
|
||||
" grey $B\n", (WriteFB)seg->grey,
|
||||
" nailed $B\n", (WriteFB)seg->nailed,
|
||||
res = WriteF(depth, stream,
|
||||
"shield depth $U\n", (WriteFU)seg->depth,
|
||||
"protection mode: ",
|
||||
(SegPM(seg) & AccessREAD) ? "" : "!", "READ", " ",
|
||||
(SegPM(seg) & AccessWRITE) ? "" : "!", "WRITE", "\n",
|
||||
"shield mode: ",
|
||||
(SegSM(seg) & AccessREAD) ? "" : "!", "READ", " ",
|
||||
(SegSM(seg) & AccessWRITE) ? "" : "!", "WRITE", "\n",
|
||||
"ranks:",
|
||||
RankSetIsMember(seg->rankSet, RankAMBIG) ? " ambiguous" : "",
|
||||
RankSetIsMember(seg->rankSet, RankEXACT) ? " exact" : "",
|
||||
RankSetIsMember(seg->rankSet, RankFINAL) ? " final" : "",
|
||||
RankSetIsMember(seg->rankSet, RankWEAK) ? " weak" : "",
|
||||
"\n",
|
||||
"white $B\n", (WriteFB)seg->white,
|
||||
"grey $B\n", (WriteFB)seg->grey,
|
||||
"nailed $B\n", (WriteFB)seg->nailed,
|
||||
NULL);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1611,7 +1584,7 @@ failSuper:
|
|||
|
||||
/* gcSegDescribe -- GCSeg description method */
|
||||
|
||||
static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream)
|
||||
static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
SegClass super;
|
||||
|
|
@ -1624,19 +1597,18 @@ static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream)
|
|||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
super = SEG_SUPERCLASS(GCSegClass);
|
||||
res = super->describe(seg, stream);
|
||||
res = super->describe(seg, stream, depth);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream,
|
||||
" summary $W\n", (WriteFW)gcseg->summary,
|
||||
res = WriteF(depth, stream,
|
||||
"summary $W\n", (WriteFW)gcseg->summary,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
if (gcseg->buffer == NULL) {
|
||||
res = WriteF(stream, " buffer: NULL\n", NULL);
|
||||
}
|
||||
else {
|
||||
res = BufferDescribe(gcseg->buffer, stream);
|
||||
res = WriteF(depth, stream, "buffer: NULL\n", NULL);
|
||||
} else {
|
||||
res = BufferDescribe(gcseg->buffer, stream, depth);
|
||||
}
|
||||
if (res != ResOK) return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -1006,7 +1006,8 @@ Tree SplayTreeNext(SplayTree splay, TreeKey oldKey) {
|
|||
*/
|
||||
|
||||
static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
|
||||
SplayNodeDescribeMethod nodeDescribe) {
|
||||
SplayNodeDescribeMethod nodeDescribe)
|
||||
{
|
||||
Res res;
|
||||
|
||||
#if defined(AVER_AND_CHECK)
|
||||
|
|
@ -1014,14 +1015,14 @@ static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
|
|||
/* stream and nodeDescribe checked by SplayTreeDescribe */
|
||||
#endif
|
||||
|
||||
res = WriteF(stream, "( ", NULL);
|
||||
res = WriteF(0, stream, "( ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
if (TreeHasLeft(node)) {
|
||||
res = SplayNodeDescribe(TreeLeft(node), stream, nodeDescribe);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream, " / ", NULL);
|
||||
res = WriteF(0, stream, " / ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
|
|
@ -1029,14 +1030,14 @@ static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
|
|||
if (res != ResOK) return res;
|
||||
|
||||
if (TreeHasRight(node)) {
|
||||
res = WriteF(stream, " \\ ", NULL);
|
||||
res = WriteF(0, stream, " \\ ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = SplayNodeDescribe(TreeRight(node), stream, nodeDescribe);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, " )", NULL);
|
||||
res = WriteF(0, stream, " )", NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
return ResOK;
|
||||
|
|
@ -1323,8 +1324,9 @@ void SplayNodeRefresh(SplayTree splay, Tree node)
|
|||
* See <design/splay/#function.splay.tree.describe>.
|
||||
*/
|
||||
|
||||
Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream,
|
||||
SplayNodeDescribeMethod nodeDescribe) {
|
||||
Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth,
|
||||
SplayNodeDescribeMethod nodeDescribe)
|
||||
{
|
||||
Res res;
|
||||
|
||||
#if defined(AVER_AND_CHECK)
|
||||
|
|
@ -1333,18 +1335,20 @@ Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream,
|
|||
if (!FUNCHECK(nodeDescribe)) return ResFAIL;
|
||||
#endif
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Splay $P {\n", (WriteFP)splay,
|
||||
" compare $F\n", (WriteFF)splay->compare,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
if (SplayTreeRoot(splay) != TreeEMPTY) {
|
||||
res = WriteF(depth, stream, " tree ", NULL);
|
||||
if (res != ResOK) return res;
|
||||
res = SplayNodeDescribe(SplayTreeRoot(splay), stream, nodeDescribe);
|
||||
if (res != ResOK) return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, "\n}\n", NULL);
|
||||
res = WriteF(depth, stream, "\n} Splay $P\n", (WriteFP)splay, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ extern Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
|
|||
extern void SplayNodeRefresh(SplayTree splay, Tree node);
|
||||
|
||||
extern Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream,
|
||||
Count depth,
|
||||
SplayNodeDescribeMethod nodeDescribe);
|
||||
|
||||
extern void SplayDebugUpdate(SplayTree splay, Tree tree);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ extern Bool ThreadCheck(Thread thread);
|
|||
extern Bool ThreadCheckSimple(Thread thread);
|
||||
|
||||
|
||||
extern Res ThreadDescribe(Thread thread, mps_lib_FILE *stream);
|
||||
extern Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth);
|
||||
|
||||
|
||||
/* Register/Deregister
|
||||
|
|
|
|||
|
|
@ -128,11 +128,11 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
|
|||
}
|
||||
|
||||
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
|
||||
" arena $P ($U)\n",
|
||||
(WriteFP)thread->arena, (WriteFU)thread->arena->serial,
|
||||
|
|
|
|||
|
|
@ -272,11 +272,11 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
|
|||
|
||||
/* ThreadDescribe -- describe a thread */
|
||||
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
|
||||
" arena $P ($U)\n",
|
||||
(WriteFP)thread->arena, (WriteFU)thread->arena->serial,
|
||||
|
|
|
|||
|
|
@ -212,11 +212,11 @@ Arena ThreadArena(Thread thread)
|
|||
return thread->arena;
|
||||
}
|
||||
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
|
||||
" arena $P ($U)\n",
|
||||
(WriteFP)thread->arena, (WriteFU)thread->arena->serial,
|
||||
|
|
|
|||
|
|
@ -248,11 +248,11 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
|
|||
}
|
||||
|
||||
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
|
||||
Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
|
||||
" arena $P ($U)\n",
|
||||
(WriteFP)thread->arena, (WriteFU)thread->arena->serial,
|
||||
|
|
|
|||
|
|
@ -1901,7 +1901,7 @@ failStart:
|
|||
|
||||
/* TraceDescribe -- describe a trace */
|
||||
|
||||
Res TraceDescribe(Trace trace, mps_lib_FILE *stream)
|
||||
Res TraceDescribe(Trace trace, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
const char *state;
|
||||
|
|
@ -1918,7 +1918,8 @@ Res TraceDescribe(Trace trace, mps_lib_FILE *stream)
|
|||
default: state = "unknown"; break;
|
||||
}
|
||||
|
||||
res = WriteF(stream, "Trace $P ($U) {\n", (WriteFP)trace, (WriteFU)trace->ti,
|
||||
res = WriteF(depth, stream,
|
||||
"Trace $P ($U) {\n", (WriteFP)trace, (WriteFU)trace->ti,
|
||||
"arena $P ($U)\n", (WriteFP)trace->arena,
|
||||
(WriteFU)trace->arena->serial,
|
||||
"why \"$S\"\n", (WriteFS)TraceStartWhyToString(trace->why),
|
||||
|
|
@ -1940,7 +1941,7 @@ Res TraceDescribe(Trace trace, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = WriteF(stream, "} Trace $P\n", (WriteFP)trace, NULL);
|
||||
res = WriteF(depth, stream, "} Trace $P\n", (WriteFP)trace, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -243,10 +243,10 @@ setter method which sets the rank set of a buffer. It is called from
|
|||
``BufferSetRankSet()``. Clients should not need to define their own
|
||||
methods for this.
|
||||
|
||||
``typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream)``
|
||||
``typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.class.method.describe`: ``describe()`` is a class-specific method
|
||||
called to describe a buffer, via BufferDescribe. Client-defined
|
||||
called to describe a buffer, via ``BufferDescribe()``. Client-defined
|
||||
methods must call their superclass method (via a next-method call)
|
||||
before describing any class-specific state.
|
||||
|
||||
|
|
|
|||
|
|
@ -167,13 +167,12 @@ and an iterator method to invoke on every range in address order. If
|
|||
the iterator method returns ``FALSE``, then the iteration is
|
||||
terminated.
|
||||
|
||||
``Res CBSDescribe(CBS cbs, mps_lib_FILE *stream)``
|
||||
``Res CBSDescribe(CBS cbs, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.function.cbs.describe`: ``CBSDescribe()`` is a function that prints
|
||||
a textual representation of the CBS to the given stream, indicating
|
||||
the contiguous ranges in order, as well as the structure of the
|
||||
underlying splay tree implementation. It is provided for debugging
|
||||
purposes only.
|
||||
_`.function.cbs.describe`: ``CBSDescribe()`` prints a textual
|
||||
representation of the CBS to the given stream, indicating the
|
||||
contiguous ranges in order, as well as the structure of the underlying
|
||||
splay tree implementation. It is provided for debugging only.
|
||||
|
||||
``Bool CBSFindFirst(Range rangeReturn, Range oldRangeReturn, CBS cbs, Size size, FindDelete findDelete)``
|
||||
|
||||
|
|
@ -291,8 +290,8 @@ simulates the allocation and deallocation of ranges within this block
|
|||
using both a ``CBS`` and a ``BT``. It makes both valid and invalid
|
||||
requests, and compares the ``CBS`` response to the correct behaviour
|
||||
as determined by the ``BT``. It also iterates the ranges in the
|
||||
``CBS``, comparing them to the ``BT``. It also invokes the
|
||||
``CBSDescribe()`` method, but makes no automatic test of the resulting
|
||||
``CBS``, comparing them to the ``BT``. It also invokes
|
||||
``CBSDescribe()``, but makes no automatic test of the resulting
|
||||
output. It does not currently test the callbacks.
|
||||
|
||||
_`.test.pool`: Several pools (currently MVT_ and MVFF_) are implemented
|
||||
|
|
|
|||
|
|
@ -77,21 +77,23 @@ There are two mechanism for getting diagnostic output:
|
|||
(gdb) frame 12
|
||||
#12 0x000000010000b1fc in MVTFree (pool=0x103ffe160, base=0x101dfd000, size=5024) at poolmv2.c:711
|
||||
711 Res res = CBSInsert(MVTCBS(mvt), base, limit);
|
||||
(gdb) p MVTDescribe(mvt, mps_lib_get_stdout())
|
||||
MVT 0000000103FFE160
|
||||
{
|
||||
minSize: 8
|
||||
meanSize: 42
|
||||
maxSize: 8192
|
||||
fragLimit: 30
|
||||
reuseSize: 16384
|
||||
fillSize: 8192
|
||||
availLimit: 1110835
|
||||
abqOverflow: FALSE
|
||||
splinter: TRUE
|
||||
splinterSeg: 0000000103FEE780
|
||||
splinterBase: 0000000101D7ABB8
|
||||
splinterLimit: 0000000101D7B000
|
||||
(gdb) p MVTDescribe(mvt, mps_lib_get_stdout(), 0)
|
||||
MVT 0000000103FFE160 {
|
||||
minSize: 8
|
||||
meanSize: 42
|
||||
maxSize: 8192
|
||||
fragLimit: 30
|
||||
reuseSize: 16384
|
||||
fillSize: 8192
|
||||
availLimit: 90931
|
||||
abqOverflow: FALSE
|
||||
splinter: TRUE
|
||||
splinterBase: 0000000106192FF0
|
||||
splinterLimit: 0000000106193000
|
||||
size: 303104
|
||||
allocated: 262928
|
||||
available: 40176
|
||||
unavailable: 0
|
||||
# ... etc ...
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,11 +203,11 @@ the Coalescing Block Structure ``cbs``. Continue until a call to
|
|||
``CBSInsert()`` fails, or until the free list is empty, whichever
|
||||
happens first.
|
||||
|
||||
``Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream)``
|
||||
``Res FreelistDescribe(Freelist fl, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.function.describe`: Print a textual representation of the free
|
||||
list ``fl`` to the given stream, indicating the contiguous ranges in
|
||||
order. It is provided for debugging purposes only.
|
||||
order. It is provided for debugging only.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ objects. Now reclaim doesn't need to check that the objects are
|
|||
allocated before skipping them. There may be a corresponding change
|
||||
for scan as well.
|
||||
|
||||
``Res AWLDescribe(Pool pool, mps_lib_FILE *stream)``
|
||||
``Res AWLDescribe(Pool pool, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.fun.describe`:
|
||||
|
||||
|
|
|
|||
|
|
@ -471,11 +471,12 @@ required.
|
|||
See analysis.mps.poolmrg.improve.scan.nomove for a suggested
|
||||
improvement that avoids redundant unlinking and relinking.
|
||||
|
||||
``Res MRGDescribe(Pool pool, mps_lib_FILE *stream)``
|
||||
``Res MRGDescribe(Pool pool, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.describe`: Describes an MRG pool. Iterates along each of the entry
|
||||
and exit lists and prints the guardians in each. The location of the
|
||||
guardian and the value of the reference in it will be printed out.
|
||||
Provided for debugging only.
|
||||
|
||||
_`.functions.unused`: All of these will be unused: ``BufferInit()``,
|
||||
``BufferFill()``, ``BufferEmpty()``, ``BufferFinish()``,
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ _`.type.splay.node.describe.method`: A function of type
|
|||
``SplayNodeDescribeMethod`` is required to write (via ``WriteF()``) a
|
||||
client-oriented representation of the splay node. The output should be
|
||||
non-empty, short, and without return characters. This is provided for
|
||||
debugging purposes only.
|
||||
debugging only.
|
||||
|
||||
``typedef Bool (*SplayTestNodeMethod)(SplayTree splay, Tree tree, void *closureP, unsigned long closureS)``
|
||||
|
||||
|
|
@ -323,12 +323,13 @@ tree was previously beneficially balanced for a small working set of
|
|||
accesses, then this local optimization will be lost. (see
|
||||
`.future.parent`_).
|
||||
|
||||
``Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, SplayNodeDescribeMethod nodeDescribe)``
|
||||
``Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth, SplayNodeDescribeMethod nodeDescribe)``
|
||||
|
||||
_`.function.splay.tree.describe`: This function prints (using
|
||||
``WriteF``) to the stream a textual representation of the given splay
|
||||
tree, using ``nodeDescribe`` to print client-oriented representations
|
||||
of the nodes (see `.req.debug`_).
|
||||
``WriteF()``) to the stream a textual representation of the given
|
||||
splay tree, using ``nodeDescribe()`` to print client-oriented
|
||||
representations of the nodes (see `.req.debug`_). Provided for
|
||||
debugging only.
|
||||
|
||||
``Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, void *closureP, unsigned long closureS)``
|
||||
|
||||
|
|
@ -368,19 +369,19 @@ _`.prop`: To support `.req.property.find`_, this splay tree
|
|||
implementation provides additional features to permit clients to cache
|
||||
maximum (or minimum) values of client properties for all the nodes in
|
||||
a subtree. The splay tree implementation uses the cached values as
|
||||
part of ``SplayFindFirst`` and ``SplayFindLast`` via the ``testNode``
|
||||
and ``testTree`` methods. The client is free to choose how to
|
||||
represent the client property, and how to compute and store the cached
|
||||
value.
|
||||
part of ``SplayFindFirst()`` and ``SplayFindLast()`` via the
|
||||
``testNode`` and ``testTree`` methods. The client is free to choose
|
||||
how to represent the client property, and how to compute and store the
|
||||
cached value.
|
||||
|
||||
_`.prop.update`: The cached values depend upon the topology of the
|
||||
tree, which may vary as a result of operations on the tree. The client
|
||||
is given the opportunity to compute new cache values whenever
|
||||
necessary, via the ``updateNode`` method (see
|
||||
`.function.splay.tree.init`_). This happens whenever the tree is
|
||||
restructured. The client may use the ``SplayNodeRefresh`` method to
|
||||
restructured. The client may use the ``SplayNodeRefresh()`` method to
|
||||
indicate that the client attributes at a node have changed (see
|
||||
`.req.property.change`_). A call to ``SplayNodeRefresh`` splays the
|
||||
`.req.property.change`_). A call to ``SplayNodeRefresh()`` splays the
|
||||
tree at the specified node, which may provoke calls to the
|
||||
``updateNode`` method as a result of the tree restructuring. The
|
||||
``updateNode`` method will also be called whenever a new splay node is
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ _`.debug.dump`: The contents of all buffers can be dumped with the
|
|||
_`.debug.describe`: Individual events can be described with the
|
||||
EventDescribe function, for example::
|
||||
|
||||
gdb> print EventDescribe(EventLast[3], mps_lib_get_stdout())
|
||||
gdb> print EventDescribe(EventLast[3], mps_lib_get_stdout(), 0)
|
||||
|
||||
_`.debug.core`: The event buffers are preserved in core dumps and can
|
||||
be used to work out what the MPS was doing before a crash. Since the
|
||||
|
|
|
|||
|
|
@ -38,13 +38,17 @@ _`.writef`: Our output requirements are few, so the code is short. The
|
|||
only output function which should be used in the rest of the MPM is
|
||||
``WriteF()``.
|
||||
|
||||
``Res WriteF(mps_lib_FILE *stream, ...)``
|
||||
``Res WriteF(Count depth, mps_lib_FILE *stream, ...)``
|
||||
|
||||
If ``depth`` is greater than zero, then the first format character,
|
||||
and each format character after a newline, is preceded by ``depth``
|
||||
spaces.
|
||||
|
||||
``WriteF()`` expects a format string followed by zero or more items to
|
||||
insert into the output, followed by another format string, more items,
|
||||
and so on, and finally a ``NULL`` format string. For example::
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Hello: $A\n", address,
|
||||
"Spong: $U ($S)\n", number, string,
|
||||
NULL);
|
||||
|
|
@ -52,25 +56,28 @@ and so on, and finally a ``NULL`` format string. For example::
|
|||
|
||||
This makes ``Describe()`` methods much easier to write. For example, ``BufferDescribe()`` contains the following code::
|
||||
|
||||
res = WriteF(stream,
|
||||
res = WriteF(depth, stream,
|
||||
"Buffer $P ($U) {\n",
|
||||
(WriteFP)buffer, (WriteFU)buffer->serial,
|
||||
"class $P (\"$S\")\n",
|
||||
" class $P (\"$S\")\n",
|
||||
(WriteFP)buffer->class, buffer->class->name,
|
||||
"Arena $P\n", (WriteFP)buffer->arena,
|
||||
"Pool $P\n", (WriteFP)buffer->pool,
|
||||
buffer->isMutator ? "Mutator" : "Internal", " Buffer\n",
|
||||
"mode $S (TRANSITION, LOGGED, FLIPPED, ATTACHED)\n",
|
||||
(WriteFS)abzMode,
|
||||
"fillSize $UKb\n", (WriteFU)(buffer->fillSize / 1024),
|
||||
"emptySize $UKb\n", (WriteFU)(buffer->emptySize / 1024),
|
||||
"alignment $W\n", (WriteFW)buffer->alignment,
|
||||
"base $A\n", buffer->base,
|
||||
"initAtFlip $A\n", buffer->initAtFlip,
|
||||
"init $A\n", buffer->ap_s.init,
|
||||
"alloc $A\n", buffer->ap_s.alloc,
|
||||
"limit $A\n", buffer->ap_s.limit,
|
||||
"poolLimit $A\n", buffer->poolLimit,
|
||||
" Arena $P\n", (WriteFP)buffer->arena,
|
||||
" Pool $P\n", (WriteFP)buffer->pool,
|
||||
" ", buffer->isMutator ? "Mutator" : "Internal", " Buffer\n",
|
||||
" mode $C$C$C$C (TRANSITION, LOGGED, FLIPPED, ATTACHED)\n",
|
||||
(WriteFC)((buffer->mode & BufferModeTRANSITION) ? 't' : '_'),
|
||||
(WriteFC)((buffer->mode & BufferModeLOGGED) ? 'l' : '_'),
|
||||
(WriteFC)((buffer->mode & BufferModeFLIPPED) ? 'f' : '_'),
|
||||
(WriteFC)((buffer->mode & BufferModeATTACHED) ? 'a' : '_'),
|
||||
" fillSize $UKb\n", (WriteFU)(buffer->fillSize / 1024),
|
||||
" emptySize $UKb\n", (WriteFU)(buffer->emptySize / 1024),
|
||||
" alignment $W\n", (WriteFW)buffer->alignment,
|
||||
" base $A\n", buffer->base,
|
||||
" initAtFlip $A\n", buffer->initAtFlip,
|
||||
" init $A\n", buffer->ap_s.init,
|
||||
" alloc $A\n", buffer->ap_s.alloc,
|
||||
" limit $A\n", buffer->ap_s.limit,
|
||||
" poolLimit $A\n", buffer->poolLimit,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
|
|
@ -93,7 +100,7 @@ used in future in some generalisation of varargs in the MPS.
|
|||
_`.formats`: The formats supported are as follows.
|
||||
|
||||
======= =========== ================== ======================================
|
||||
Code Bame Type Example rendering
|
||||
Code Name Type Example rendering
|
||||
======= =========== ================== ======================================
|
||||
``$A`` address ``Addr`` ``000000019EF60010``
|
||||
``$P`` pointer ``void *`` ``000000019EF60100``
|
||||
|
|
@ -111,8 +118,8 @@ promotion of a ``char`` (see `.types`_).
|
|||
|
||||
_`.snazzy`: We should resist the temptation to make ``WriteF()`` an
|
||||
incredible snazzy output engine. We only need it for ``Describe()``
|
||||
methods. At the moment it's a very simple bit of code -- let's keep it
|
||||
that way.
|
||||
methods. At the moment it's a simple bit of code -- let's keep it that
|
||||
way.
|
||||
|
||||
_`.f`: The ``F`` code is used for function pointers. ISO C forbids casting
|
||||
function pointers to other types, so the bytes of their representation are
|
||||
|
|
@ -129,7 +136,7 @@ Document History
|
|||
|
||||
- 2013-05-22 GDR_ Converted to reStructuredText.
|
||||
|
||||
- 2014-04-17 GDR_ Add design for maintaining indentation.
|
||||
- 2014-04-17 GDR_ ``WriteF()`` now takes a ``depth`` parameter.
|
||||
|
||||
.. _RB: http://www.ravenbrook.com/consultants/rb/
|
||||
.. _GDR: http://www.ravenbrook.com/consultants/gdr/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue