STDebugSymbols.mesa
Edited by Bruce, 18-Sep-81 20:38:56
Edited by Sweet, 8-Jul-83 23:58:33
Edited by Haynes, 29-Nov-82 20:24:50
Sweet May 16, 1986 3:55:35 pm PDT
DIRECTORY
BasicTime,
BcdDefs USING [VersionStamp],
IO,
RESOut USING [
Handle, PChar, PCr, PNext, PNextNull, PNextUnsigned, PNull, PRope, PUnsigned],
Rope,
STDebugDefs USING [
HashForSei, PutHashString, PutModeName, PutTypeName, ShowLinks,
STCopyRead, TableBase, TableSize],
Symbols USING [
BodyRecord, bodyType, BTIndex, BTNull, CSENull, CTXIndex, CTXNull, CTXRecord,
ctxType, ExtensionType, HTIndex, HTNull, HTRecord, htType, ISEIndex,
ISENull, MDIndex, MDRecord, mdType, SEIndex, SENull, SERecord, seType],
SymbolSegment USING [ExtIndex, ExtRecord, extType],
Table USING [Base],
Tree USING [Link, Null, NullIndex];
STDebugSymbols: PROGRAM
IMPORTS BasicTime, IO, RESOut, STDebugDefs
EXPORTS STDebugDefs =
BEGIN OPEN Symbols, RESOut, STDebugDefs;
Handle: TYPE = RESOut.Handle;
ROPE: TYPE = Rope.ROPE;
ISERecord: TYPE = Symbols.SERecord.id;
PU: PROCEDURE [h: Handle, u: UNSPECIFIED] = LOOPHOLE[RESOut.PUnsigned];
PNextU: PROCEDURE [h: Handle, s: ROPE, num: UNSPECIFIED, indent: CARDINAL ← 2] =
LOOPHOLE[RESOut.PNextUnsigned];
NextSe: PUBLIC PROCEDURE [h: Handle, sei: ISEIndex] RETURNS [ISEIndex] =
BEGIN
seb: Table.Base;
ser: ISERecord;
IF sei = ISENull THEN RETURN [ISENull];
seb ← TableBase[h, seType];
STCopyRead[h: h, to: @ser, from: @seb[sei], nwords: SIZE [ISERecord]];
WITH ser SELECT FROM
terminal => RETURN[ISENull];
linked => RETURN[link];
ENDCASE -- sequential-- => RETURN[LOOPHOLE[sei+SIZE[sequential id SERecord]]];
END;
FindExt: PRIVATE PROCEDURE [h: Handle, sei: ISEIndex] RETURNS
[type: ExtensionType, tree: Tree.Link] =
BEGIN OPEN SymbolSegment;
extb: Table.Base = TableBase[h, extType];
exti: ExtIndex;
extr: ExtRecord;
extLimit: ExtIndex = LOOPHOLE[TableSize[h, extType]];
FOR exti ← FIRST[ExtIndex], exti + SIZE[ExtRecord] UNTIL exti = extLimit DO
STCopyRead[h: h, to: @extr, from: @extb[exti], nwords: SIZE[ExtRecord]];
IF extr.sei = sei THEN RETURN[extr.type, extr.tree];
ENDLOOP;
RETURN[none, Tree.Null];
END;
PutAsSei: PUBLIC PROCEDURE [h: Handle, sei: Symbols.SEIndex] RETURNS [id: BOOLFALSE] =
BEGIN
seb: Table.Base;
ser: SERecord;
hti: HTIndex;
seb ← TableBase[h, seType];
STCopyRead[h: h, to: @ser, from: @seb[sei],
nwords: SIZE [SERecord]];
PCr[h];
PRope[h, "seb["]; PU[h, sei]; PRope[h, "] "];
WITH se: ser SELECT FROM
id =>
BEGIN
id ← TRUE;
hti ← HashForSei[h, LOOPHOLE[sei]];
PutHashString[h, hti];
PNextNull[h, "hti", hti, HTNull];
PNextNull[h, "ctx", se.idCtx, CTXNull];
PNextU[h, "value", se.idValue];
PNextU[h, "info", se.idInfo];
PNextU[h, "type", se.idType];
IF se.extended THEN
BEGIN
es: IO.STREAMIO.ROS[];
type: ExtensionType;
tree: Tree.Link;
[type, tree] ← FindExt[h, LOOPHOLE[sei]];
es.PutF["extended[%g,%d]",
[rope[SELECT type FROM
value => "val",
form => "for",
default => "def",
ENDCASE => "non"]],
[cardinal[LOOPHOLE[tree]]]];
PNext[h, es.RopeFromROS[]];
END;
IF se.public THEN PNext[h, "public"];
IF se.immutable THEN PNext[h, "immutable"];
IF se.constant THEN PNext[h, "constant"];
IF se.linkSpace THEN PNext[h, "linkSpace"];
WITH se SELECT FROM
terminal => PNext[h, "terminal"];
linked => PNextNull[h, "linked", link, ISENull];
sequential => NULL;
ENDCASE;
END;
cons =>
BEGIN
WITH se SELECT FROM
transfer => PutModeName[h, mode];
ENDCASE => PutTypeName[h, se.typeTag];
WITH cse: se SELECT FROM
mode => NULL;
basic =>
BEGIN
PRope[h, " - code: "]; PUnsigned[h, cse.code];
PNextU[h, "length", cse.length];
IF cse.ordered THEN PNext[h, "ordered"];
END;
enumerated =>
BEGIN
PRope[h, " - valCtx: "];
PU[h, cse.valueCtx]; PNextU[h, "nVals", cse.nValues];
IF cse.ordered THEN PNext[h, "ordered"];
IF cse.machineDep THEN PNext[h, "machineDep"];
IF cse.sparse THEN PNext[h, "sparse"];
IF cse.unpainted THEN PNext[h, "unpainted"];
END;
record =>
BEGIN
PRope[h, " - fieldCtx: "]; PU[h, cse.fieldCtx];
PNextU[h, "length", cse.length];
WITH lnkp: cse SELECT FROM
linked => PNextU[h, "linkType",lnkp.linkType];
ENDCASE;
IF cse.argument THEN PNext[h, "argument"];
IF cse.monitored THEN PNext[h, "monitored"];
IF cse.painted THEN PNext[h, "painted"];
IF cse.machineDep THEN PNext[h, "machineDep"];
IF cse.hints.variant THEN PNext[h, "variant"];
IF cse.hints.comparable THEN PNext[h, "comparable"];
IF cse.hints.assignable THEN PNext[h, "assignable"];
IF cse.hints.privateFields THEN PNext[h, "privateFields"];
IF cse.hints.unifield THEN PNext[h, "unifield"];
IF cse.hints.refField THEN PNext[h, "refField"];
IF cse.hints.default THEN PNext[h, "default"];
IF cse.hints.voidable THEN PNext[h, "voidable"];
END;
ref =>
BEGIN
PRope[h, " - refT: "]; PU[h, cse.refType];
IF cse.counted THEN PNext[h, "counted"];
IF cse.list THEN PNext[h, "list"];
IF cse.var THEN PNext[h, "var"];
IF cse.ordered THEN PNext[h, "ordered"];
IF cse.readOnly THEN PNext[h, "readOnly"];
IF cse.basing THEN PNext[h, "basing"];
END;
array =>
BEGIN
PRope[h, " - index: "]; PU[h, cse.indexType];
PNextU[h, "comp", cse.componentType];
IF cse.packed THEN PNext[h, "packed"];
END;
arraydesc =>
BEGIN
PRope[h, " - of: "]; PU[h, cse.describedType];
IF cse.readOnly THEN PNext[h, "readOnly"];
IF cse.var THEN PNext[h, "var"];
END;
transfer =>
BEGIN
IF cse.safe THEN PNext[h, "safe"];
PNextNull[h, "in", cse.typeIn, CSENull];
PNextNull[h, "out", cse.typeOut, CSENull];
END;
definition =>
BEGIN
PRope[h, " - defCtx: "]; PU[h, cse.defCtx];
IF cse.named THEN PNext[h, "named"];
END;
union =>
BEGIN
PRope[h, " - tag: "]; PNull[h, cse.tagSei, SENull];
PNextU[h, "caseCtx", cse.caseCtx];
IF cse.overlaid THEN PNext[h, "overlaid"];
IF cse.controlled THEN PNext[h, "controlled"];
IF cse.machineDep THEN PNext[h, "machineDep"];
IF cse.hints.equalLengths THEN PNext[h, "equalLengths"];
IF cse.hints.refField THEN PNext[h, "refField"];
IF cse.hints.default THEN PNext[h, "default"];
IF cse.hints.voidable THEN PNext[h, "voidable"];
END;
sequence =>
BEGIN
PRope[h, " - tag: "]; PNull[h, cse.tagSei, SENull];
PNextU[h, "comp", cse.componentType];
IF cse.controlled THEN PNext[h, "controlled"];
IF cse.packed THEN PNext[h, "packed"];
IF cse.machineDep THEN PNext[h, "machineDep"];
END;
relative =>
BEGIN
PRope[h, " - base: "]; PU[h, cse.baseType];
PNextU[h, "offset", cse.offsetType];
PNextU[h, "result", cse.resultType];
END;
subrange =>
BEGIN
PRope[h, " - of: "]; PNull[h, cse.rangeType, SENull];
PNextU[h, "origin", cse.origin];
PNextU[h, "range", cse.range];
IF cse.filled THEN PNext[h, "filled"];
IF cse.empty THEN PNext[h, "empty"];
END;
long, real =>
BEGIN
PRope[h, " - of: "]; PNull[h, cse.rangeType, SENull];
END;
opaque =>
BEGIN
PRope[h, " - id(se): "]; PNull[h, cse.id, SENull];
PNextU[h, "length", cse.length];
IF cse.lengthKnown THEN PNext[h, "lengthKnown"];
END;
zone =>
BEGIN
IF cse.counted THEN PNext[h, "counted"];
IF cse.mds THEN PNext[h, "mds"];
END;
ENDCASE;
END;
ENDCASE;
IF ShowLinks[h] THEN
BEGIN
IF ser.mark3 THEN PNext[h, "mk3"];
IF ser.mark4 THEN PNext[h, "mk4"];
END;
END;
PutAsHti: PUBLIC PROCEDURE [h: Handle, hti: Symbols.HTIndex] =
BEGIN
ht: LONG DESCRIPTOR FOR ARRAY HTIndex OF HTRecord;
htr: HTRecord;
ht ← DESCRIPTOR[TableBase[h, htType], 0]; -- ignore length
STCopyRead[h: h, to: @htr, from: @ht[hti], nwords: SIZE[HTRecord]];
PCr[h];
PRope[h, "ht["]; PU[h, hti]; PRope[h, "] "];
PutHashString[h, hti];
PNextU[h, "ssI", htr.ssIndex];
PNextU[h, "link", htr.link];
IF htr.anyInternal THEN PNext[h, "anyInt"];
IF htr.anyPublic THEN PNext[h, "anyPub"];
END;
PutAsCti: PUBLIC PROCEDURE [h: Handle, cti: Symbols.CTXIndex] =
BEGIN
ctxb: Table.Base;
ctx: CTXRecord;
ctxb ← TableBase[h, ctxType];
STCopyRead[h: h, to: @ctx, from: @ctxb[cti],
nwords: SIZE[CTXRecord]];
PCr[h];
PRope[h, "ctx["]; PU[h, cti]; PRope[h, "] level: "];
PU[h, 8*ctx.levelOrigin + ctx.levelOffset];
PNextU[h, "seList", ctx.seList];
IF ctx.varUpdated THEN PNext[h, "varUpdated"];
IF ctx.ctxType # nil THEN
BEGIN
WITH ctx SELECT FROM
simple =>
BEGIN
PNextU[h, "simple - copied", copied.ORD];
END;
imported =>
BEGIN
PNextU[h, "imported - link", includeLink];
END;
included =>
BEGIN
PCr[h]; PRope[h, " "];
PRope[h, "included - chain: "]; PNull[h, chain, CTXNull];
PNextU[h, "module", module];
PNextU[h, "map", map];
IF closed THEN PNext[h, "closed",,6];
IF complete THEN PNext[h, "complete",,6];
IF restricted THEN PNext[h, "restricted",,6];
IF reset THEN PNext[h, "reset",,6];
END;
ENDCASE;
END;
END;
PutAsBti: PUBLIC PROCEDURE [h: Handle, bti: Symbols.BTIndex] =
BEGIN
bb: Table.Base;
btr: BodyRecord;
bb ← TableBase[h, bodyType];
STCopyRead[h: h, to: @btr, from: @bb[bti],
nwords: SIZE[BodyRecord]];
PCr[h];
PRope[h, "bb["]; PU[h, bti]; PRope[h, "] link: "];
IF btr.link.index = BTNull THEN PRope[h, "Null"]
ELSE
BEGIN
PU[h, btr.link.index];
PRope[h, (IF btr.link.which = sibling THEN " (sib)" ELSE " (parent)")];
END;
PNextNull[h, "firstSon", btr.firstSon, BTNull];
PNextNull[h, "localCtx", btr.localCtx, CTXNull];
PNextU[h, "level", btr.level];
PNextU[h, "source", btr.sourceIndex];
PCr[h]; PRope[h, " "];
WITH btr.info SELECT FROM
Internal =>
BEGIN
PRope[h, "Internal - tree: "]; PNull[h, bodyTree, Tree.NullIndex];
PNextU[h, "thread", thread, 6];
PNextU[h, "frameSz", frameSize, 6];
END;
External =>
BEGIN
PRope[h, "External - bytes: "]; PU[h, bytes];
PNextU[h, "startInd", startIndex, 6];
PNextU[h, "indLen", indexLength, 6];
END;
ENDCASE;
WITH bc: btr SELECT FROM
Callable =>
BEGIN
PCr[h]; PRope[h, " Callable - id(se): "]; PU[h, bc.id];
IF bc.id # ISENull THEN {
hti: HTIndex = HashForSei[h, bc.id];
PRope[h, " ("]; PutHashString[h, hti]; PChar[h, ')]};
PNextU[h, "ioType", bc.ioType, 6];
PNextU[h, "entIndex", bc.entryIndex, 6];
WITH bc SELECT FROM
Inner => PNextU[h, "frameOff", frameOffset, 6];
Catch => PNextU[h, "Catch, index", index, 6];
ENDCASE;
IF bc.inline THEN PNext[h, "inline",,6];
IF bc.monitored THEN PNext[h, "monitored",,6];
IF bc.noXfers THEN PNext[h, "noXfers",,6];
IF bc.resident THEN PNext[h, "resident",,6];
IF bc.entry THEN PNext[h, "entry",,6];
IF bc.internal THEN PNext[h, "internal",,6];
IF bc.hints.safe THEN PNext[h, "safe",,6];
IF bc.hints.argUpdated THEN PNext[h, "argUpdated",,6];
IF bc.hints.nameSafe THEN PNext[h, "nameSafe",,6];
END;
Other =>
BEGIN
PCr[h]; PRope[h, " Other - relOffset: "]; PU[h, bc.relOffset];
END;
ENDCASE;
END;
PutAsMdi: PUBLIC PROCEDURE [h: Handle, mdi: Symbols.MDIndex] =
BEGIN
mdb: Table.Base;
mdr: MDRecord;
mdb ← TableBase[h, mdType];
STCopyRead[h: h, to: @mdr, from: @mdb[mdi],
nwords: SIZE[MDRecord]];
PCr[h];
PRope[h, "mdb["]; PU[h, mdi]; PRope[h, "] stamp: "]; PutVersion[h, mdr.stamp];
PNextU[h, "modId", mdr.moduleId];
PNextU[h, "fileId", mdr.fileId];
PNextNull[h, "ctx", mdr.ctx, CTXNull];
PNextNull[h, "defaultImport", mdr.defaultImport, CTXNull];
PNextUnsigned[h, "file", mdr.file];
IF mdr.shared THEN PNext[h, "shared"];
IF mdr.exported THEN PNext[h, "exported"];
END;
PutVersion: PUBLIC PROCEDURE [h: Handle, stamp: BcdDefs.VersionStamp] =
BEGIN
s: IO.STREAMIO.ROS[];
s.PutF["%g on %b#%b#",
[time[BasicTime.FromNSTime[stamp.time]]], [cardinal[stamp.net]], [cardinal[stamp.host]]];
PRope[h, IO.RopeFromROS[s]];
RETURN
END;
END.