TestMonitorSmallCachePmCode.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created: October 12, 1987 5:52:44 pm PDT
Pradeep Sindhu February 7, 1988 12:29:52 pm PST
Tests Monitoring code.
DIRECTORY
MonitorSmallCachePmCode, Rope, SmallCacheUtils;
TestMonitorSmallCachePmCode: CEDAR PROGRAM
IMPORTS MonitorSmallCachePmCode, SmallCacheUtils
~
BEGIN
IndexType: TYPE = {Label, ReturnAddress, IOAddr};
Index: ARRAY IndexType OF NAT ← ALL [0];
-- Begin Labels
PC0: NAT = Next[Label];
PC1: NAT = Next[Label];
PC2: NAT = Next[Label];
PC3: NAT = Next[Label];
PC4: NAT = Next[Label];
PC5: NAT = Next[Label];
-- End Labels
MaxPC: NAT = Next[Label];
Next:
PROC [it: IndexType]
RETURNS [index:
NAT] = {
index ← Index[it];
Index[it] ← Index[it]+1;
};
Simple:
PROC [p, newPC:
NAT] = {
vs:
PROC [ix:
NAT]
RETURNS [
NAT] = {
RETURN[ix]
};
Jmp:
PROC [dest:
NAT] = {
PC ← dest;
MonitorSmallCachePmCode.RecordPC[h, PC]
};
SELECT p
FROM
= 0 => NULL;
= 1 => NULL;
= 2 => {
SELECT vs[
PC]
FROM
-- Begin Transitions
=
PC1 => {
SELECT newPC
FROM
= 2 => Jmp[PC2];
ENDCASE => Jmp[PC3]
};
ENDCASE => ERROR; -- End Transitions
};
ENDCASE => ERROR;
};
Test:
PROC [] = {
PC ← PC0;
MonitorSmallCachePmCode.RecordPC[h, PC];
Simple[2, 0]; --> PC1
Simple[2, 2]; --> PC2
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 3]; --> PC3
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 3]; --> PC3
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 2]; --> PC2
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Finally, cause a disallowed transition (from PC5 to PC5)
MonitorSmallCachePmCode.RecordPC[h, PC5];
MonitorSmallCachePmCode.PrintUnVisitedPaths[h, LAST[NAT]];
ERROR
};
PC: NAT;
h: MonitorSmallCachePmCode.Handle ← MonitorSmallCachePmCode.ParseMCode["TestMonitorSmallCachePmCode.mesa", SmallCacheUtils.workingDirectory];
END.