DrcDebugImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Written by gbb, January 12, 1987 11:47:17 am PST
gbb March 8, 1987 12:54:13 pm PST
DIRECTORY
CDProperties USING [RegisterProperty],
Core USING [Wire],
CoreProperties USING [RegisterProperty],
CoreOps USING [GetShortWireName],
DrcDebug,
IO USING [card, noWhereStream, PutF, refAny, rope, STREAM],
Rope USING [ROPE],
UserProfile USING [Boolean, CallWhenProfileChanges, ProfileChangedProc],
ViewerIO USING [CreateViewerStreams],
ViewerTools USING [FindExistingViewer, Viewer];
DrcDebugImpl: CEDAR PROGRAM
IMPORTS CDProperties, CoreOps, CoreProperties, IO, UserProfile, ViewerIO, ViewerTools
EXPORTS DrcDebug
~ BEGIN OPEN DrcDebug;
debug: PUBLIC BOOL ← UserProfile.Boolean [key: "Genista.Debug", default: FALSE];
trace: PUBLIC ATOM ← CoreProperties.RegisterProperty [$DrcTrace];
pause: PUBLIC ATOM ← CoreProperties.RegisterProperty [$break];
break: PUBLIC SIGNAL ~ CODE;
dLog: PUBLIC IO.STREAM ← IO.noWhereStream;
Note: Output to noWhereStream passes all I/O code, and hence is very slow !
ActivateDebug: UserProfile.ProfileChangedProc ~ BEGIN
profile: BOOL ~ UserProfile.Boolean [key: "Genista.Debug", default: FALSE];
IF debug THEN {IF (debug # profile) THEN debug ← FALSE}
ELSE {IF (debug # profile) THEN Debug}
END; -- ActivateDebug
Debug: PUBLIC PROC ~ BEGIN
For convenience in debugging. Call this procedure in the Interpreter.
viewerName: Rope.ROPE ~ "Genista debug";
viewer: ViewerTools.Viewer ← ViewerTools.FindExistingViewer [viewerName];
debug ← TRUE; -- Get all in one
dLog ← ViewerIO.CreateViewerStreams [viewerName, viewer].out
END; -- Debug
PrintWire: PUBLIC PROC [w: Core.Wire] ~ BEGIN
dLog.PutF ["%g %g %g\n", IO.rope [CoreOps.GetShortWireName[w]], IO.card [LOOPHOLE[w]], IO.refAny [w]];
FOR i: NAT IN [0 .. w.size) DO
dLog.PutF ["\t(%g) %g %g %g\n", IO.card [i], IO.rope [CoreOps.GetShortWireName[w[i]]], IO.card [LOOPHOLE[w[i]]], IO.refAny [w[i]]]
ENDLOOP
END; -- PrintWire
[] ← CDProperties.RegisterProperty [trace, $gbb];
[] ← CDProperties.RegisterProperty [pause, $gbb];
IF debug THEN Debug[];
UserProfile.CallWhenProfileChanges [ActivateDebug]
END.