MBDebug.mesa
Edited by Sandman on 28-Jan-81 10:42:17
Edited by Lewis on 25-Sep-81 15:33:42
Edited by Levin on June 21, 1983 3:37 pm
DIRECTORY
Ascii USING [CR, SP],
BcdDefs
USING [
Base, BcdBase, CTHandle, CTIndex, CTNull, FPHandle, FPIndex, FTIndex, FTSelf, MTHandle, MTIndex, NameRecord, NameString, NTHandle, NTIndex, SGHandle, SGIndex, SpaceID, SPHandle, SPIndex],
BcdOps
USING [
ProcessConfigs, ProcessFramePacks, ProcessModules, ProcessNames, ProcessSegs, ProcessSpaces],
BootFile USING [Header, Location],
BootStartList
USING [
Base, Entry, Header, Index, SwapUnitInfo, SpaceType, startIndex, StateVectorCounts, Switches],
IO USING [bool, card, PutChar, PutF, PutRope, rope, time],
MB USING [BIndex, Handle, MT, VirtualGlobalFrame],
MBVM USING [Seg, Segs],
PrincOps USING [GlobalFrameHandle],
Rope USING [Cat, ROPE];
MBDebug:
PROGRAM
IMPORTS BcdOps, IO, MB, Rope
EXPORTS MB =
BEGIN
data: MB.Handle ← NIL;
InitDebug: PUBLIC PROC [h: MB.Handle] = {data ← h};
FinishDebug: PUBLIC PROC = {data ← NIL};
DumpSegs:
PUBLIC
PROC [segs:
MBVM.Segs, msg: Rope.
ROPE] = {
DumpSeg:
PROC [s:
MBVM.Seg] = {
data.loadmap.PutF["Seg[%n] type: ", IO.card[LOOPHOLE[s]]];
WITH seg: s
SELECT
FROM
data => data.loadmap.PutRope["data"];
code => data.loadmap.PutRope["code"];
file => data.loadmap.PutRope["file"];
ENDCASE;
data.loadmap.PutF[", vmpage: %n, info: %g, scriptIndex: %n, booted: %z\N",
IO.card[s.base], IO.rope[GetSwapUnitInfo[s.info]],
IO.card[LOOPHOLE[s.index].LONG], IO.bool[s.bootLoaded]];
WITH seg: s
SELECT
FROM
data => NULL;
code =>
data.loadmap.PutF[" location: %f(%n)[%n,%n]\N",
IO.card[LOOPHOLE[seg.file].LONG],
IO.card[LOOPHOLE[seg.file].LONG],
IO.card[seg.fileBase], IO.card[s.pages]];
file =>
data.loadmap.PutF[" location: %f(%n)[%n,%n]\N",
IO.card[LOOPHOLE[seg.file].LONG],
IO.card[LOOPHOLE[seg.file].LONG],
IO.card[seg.fileBase],
IO.card[s.pages]
];
ENDCASE;
};
data.loadmap.PutF["\NSEGMENT TABLE JUST BEFORE %g:\N\N", IO.rope[msg]];
FOR i: CARDINAL IN [0..segs.length) DO DumpSeg[segs[i]]; ENDLOOP;
};
GetSwapUnitInfo:
PROC [info: BootStartList.SwapUnitInfo]
RETURNS [Rope.
ROPE] = {
RETURN[Rope.Cat[
"[readOnly: ",
IF info.readOnly THEN "T, " ELSE "F, ",
SELECT info.state
FROM
resident => "resident",
residentDescriptor => "residentDescriptor",
ENDCASE => "swappable",
"]"
]]
};
DumpInputBcds:
PUBLIC
PROC = {
OPEN BcdDefs, BcdOps;
data.loadmap.PutRope["\NINPUT BCDS:\N\N"];
FOR i:
MB.BIndex
IN [0..data.inputBCDs.nBcds)
DO
bcd: BcdBase = data.inputBCDs.bcds[i].bcd;
ctb: Base = LOOPHOLE[bcd + bcd.ctOffset];
mtb: Base = LOOPHOLE[bcd + bcd.mtOffset];
ftb: Base = LOOPHOLE[bcd + bcd.ftOffset];
ssb: NameString = LOOPHOLE[bcd + bcd.ssOffset];
level: CARDINAL ← 2;
DumpName:
PROC [name: NameRecord]
RETURNS [length:
CARDINAL] = {
length ← ssb.size[name];
FOR i:
CARDINAL
IN [name..name+length)
DO
data.loadmap.PutChar[ssb.string[i]];
ENDLOOP;
};
DumpCTName:
PROC [cti: CTIndex]
RETURNS [length:
CARDINAL ← 0] = {
cth: CTHandle = @ctb[cti];
IF cth.namedInstance
THEN {
FindConfigInstanceName:
PROC [nth: NTHandle, nti: NTIndex]
RETURNS [
BOOL] = {
WITH namee: nth.item
SELECT
FROM
config => IF namee.cti = cti THEN {length ← DumpName[nth.name]; RETURN[TRUE]};
ENDCASE;
RETURN[FALSE]
};
[] ← ProcessNames[bcd, FindConfigInstanceName];
data.loadmap.PutRope[": "]; length ← length + 2};
length ← length + DumpName[cth.name];
};
DumpMTName:
PROC [mti: MTIndex]
RETURNS [length:
CARDINAL ← 0] = {
mth: MTHandle = @mtb[mti];
IF mth.namedInstance
THEN {
FindModuleInstanceName:
PROC [nth: NTHandle, nti: NTIndex]
RETURNS [
BOOL] = {
WITH namee: nth.item
SELECT
FROM
module =>
IF namee.mti = mti THEN {length ← DumpName[nth.name]; RETURN[TRUE]};
ENDCASE;
RETURN[FALSE]
};
[] ← ProcessNames[bcd, FindModuleInstanceName];
data.loadmap.PutRope[": "]; length ← length + 2;
};
length ← length + DumpName[mth.name];
};
DumpConfigsWithParent:
PROC [parentConfig: CTIndex] = {
DumpConfigsWithinParent:
PROC [cth: CTHandle, cti: CTIndex]
RETURNS [
BOOL] = {
IF cth.config = parentConfig
THEN {
data.loadmap.PutF["%s", IO.card[level]];
[] ← DumpCTName[cti];
IF cth.nControls > 0
THEN {
data.loadmap.PutRope[" control list:"];
FOR i:
CARDINAL
IN [0..cth.nControls)
DO
data.loadmap.PutChar[Ascii.SP];
WITH cItem: cth.controls[i]
SELECT
FROM
module => [] ← DumpMTName[cItem.mti];
config => [] ← DumpCTName[cItem.cti];
ENDCASE;
ENDLOOP;
};
data.loadmap.PutChar[Ascii.CR];
level ← level + 2;
DumpConfigsWithParent[cti];
level ← level - 2;
};
RETURN[FALSE]
};
DumpModulesWithinParent:
PROC [mth: MTHandle, mti: MTIndex]
RETURNS [
BOOL] = {
IF mth.config = parentConfig
THEN {
nameLength: CARDINAL;
data.loadmap.PutF["%s", IO.card[level]];
nameLength ← DumpMTName[mti];
data.loadmap.PutF[" links: %g, framesize: %n, residentFrame: %z, packageable: %z, nGFI: %n,\N",
IO.rope[SELECT mth.linkLoc FROM frame => "frame", ENDCASE => "code"],
IO.card[mth.framesize],
IO.bool[mth.residentFrame], IO.bool[mth.packageable],
IO.card[mth.ngfi]
];
data.loadmap.PutF["%scode: [sgi: %n, linkspace: %z, packed: %z, offset: %n",
IO.card[level+nameLength+2],
IO.card[LOOPHOLE[mth.code.sgi].LONG],
IO.bool[mth.code.linkspace], IO.bool[mth.code.packed],
IO.card[mth.code.offset]
];
IF mth.packageable THEN data.loadmap.PutF[", length: %n", IO.card[mth.code.length]];
data.loadmap.PutRope["]\N"];
};
RETURN[FALSE]
};
[] ← ProcessModules[bcd, DumpModulesWithinParent];
[] ← ProcessConfigs[bcd, DumpConfigsWithinParent];
};
DumpSegment:
PROC [sgh: SGHandle, sgi: SGIndex]
RETURNS [
BOOL] = {
IF sgh.class = code
THEN {
DumpCodePacksInSegment:
PROC [sph: SPHandle, spi: SPIndex]
RETURNS [
BOOL] = {
IF sph.seg = sgi
THEN {
FOR i:
CARDINAL
IN [0..sph.length)
DO
space: SpaceID = sph.spaces[i];
data.loadmap.PutRope[" "];
[] ← DumpName[space.name];
data.loadmap.PutF[" resident: %z, relative location: [%n,%n]\N",
IO.bool[space.resident], IO.card[space.offset], IO.card[space.pages]
];
ENDLOOP;
};
RETURN[FALSE]
};
data.loadmap.PutF[" Code Segment [sgi: %n], location: ", IO.card[LOOPHOLE[sgi].LONG]];
IF sgh.file = FTSelf THEN data.loadmap.PutRope["(self)"]
ELSE [] ← DumpName[ftb[sgh.file].name];
data.loadmap.PutF["[%n,%n+%n]\N",
IO.card[sgh.base], IO.card[sgh.pages], IO.card[sgh.extraPages]
];
[] ← ProcessSpaces[bcd, DumpCodePacksInSegment];
};
RETURN[FALSE]
};
DumpFramePack:
PROC [fph: FPHandle, fpi: FPIndex]
RETURNS [
BOOL] = {
data.loadmap.PutRope[" Frame Pack "]; [] ← DumpName[fph.name];
FOR i:
CARDINAL
IN [0..fph.length)
DO
data.loadmap.PutRope["\N "]; [] ← DumpMTName[fph.modules[i]];
ENDLOOP;
data.loadmap.PutChar[Ascii.CR];
RETURN[FALSE]
};
DumpSwapUnits:
PROC = {
data.loadmap.PutF[" BCD is %n pages\N BCD header occupies [1,%n]\N",
IO.card[bcd.nPages], IO.card[bcd.nPages-bcd.rtPages.pages]
];
IF bcd.rtPages.pages = 0 THEN data.loadmap.PutRope[" No RT extension\N"]
ELSE {
data.loadmap.PutF[" RT extension occupies [%n,%n]\N",
IO.card[1+bcd.rtPages.relPageBase], IO.card[bcd.rtPages.pages]
];
};
};
data.loadmap.PutF["Configurations and Modules in %g:\N",
IO.rope[data.inputBCDs.bcds[i].name]];
DumpConfigsWithParent[CTNull];
data.loadmap.PutF["\NCode Segments, Code Packs, and Frame Packs in %g:\N",
IO.rope[data.inputBCDs.bcds[i].name]];
DumpSwapUnits[];
[] ← ProcessSegs[bcd, DumpSegment];
[] ← ProcessFramePacks[bcd, DumpFramePack];
data.loadmap.PutChar[Ascii.CR];
ENDLOOP;
DumpStartList:
PUBLIC
PROC = {
base: BootStartList.Base ← data.scriptBase;
p: BootStartList.Index ← BootStartList.startIndex;
data.loadmap.PutRope["\NSTART LIST:\N\N"];
DumpStartListHeader[];
data.loadmap.PutRope["Script\N"];
DO
WITH e: base[p]
SELECT
FROM
space => {
OPEN e;
data.loadmap.PutF[" Space[%n] type: ", IO.card[LOOPHOLE[p].LONG]];
DumpSpaceType[type];
data.loadmap.PutF[", backingStore: %g, booted: %z\N",
IO.rope[IF backingStore = self THEN "self" ELSE "null"],
IO.bool[bootLoaded]
];
data.loadmap.PutF[" vmpage: %n, pages: %n",
IO.card[vmPage], IO.card[pages]];
IF backingStore = self
THEN
data.loadmap.PutF[", backingPage: %n", IO.card[backingPage]];
data.loadmap.PutChar[Ascii.CR];
p ← p + SIZE[space BootStartList.Entry];
};
swapUnit => {
OPEN e;
data.loadmap.PutF[" SwapUnit[%n] parent: %n, base: %n, pages: %n, info: %g\N",
IO.card[LOOPHOLE[p].LONG],
IO.card[LOOPHOLE[parent].LONG],
IO.card[base], IO.card[pages],
IO.rope[GetSwapUnitInfo[info]]
];
p ← p + SIZE[swapUnit BootStartList.Entry];
};
stop => {data.loadmap.PutRope[" Stop\N"]; EXIT};
ENDCASE => {data.loadmap.PutRope["**Unknown BootScript Type\N"]; EXIT};
ENDLOOP;
data.loadmap.PutChar[Ascii.CR];
};
DumpSpaceType:
PROC [type: BootStartList.SpaceType] = {
WITH type
SELECT
FROM
empty => data.loadmap.PutRope["[empty[]]"];
unitary =>
data.loadmap.PutF["[unitary[swapUnit: %n]]", IO.card[LOOPHOLE[swapUnit].LONG]];
family =>
data.loadmap.PutF["[family[resDescChildren: %z]]", IO.bool[anyResidentDescriptorChildren]];
ENDCASE;
};
DumpStartListHeader:
PROC = {
h: REF BootStartList.Header ← data.header;
data.loadmap.PutF[
"Header (%n)\N version: %n\N release: %n.%n.%n\N",
IO.card[LOOPHOLE[data.scriptBaseInVM]],
IO.card[h.version],
IO.card[h.release.major], IO.card[h.release.minor], IO.card[h.release.patch]
];
data.loadmap.PutF[" buildDate: %t\N", IO.time[LOOPHOLE[h.buildDate]]];
data.loadmap.PutF[
" uCodeDolphin: %t\N uCodeDorado: %t\N uCodeDandelion: %t\N uCodeDicentra: %t\N",
IO.time[LOOPHOLE[h.requiredUCode[dolphin]]],
IO.time[LOOPHOLE[h.requiredUCode[dorado]]],
IO.time[LOOPHOLE[h.requiredUCode[dandelion]]],
IO.time[LOOPHOLE[h.requiredUCode[dicentra]]],
];
data.loadmap.PutF[" controlList: %n\N initLoadState: %n\N",
IO.card[LOOPHOLE[h.controlList].LONG],
IO.card[LOOPHOLE[h.initLoadState].LONG]
];
data.loadmap.PutF[" mdsBase: %n\N pdaPages: %n\N",
IO.card[h.mdsBase], IO.card[h.pdaPages]
];
data.loadmap.PutRope[" stateVectorCounts: "];
DumpStateVectorCounts[@h.stateVectorCounts];
data.loadmap.PutChar[Ascii.CR];
data.loadmap.PutF[
" stateVectorSize: %n\N nProcesses: %n\N lastVMPage: %n\N lastBootLoadedPage: %n\N",
IO.card[h.stateVectorSize.LONG],
IO.card[h.nProcesses.LONG],
IO.card[h.lastVMPage],
IO.card[h.lastBootLoadedPage]
];
data.loadmap.PutRope[" switches: "];
DumpSwitches[@h.switches];
data.loadmap.PutChar[Ascii.CR];
data.loadmap.PutRope[" locDebuggerMicrocode: "];
DumpBootLocation[@h.locDebuggerMicrocode];
data.loadmap.PutChar[Ascii.CR];
data.loadmap.PutRope[" locDebuggerGerm: "];
DumpBootLocation[@h.locDebuggerGerm];
data.loadmap.PutChar[Ascii.CR];
data.loadmap.PutRope[" locDebugger: "];
DumpBootLocation[@h.locDebugger];
data.loadmap.PutChar[Ascii.CR];
data.loadmap.PutRope[" locDebuggee: "];
DumpBootLocation[@h.locDebuggee];
data.loadmap.PutChar[Ascii.CR];
};
DumpStateVectorCounts:
PROC [svc:
LONG
POINTER
TO BootStartList.StateVectorCounts] = {
data.loadmap.PutChar['[];
FOR i:
CARDINAL
IN [0..
SIZE[BootStartList.StateVectorCounts])
DO
data.loadmap.PutF["%g%n", IO.rope[IF i ~= 0 THEN ", " ELSE NIL], IO.card[svc[i]]];
ENDLOOP;
data.loadmap.PutChar[']];
};
DumpSwitches:
PROC [s:
LONG
POINTER
TO BootStartList.Switches] = {
data.loadmap.PutF["[%n, %n, %n, %n]", IO.card[s.a], IO.card[s.b], IO.card[s.c], IO.card[s.d]];
};
DumpBootLocation:
PROC [bl:
LONG
POINTER
TO BootFile.Location] = {
bits: LONG POINTER TO ARRAY [0..SIZE[BootFile.Location]) OF CARDINAL = LOOPHOLE[bl];
data.loadmap.PutChar['[];
FOR i:
CARDINAL
IN [0..
SIZE[BootFile.Location])
DO
data.loadmap.PutF["%g%n", IO.rope[IF i ~= 0 THEN ", " ELSE NIL], IO.card[bits[i]]];
ENDLOOP;
data.loadmap.PutChar[']];
};
DumpBootHeader:
PUBLIC
PROC = {
h: REF BootFile.Header ← data.bootHeader;
data.loadmap.PutF[
"\N\NBOOTFILE HEADER:\N version: %n\N creationDate: %t\N pStartListHeader: %n\N",
IO.card[h.version],
IO.time[[h.creationDate]],
IO.card[LOOPHOLE[h.pStartListHeader.LONG]]];
data.loadmap.PutF[" inLoadMode: %g\N continuation: ",
IO.rope[SELECT h.inLoadMode FROM load => "load", ENDCASE => "restore"]];
WITH h.continuation
SELECT
FROM
initial =>
data.loadmap.PutF["initial[mdsi: %n, destination: %n]",
IO.card[mdsi],
IO.card[LOOPHOLE[destination].LONG]];
ENDCASE => data.loadmap.PutRope["unexpected variant!!!"];
data.loadmap.PutF["\N countData: %n\N\N", IO.card[h.countData]];
};
DumpFrames:
PUBLIC
PROC = {
data.loadmap.PutRope["\NGLOBAL FRAMES AT COMPLETION OF LOADING:\N\N"];
FOR i:
MB.BIndex
IN [0..data.inputBCDs.nBcds)
DO
mt: MB.MT = data.inputBCDs.bcds[i].mt;
data.loadmap.PutF["%g\N", IO.rope[data.inputBCDs.bcds[i].name]];
FOR gfi:
CARDINAL
IN [1..mt.length)
DO
frame: PrincOps.GlobalFrameHandle;
IF mt[gfi].mth.gfi ~= gfi THEN LOOP;
frame ← mt[gfi].frame;
data.loadmap.PutF[
" Frame[%n] gfi: %n, shared: %z, alloced: %z, codelinks: %z",
IO.card[LOOPHOLE[frame].LONG],
IO.card[MB.VirtualGlobalFrame[frame].gfi],
IO.bool[MB.VirtualGlobalFrame[frame].shared],
IO.bool[MB.VirtualGlobalFrame[frame].alloced],
IO.bool[MB.VirtualGlobalFrame[frame].codelinks]
];
data.loadmap.PutF[", codebase: %n\N",
IO.card[LOOPHOLE[MB.VirtualGlobalFrame[frame].code.longbase]]
];
ENDLOOP;
data.loadmap.PutChar[Ascii.CR];
ENDLOOP;
END.