SpyClient.mesa
Copyright Ó 1985, 1987 by Xerox Corporation. All rights reserved.
Maxwell November 29, 1983 11:27 am
see SpyDoc.tioga for instructions on how to use this interface
Russ Atkinson (RRA) February 16, 1987 12:16:40 pm PST
Mike Spreitzer September 24, 1986 12:38:30 pm PDT
DIRECTORY
AMModel USING [Section],
IO USING [STREAM],
PrincOps USING [PsbNull, PsbIndex],
Rope USING [ROPE];
SpyClient: DEFINITIONS = BEGIN OPEN Rope;
StackType: TYPE = MACHINE DEPENDENT {
ready (0),
pageFault (1),
waitingML (2),
waitingCV (3),
preempted (4),
waitingSV (5),
unknown (6),
pageFaultData (7),
pageFaultCode (8),
pageFaultXfer (9),
allocSafe (10),
allocPerm (11),
allocUnsafe (12),
userBreak (13)};
DataType: TYPE = MACHINE DEPENDENT {
CPU (0), process, breakProcess, pagefaults, allocations, wordsAllocated, userDefined};
common procedures
InitializeSpy: PROC [dataType: DataType ← CPU, process: PrincOps.PsbIndex ← PrincOps.PsbNull, spyOnSpyLog: BOOLFALSE, frequencyDivisor: NAT ← 1] RETURNS [errorMsg: ROPE];
process is only used if dataType = process
spyOnSpyLog is used by DisplayData
errorMsg = NIL indicates success
When dataType is one of {CPU, process, breakProcess, allocations, wordsAllocated}, we ignore all but one of every frequencyDivisor wakeups.
StandardSpy: PROC = INLINE {IF InitializeSpy[].errorMsg # NIL THEN ERROR};
StartSpy: PROC;
the spy records data whenever # starts exceeds # stops
StopSpy: PROC;
you must StartSpy to enable breaks
DisplayData: PROC [cutoff: CARDINAL ← 3, herald: ROPENIL, stream: IO.STREAMNIL, spyOnSpyLog: BOOLFALSE];
... displays data (automatically stops Spy); cutoff gives cutoff of printing (in percentage points); herald is the client supplied herald (follows Cedar Spy of xxx); a typescript is opened if stream = NIL
break procedures
SetStartBreak: PROC [section: AMModel.Section ← NIL, procedure: ROPENIL, sourceIndex: INT ← 0] RETURNS [ok: BOOL, msg: ROPE];
... sets a breakpoint that will start Spying whenever the breakpoint is encountered. procedure is of form "ModuleIMPL.Proc" & is only used if section = NIL; if sourceIndex # 0, then treat `procedure' as a filename.
SetStopBreak: PROC [section: AMModel.Section ← NIL, procedure: ROPENIL, sourceIndex: INT ← 0] RETURNS [ok: BOOL, msg: ROPE];
... sets a breakpoint that will stop Spying whenever the breakpoint is encountered. procedure is of form "ModuleIMPL.Proc" & is only used if section = NIL (breakpoint is set at the RETURN); if sourceIndex # 0, then treat `procedure' as a filename.
ClearBreaks: PROC;
clears all stop and start breaks
SetUserBreak: PROC [section: AMModel.Section ← NIL, type: StackType ← ready, procedure: ROPENIL, sourceIndex: INT ← 0] RETURNS [ok: BOOL, msg: ROPE];
log a count whenever this break is encountered; type allows the user to distinguish breaks; procedure is of form "ModuleImpl.Proc"; only used if section = NIL; if sourceIndex # 0, then treat `procedure' as a filename
SetTrace: PROC [section: AMModel.Section ← NIL, procedure: ROPENIL, sourceIndex: INT ← 0] RETURNS [ok: BOOL, msg: ROPE];
sets a break such that Spy writes a trace on the spy log whenever this break is encountered; procedure is of form "ModuleImpl.Proc"; only used if section = NIL; if sourceIndex # 0, then treat `procedure' as a filename
ClearUserBreaks: PROC;
clears all stop and start breaks; clears the traces, too.
END. .