-- SpyLog.mesa -- Last Modified by: John Maxwell 3-Feb-82 8:29:03 -- Last Edited by: Maxwell, January 18, 1983 2:35 pm DIRECTORY PrincOps USING [GFTIndex, BytePC], System USING[Pulses]; SpyLog: DEFINITIONS = BEGIN spy: BOOLEAN; -- are we monitoring the spy? logging: READONLY BOOLEAN; -- set by Open and Close Entry:TYPE = MACHINE DEPENDENT RECORD[ SELECT type:{endOfLog, nullEntry, trace, data} FROM endOfLog => [fill: [0..16000)_0], -- marks the end of valid data nullEntry => [size: [0..16000)_0], -- indicates data to be skipped trace => [ -- 4 words fill: [0..16)_0, gfi: PrincOps.GFTIndex, pc: PrincOps.BytePC, timestamp: System.Pulses], data => [ -- size + 4 words size: [0..16000), rttype: CARDINAL, timestamp: System.Pulses, data: ARRAY [0..0) OF WORD], ENDCASE]; Initialize: PROC[name: STRING, pages: CARDINAL, append: BOOLEAN _ FALSE]; Open: PROCEDURE[write: BOOLEAN _ TRUE, reset: BOOLEAN _ FALSE]; Close: PROCEDURE; -- there are two mutually exclusive modes: -- reading from the log and writing to the log. -- trying to read the log while it is in the write mode is an error. -- you do not have to close the log to reopen it in a different mode. NextEntry: PROCEDURE RETURNS[LONG POINTER TO Entry]; -- destructive read WriteData: PROCEDURE [type, size: CARDINAL, data: LONG POINTER]; -- try: WriteData[CODE[Foo],SIZE[Foo],@foo] -- or: WriteData[RTTypes.nullType, size, @data]; -- The system will store the type and use it to print the data -- This doesn't cost anything; all the expense is at compile time. -- An error will be generated if the type is ref-containing. WriteTrace: PROC [gfi: PrincOps.GFTIndex, pc: PrincOps.BytePC]; Here: PROC = INLINE {IF logging THEN WriteTrace[0, [0]]}; -- defaults to the current pc Print: PROC; -- prints on Trace.log -- implemented by TraceLogTest END.