From 6f9eea08def78ca4273b759b428f66814b660a38 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Wed, 21 Mar 2007 17:35:45 +0000 Subject: [PATCH 1/6] Mps branch unfixed-summary: better segdescribe: all segs: say "buffer: NULL" if it is (rather than saying nothing) AMC: correct SEG_SUPERCLASS, so we see GCSeg fields, and say if there's a nailboard. Copied from Perforce Change: 161973 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 15 +++++++++++++-- mps/code/seg.c | 16 +++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index df0716571cb..67cf3eff7f5 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -26,6 +26,7 @@ typedef struct amcGenStruct *amcGen; /* forward declarations */ +static Bool amcSegHasNailboard(Seg seg); static Bool AMCCheck(AMC amc); static Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO); static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO); @@ -160,7 +161,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) if (!CHECKT(amcSeg, amcseg)) return ResFAIL; /* Describe the superclass fields first via next-method call */ - super = SEG_SUPERCLASS(GCSegClass); + super = SEG_SUPERCLASS(amcSegClass); res = super->describe(seg, stream); if (res != ResOK) return res; @@ -179,10 +180,20 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) res = WriteF(stream, "AMC seg $P [$A,$A){\n", (WriteFP)seg, (WriteFA)base, (WriteFA)limit, - " Map\n", NULL); if (res != ResOK) return res; + if (amcSegHasNailboard(seg)) { + res = WriteF(stream, " Boarded\n", NULL); + /* @@@@ should have AMCNailboardDescribe() */ + } else { + res = WriteF(stream, " Mobile or Stuck\n", NULL); + } + if (res != ResOK) return res; + + res = WriteF(stream, " Map\n", NULL); + if (res != ResOK) return res; + for(i = base; i < limit; i = AddrAdd(i, row)) { Addr j; char c; diff --git a/mps/code/seg.c b/mps/code/seg.c index 9f6b485d5c0..e8a2b376b57 100644 --- a/mps/code/seg.c +++ b/mps/code/seg.c @@ -1569,14 +1569,20 @@ static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream) res = super->describe(seg, stream); if (res != ResOK) return res; - if (gcseg->buffer != NULL) { - res = BufferDescribe(gcseg->buffer, stream); - if (res != ResOK) return res; - } res = WriteF(stream, " summary $W\n", (WriteFW)gcseg->summary, NULL); - return res; + if (res != ResOK) return res; + + if (gcseg->buffer == NULL) { + res = WriteF(stream, " buffer: NULL\n", NULL); + } + else { + res = BufferDescribe(gcseg->buffer, stream); + } + if (res != ResOK) return res; + + return ResOK; } From 7ca4179235f1f358a596c621a914e495cc16f131 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Thu, 22 Mar 2007 13:52:40 +0000 Subject: [PATCH 2/6] Mps br/unfixed-summary: good: bufferdescribe now interprets buffer->mode for you Copied from Perforce Change: 161977 ServerID: perforce.ravenbrook.com --- mps/code/buffer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mps/code/buffer.c b/mps/code/buffer.c index 6e6616fc5b8..b4c210882f5 100644 --- a/mps/code/buffer.c +++ b/mps/code/buffer.c @@ -147,10 +147,17 @@ Bool BufferCheck(Buffer buffer) Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream) { Res res; + char aczMode[5]; if (!CHECKT(Buffer, buffer)) return ResFAIL; if (stream == NULL) return ResFAIL; + aczMode[0] = (buffer->mode & BufferModeTRANSITION) ? 't' : '_'; + aczMode[1] = (buffer->mode & BufferModeLOGGED) ? 'l' : '_'; + aczMode[2] = (buffer->mode & BufferModeFLIPPED) ? 'f' : '_'; + aczMode[3] = (buffer->mode & BufferModeATTACHED) ? 'a' : '_'; + aczMode[4] = '\0'; + res = WriteF(stream, "Buffer $P ($U) {\n", (WriteFP)buffer, (WriteFU)buffer->serial, @@ -160,7 +167,8 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream) " Pool $P\n", (WriteFP)buffer->pool, buffer->isMutator ? " Mutator Buffer\n" : " Internal Buffer\n", - " Mode $B\n", (WriteFB)(buffer->mode), + " mode $S (TRANSITION, LOGGED, FLIPPED, ATTACHED)\n", + (WriteFS)aczMode, " fillSize $UKb\n", (WriteFU)(buffer->fillSize / 1024), " emptySize $UKb\n", (WriteFU)(buffer->emptySize / 1024), " alignment $W\n", (WriteFW)buffer->alignment, From d46ebba46c141e9d55519d064c3661644dc85142 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Thu, 22 Mar 2007 14:02:14 +0000 Subject: [PATCH 3/6] Mps br/unfixed-summary: good: amcsegcheck: nailboard onlyif segnailed; AMCSegDescribe now splits Mobile vs. Stuck, clearer Map symbols, add key. Copied from Perforce Change: 161978 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 67cf3eff7f5..496e4876801 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -106,6 +106,9 @@ static Bool amcSegCheck(amcSeg amcseg) CHECKD(GCSeg, &amcseg->gcSegStruct); CHECKL(*amcseg->segTypeP == AMCPTypeNailboard || *amcseg->segTypeP == AMCPTypeGen); + if (*amcseg->segTypeP == AMCPTypeNailboard) { + CHECKL(SegNailed(amcSeg2Seg(amcseg)) != TraceSetEMPTY); + } CHECKL(BoolCheck(amcseg->new)); return TRUE; } @@ -172,10 +175,6 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) base = SegBase(seg); p = AddrAdd(base, pool->format->headerSize); limit = SegLimit(seg); - if (SegBuffer(seg) != NULL) - init = BufferGetInit(SegBuffer(seg)); - else - init = limit; res = WriteF(stream, "AMC seg $P [$A,$A){\n", @@ -187,13 +186,22 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) res = WriteF(stream, " Boarded\n", NULL); /* @@@@ should have AMCNailboardDescribe() */ } else { - res = WriteF(stream, " Mobile or Stuck\n", NULL); + if (SegNailed(seg) == TraceSetEMPTY) { + res = WriteF(stream, " Mobile\n", NULL); + } else { + res = WriteF(stream, " Stuck\n", NULL); + } } if (res != ResOK) return res; - res = WriteF(stream, " Map\n", NULL); + res = WriteF(stream, " Map: *===:object bbbb:buffer\n", NULL); if (res != ResOK) return res; + if (SegBuffer(seg) != NULL) + init = BufferGetInit(SegBuffer(seg)); + else + init = limit; + for(i = base; i < limit; i = AddrAdd(i, row)) { Addr j; char c; @@ -207,7 +215,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) if (j >= limit) c = ' '; else if (j >= init) - c = '.'; + c = 'b'; else if (j == p) { c = '*'; p = (pool->format->skip)(p); From 84f8809886f69895e06e5e45d6920111e9c51bd3 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Thu, 22 Mar 2007 14:08:57 +0000 Subject: [PATCH 4/6] Mps br/unfixed-summary: (debug only): on entering et (emergency tracing), SegDescribe the seg being scanned, and the seg being Fixed (ie. holding the referent object that we have just failed to forward). Copied from Perforce Change: 161979 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 19 ++++++++++++++++++- mps/code/trace.c | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 496e4876801..57e4472eec0 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -1282,6 +1282,15 @@ static Res AMCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg) format = pool->format; arena = pool->arena; + + /* what is a typical buffer state? */ + if (SegBuffer(seg) != NULL) { + static int lots = 5; + if (lots > 0) { + lots -= 1; + SegDescribe(seg, mps_lib_get_stdout()); + } + } if (amcSegHasNailboard(seg)) { return amcScanNailed(totalReturn, ss, pool, seg, amc); @@ -1507,8 +1516,16 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) ss->forwardedSize += length; do { res = BUFFER_RESERVE(&newRef, buffer, length, FALSE); - if (res != ResOK) + if (res != ResOK) { + WriteF(mps_lib_get_stdout(), + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" + "AMCFix forwarding buffer: BUFFER_RESERVE failed,\n" + "Referent object is in this seg:\n", + NULL + ); + SegDescribe(seg, mps_lib_get_stdout()); goto returnRes; + } toSeg = BufferSeg(buffer); ShieldExpose(arena, toSeg); diff --git a/mps/code/trace.c b/mps/code/trace.c index ff76600689b..eaf948c6fa5 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c @@ -1093,6 +1093,13 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg) /* Expose the segment to make sure we can scan it. */ ShieldExpose(arena, seg); res = PoolScan(&wasTotal, &ss, SegPool(seg), seg); + if (res != ResOK) { + WriteF(mps_lib_get_stdout(), + "PoolScan failed on this seg:\n", + NULL + ); + SegDescribe(seg, mps_lib_get_stdout()); + } /* Cover, regardless of result */ ShieldCover(arena, seg); From 1c7dc02bda03b3aec59f47d601fcb5c1398e4bed Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Thu, 22 Mar 2007 14:10:49 +0000 Subject: [PATCH 5/6] Mps br/unfixed-summary: (debug only): drop 5x bufferdescribes Copied from Perforce Change: 161980 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 57e4472eec0..37bf35abee9 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -1282,15 +1282,6 @@ static Res AMCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg) format = pool->format; arena = pool->arena; - - /* what is a typical buffer state? */ - if (SegBuffer(seg) != NULL) { - static int lots = 5; - if (lots > 0) { - lots -= 1; - SegDescribe(seg, mps_lib_get_stdout()); - } - } if (amcSegHasNailboard(seg)) { return amcScanNailed(totalReturn, ss, pool, seg, amc); From 8bf324c5523c05002ca12d0b8681e3fa9528c9d5 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Thu, 22 Mar 2007 14:57:29 +0000 Subject: [PATCH 6/6] Mps br/unfixed-summary: good: tidy bufferdescribe and amcsegdescribe. Copied from Perforce Change: 161982 ServerID: perforce.ravenbrook.com --- mps/code/buffer.c | 14 +++++++------- mps/code/poolamc.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mps/code/buffer.c b/mps/code/buffer.c index b4c210882f5..e55c12a7e8d 100644 --- a/mps/code/buffer.c +++ b/mps/code/buffer.c @@ -147,16 +147,16 @@ Bool BufferCheck(Buffer buffer) Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream) { Res res; - char aczMode[5]; + char abzMode[5]; if (!CHECKT(Buffer, buffer)) return ResFAIL; if (stream == NULL) return ResFAIL; - aczMode[0] = (buffer->mode & BufferModeTRANSITION) ? 't' : '_'; - aczMode[1] = (buffer->mode & BufferModeLOGGED) ? 'l' : '_'; - aczMode[2] = (buffer->mode & BufferModeFLIPPED) ? 'f' : '_'; - aczMode[3] = (buffer->mode & BufferModeATTACHED) ? 'a' : '_'; - aczMode[4] = '\0'; + abzMode[0] = (buffer->mode & BufferModeTRANSITION) ? 't' : '_'; + abzMode[1] = (buffer->mode & BufferModeLOGGED) ? 'l' : '_'; + abzMode[2] = (buffer->mode & BufferModeFLIPPED) ? 'f' : '_'; + abzMode[3] = (buffer->mode & BufferModeATTACHED) ? 'a' : '_'; + abzMode[4] = '\0'; res = WriteF(stream, "Buffer $P ($U) {\n", @@ -168,7 +168,7 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream) buffer->isMutator ? " Mutator Buffer\n" : " Internal Buffer\n", " mode $S (TRANSITION, LOGGED, FLIPPED, ATTACHED)\n", - (WriteFS)aczMode, + (WriteFS)abzMode, " fillSize $UKb\n", (WriteFU)(buffer->fillSize / 1024), " emptySize $UKb\n", (WriteFU)(buffer->emptySize / 1024), " alignment $W\n", (WriteFW)buffer->alignment, diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 37bf35abee9..ea88776319b 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -213,7 +213,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream) /* @@@@ This misses a header-sized pad at the end. */ for(j = i; j < AddrAdd(i, row); j = AddrAdd(j, step)) { if (j >= limit) - c = ' '; + c = ' '; /* if seg is not a whole number of print rows */ else if (j >= init) c = 'b'; else if (j == p) {