FakeRemoteCirioImpl.mesa
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Peter B. Kessler, April 18, 1990 10:12:45 pm PDT
DIRECTORY
FakeCirio,
TargetArchitecture,
BreakWorldArchitecture,
PCRMonitorDefs;
FakeRemoteCirioImpl: CEDAR PROGRAM
IMPORTS FakeCirio, BreakWorldArchitecture
EXPORTS FakeCirio
~ {
MonitoredCall: PUBLIC BreakWorldArchitecture.MonitoredCallProc ~ {
PROCEDURE [address: Address, proc: PROCEDURE [] RETURNS []] RETURNS []
IF address.IsNullAddress[] THEN {
ERROR FakeCirio.Cant[message: "MonitoredCall[nullAddress]"];
};
IF proc = NIL THEN {
ERROR FakeCirio.Cant[message: "MonitoredCall[nullProc]"];
};
{
HolderOffset: PROCEDURE [] RETURNS [TargetArchitecture.Displacement] ~ TRUSTED {
Watch this! We compute target field offsets using structures we've defined over here!
I think this is about the grottiest code I've written, but Russ says it's the most straightforward way of doing it.
sampleMonitorLock: PCRMonitorDefs.MonitorLock;
sampleAddress: LONG POINTER TO PCRMonitorDefs.MonitorLock ~
@sampleMonitorLock;
sampleAddressCard: CARD32 ~ LOOPHOLE[sampleAddress];
holderAddress: LONG POINTER TO TargetArchitecture.Contents ~
@sampleMonitorLock.holder;
holderAddressCard: CARD32 ~ LOOPHOLE[holderAddress];
offset: TargetArchitecture.Displacement ~
(holderAddressCard - sampleAddressCard) * BYTES[UNIT];
RETURN [offset];
};
holder: TargetArchitecture.Contents ~ BreakWorldArchitecture.PeekContents[
address: address, displacement: HolderOffset[]];
IF holder = PCRMonitorDefs.nullHolder
THEN {
We don't have to acquire the monitor lock, since the remote debuggee is frozen.
proc[];
}
ELSE {
We can't acquire the monitor lock, and the remote world is frozen.
ERROR BreakWorldArchitecture.WouldBlock["Monitor lock already held"];
};
};
};
}.