LocalCirioTest.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Sturgis, March 23, 1990 4:07 pm PST
Spreitze, October 1, 1990 12:01 pm PDT
Willie-s, May 15, 1992 2:46 pm PDT
DIRECTORY
Commander USING[CommandProc, Register],
CommanderOps USING[ArgumentVector, Parse],
IO,
LocalCirio USING[AddSearchDirectory, Connection, GetConnection, GetStackForSelf, ReleaseConnection],
RMTWTestSubject USING[ExamineSubjectStack, Subject],
Rope USING[ActionType, ROPE],
StackCirio USING[GetBannerForDotOofCurrentFrame, ResetStack, Stack, WalkStack, WalkStackToCProcedure];
LocalCirioTest: CEDAR PROGRAM IMPORTS Commander, CommanderOps, IO, LocalCirio, StackCirio, RMTWTestSubject =
BEGIN
Local Test
LocalCirioTestDriver: Commander.CommandProc =
BEGIN
reports: IO.STREAM ¬ cmd.out;
args: CommanderOps.ArgumentVector ¬ CommanderOps.Parse[cmd];
connection: LocalCirio.Connection ¬ LocalCirio.GetConnection[["PopUpDriver2", "BreakPointPopUp"], reports];
CleanUp: PROC =
BEGIN
LocalCirio.ReleaseConnection[connection, reports];
END;
open a block to so that unwind catches can cleanup
(note: we need not lock a monitor, since only one thread has access to the connection data.)
BEGIN
ENABLE UNWIND => CleanUp[];
LocalCirioTestInner: PROC[key: CARD32] =
BEGIN
stack: StackCirio.Stack ¬ LocalCirio.GetStackForSelf[connection, reports];
index: CARD ¬ StackCirio.ResetStack[stack, reports];
IO.PutF1[reports, "Cirio Of %g\N", IO.rope[StackCirio.GetBannerForDotOofCurrentFrame[stack, reports]]];
FOR I: INT IN [1..args.argc) DO
LocalCirio.AddSearchDirectory[connection, args[I], reports];
ENDLOOP;
IF StackCirio.WalkStackToCProcedure[stack, "←LocalCirioTestInner←", "LocalCirioTest", cmd.out] THEN
BEGIN
actualMovement: INT; newFrameIndex: CARD;
[actualMovement, newFrameIndex] ¬ StackCirio.WalkStack[stack, 1, cmd.out]; -- get into position
RMTWTestSubject.ExamineSubjectStack[stack, TRUE, reports]
END
ELSE
IO.PutRope[reports, "\N\NFAILED TO FIND EXPECTED TEST SUBJECT FRAME\N\N"];
now, lets close down the test
ERROR CloseDownLocalTest[];
END;
RMTWTestSubject.Subject[TRUE, LocalCirioTestInner
! CloseDownLocalTest => CONTINUE];
END;
CleanUp[]
END;
CloseDownLocalTest: ERROR = CODE;
Cirio Test Subject
LocalCirioTestSubjectDriver: Commander.CommandProc =
{RMTWTestSubject.Subject[TRUE, LocalDebuggeeTestFrame]};
LocalDebuggeeTestFrame: PROC[key: CARD32] =
BEGIN
inner: PROC[key: CARD32] RETURNS[INT32] =
{ThisIsUncaught[]; RETURN[-1]};
result: INT ¬ inner[key];
SELECT result FROM
-1 => RETURN;
ENDCASE => ERROR ABORTED;
END;
ThisIsUncaught: SIGNAL = CODE;
RemoteCirioTestSubjectDriver: Commander.CommandProc =
{RMTWTestSubject.Subject[TRUE, CirioDebuggeeTestFrame]};
remote cirio test will be looking for a frame with this procedure name
CirioDebuggeeTestFrame: PROC[key: CARD32] =
BEGIN
inner: PROC[key: CARD32] RETURNS[INT32] = TRUSTED MACHINE CODE
{"XR�llDebugger"};
result: INT ¬ inner[key];
SELECT result FROM
-1 => RETURN;
ENDCASE => ERROR ABORTED;
END;
Remote Cirio Test
note: this module can not be loaded on the D machine because it references Local Cirio stuff. Perhaps we can build a dummy Local Cirio?
This code should be copied into a RemoteCirioTest module.
RemoteCirioTestDriver: Commander.CommandProc =
BEGIN
args: CommanderOps.ArgumentVector ← CommanderOps.Parse[cmd];
serverName: Rope.ROPE ← args[1];
portNum: CARDINALIF args.argc <= 2 THEN 4815 ELSE CARDINAL[Convert.CardFromRope[args[2]]];
reports: IO.STREAMIO.ROS[];
connection: RemoteCirio.Connection ← RemoteCirio.OpenConnection[serverName, portNum, FileNames.CurrentWorkingDirectory[], reports];
remoteWorldStopped: BOOLEANFALSE;
CleanUp: PROC =
BEGIN
IF remoteWorldStopped THEN RemoteCirio.ResumeRemoteWorld[connection];
remoteWorldStopped ← FALSE;
RemoteCirio.CloseConnection[connection, reports];
IO.Close[reports]
END;
open a block to so that unwind catches can cleanup
(note: we need not lock a monitor, since only one thread has access to the connection data.)
BEGIN
ENABLE UNWIND => CleanUp[];
TestInner: PROC =
BEGIN
nThreads: CARD ← RemoteCirio.StopRemoteWorld[connection, reports];
remoteWorldStopped ← TRUE;
BEGIN
interestingThreads: LIST OF CARD ← RemoteCirio.FindThreadsWithProperty[connection, [callingDebugger[]]];
threadFound: BOOLEAN ← FALSE; -- tentative
FOR ts: LIST OF CARD ← interestingThreads, ts.rest WHILE ts # NIL DO
x: CARD ← ts.first;
remoteThreadIndex: CARD ← RemoteCirio.FocusOnThread[connection, x, cmd.out];
stack: StackCirio.Stack ← RemoteCirio.GetStackForCurrentThread[connection, reports];
index: CARD ← StackCirio.ResetThreadStack[stack, reports];
IO.PutF[cmd.out, "searching thread %g\N", IO.rope[RemoteCirio.GetThreadTitleText[connection, x]]];
IF StackCirio.WalkThreadStackToCProcedure[stack, keyName, "LocalCirioTest", cmd.out] THEN
{ExamineStack[stack, reports]; threadFound ← TRUE; EXIT};
ENDLOOP;
IF NOT threadFound THEN IO.PutF[reports, "\N\NFAILED TO FIND EXPECTED TEST SUBJECT THREAD\N\N"];
END;
END;
TestInner[]; -- so that unwinds from aborts from breakpoints will be caught
END;
CleanUp[]
END;
main code
Commander.Register["TestLocalCirio", LocalCirioTestDriver];
Commander.Register["RemoteCirioTestSubject", RemoteCirioTestSubjectDriver];
Commander.Register["LocalCirioTestSubject", LocalCirioTestSubjectDriver];
END..