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"];
};