CDebugVar.mesa
Edited by Sweet, 9-Jul-83 0:15:39
Sweet January 30, 1986 9:49:13 am PST
DIRECTORY
CDebugDefs USING [CDCopyRead, Handle],
CodeDefs USING [codeType, StackNull, VarComponent, VarIndex, VarItem, VarSpace, VarTag],
Literals USING [LTNull],
RESOut USING [PChar, PCr, PNext, PNextUnsigned, PNull, PRope, PUnsigned],
Rope USING [ROPE],
STDebugDefs USING [TableBase],
Symbols USING [lG, lL, lZ],
Table USING [Base];
CDebugVar: PROGRAM
IMPORTS CDebugDefs, RESOut, STDebugDefs
EXPORTS CDebugDefs =
BEGIN OPEN CodeDefs, RESOut;
ROPE: TYPE = Rope.ROPE;
Handle: TYPE = CDebugDefs.Handle;
PutAsVar: PUBLIC PROCEDURE [h: Handle, index: CodeDefs.VarIndex] =
BEGIN OPEN CodeDefs;
cbr: CodeDefs.VarItem;
cb: Table.Base ← STDebugDefs.TableBase[h, codeType];
CDebugDefs.CDCopyRead[h: h, to: @cbr, from: @cb[index], nwords: SIZE[CodeDefs.VarItem]];
PUnsigned[h, LOOPHOLE[index]];
PChar[h, ':];
IF cbr.free THEN
BEGIN
PRope[h, " Free!"];
RETURN;
END;
IF cbr.tag NOT IN VarTag THEN
BEGIN
PRope[h, " tag: ?["]; PUnsigned[h, LOOPHOLE[cbr.tag]]; PChar[h, ']];
RETURN
END;
WITH cc: cbr SELECT FROM
o => PutComponent[h, "var", @cc.var];
bo =>
BEGIN
PutComponent[h, "base",@cc.base];
PCr[h]; PutComponent[h, "offset", @cc.offset];
END;
bdo =>
BEGIN
PutComponent[h, "base",@cc.base];
PCr[h]; PutComponent[h, "disp", @cc.disp];
PCr[h]; PutComponent[h, "offset", @cc.offset];
END;
ind =>
BEGIN
PutComponent[h, "base",@cc.base];
PCr[h]; PutComponent[h, "index", @cc.index];
WITH cc SELECT FROM
packed =>
BEGIN
PNext[h, "grain: ", 1, 10];
PUnsigned[h, grain];
END;
notPacked => PNextUnsigned[h, "eWords", eWords, 10];
ENDCASE;
IF cc.simple THEN PNext[h, "simple"];
PCr[h]; PutComponent[h, "offset", @cc.offset];
END;
ENDCASE;
END;
PutAsComponent: PUBLIC PROCEDURE [h: Handle, cp: POINTER] =
BEGIN
var: VarComponent;
CDebugDefs.CDCopyRead[h: h, to: @var, from: cp, nwords: SIZE[VarComponent]];
PutComponentFields[h, @var, 2];
END;
PutComponent: PROCEDURE [h: Handle, name: ROPE, c: POINTER TO CodeDefs.VarComponent] =
BEGIN
PChar[h, '\t];
PRope[h, name]; PRope[h, " - "];
PutComponentFields[h, c, 10];
END;
PutComponentFields: PROCEDURE
[h: Handle, c: POINTER TO CodeDefs.VarComponent, indent: CARDINAL] =
BEGIN
SpaceName: ARRAY VarSpace OF ROPE = [
"faddr", "frame", "frameup", "caddr",
"code", "link", "linkup", "stack", "const", "pdesc"];
PRope[h, "wSize: "];
PUnsigned[h, c.wSize];
IF c.bSize # 0 THEN PNextUnsigned[h, "bSize",c.bSize,indent];
IF c.tag NOT IN VarSpace THEN
BEGIN
PNextUnsigned[h, "Invalid tag", c.tag, indent];
RETURN
END
ELSE PNext[h, SpaceName[c.tag], 1, indent];
PChar[h, '[];
WITH c SELECT FROM
frame =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
IF bd # 0 THEN PNextUnsigned[h, "bd", bd, indent];
PNext[h, "level: ", 1, indent];
SELECT level FROM
Symbols.lZ => PChar[h, 'Z];
Symbols.lG => PChar[h, 'G];
Symbols.lL => PChar[h, 'L];
ENDCASE => PUnsigned[h, level];
IF immutable THEN PNext[h, "immutable",,indent];
END;
frameup =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
PNext[h, "pwSize: ", 1, indent];
PUnsigned[h, pwSize];
PNext[h, "level: ", 1, indent];
SELECT level FROM
Symbols.lZ => PChar[h, 'Z];
Symbols.lG => PChar[h, 'G];
Symbols.lL => PChar[h, 'L];
ENDCASE => PUnsigned[h, level];
PNextUnsigned[h, "delta", delta, indent];
END;
faddr =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
PNext[h, "level: ", 1, indent];
SELECT level FROM
Symbols.lZ => PChar[h, 'Z];
Symbols.lG => PChar[h, 'G];
Symbols.lL => PChar[h, 'L];
ENDCASE => PUnsigned[h, level];
END;
lfaddr =>
BEGIN
PRope[h, "wd: "];
PUnsigned[wd];
PNext["level: ", 1, indent];
SELECT level FROM
Symbols.lZ => PChar[h, 'Z];
Symbols.lG => PChar[h, 'G];
Symbols.lL => PChar[h, 'L];
ENDCASE => PUnsigned[h, level];
PNext[h, IF op = pad THEN "pad" ELSE "lengthen"];
END;
caddr, link =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
END;
linkup =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
PNextUnsigned[h, "delta", delta, indent];
END;
code =>
BEGIN
PRope[h, "wd: "];
PUnsigned[h, wd];
IF bd # 0 THEN PNextUnsigned[h, "bd", bd, indent];
IF lti # Literals.LTNull THEN PNextUnsigned[h, "lti", lti, indent];
END;
stack =>
BEGIN
PRope[h, "sti: "];
PNull[h, sti, StackNull];
IF wd # 0 THEN PNextUnsigned[h, "wd", wd, indent];
IF bd # 0 THEN PNextUnsigned[h, "bd", bd, indent];
END;
const =>
BEGIN
PRope[h, "d1: "];
PUnsigned[h, d1];
IF c.wSize = 2 OR c.wSize = 1 AND c.bSize # 0 THEN
PNextUnsigned[h, "d2", d2, indent];
IF bd # 0 THEN PNextUnsigned[h, "bd", bd, indent];
END;
pdesc =>
BEGIN
PRope[h, "ep: "];
PUnsigned[h, ep];
END;
sigdesc =>
BEGIN
PRope[h, "sig: "];
PUnsigned[sig];
END;
ENDCASE;
PChar[h, ']];
END;
END.