SPARCBreakpoint.mesa
Copyright Ó 1989, 1990 by Xerox Corporation. All rights reserved.
Peter B. Kessler, March 29, 1990 10:30 am PST
DIRECTORY
SPARCArchitecture,
SPARCManger;
SPARCBreakpoint: CEDAR DEFINITIONS ~ {
Patches can't be monitored, since the processor executes out of them. My accesses of the patches and the pc's executing in them are races. That isn't a problem because the pc's never get to the patches until I'm done setting them up (fortunately), and I don't clear the patch. Clearing a breakpoint is just putting the instruction back, since you can't tell when the pc (or several of them) are done with the patch (that's is a garbage collection problem).
This closureCaller is for SPARC's: it includes pushing an extra register window to avoid some register saving and to allocate space for saving the rest of the registers.
save %sp, -(spOffset+stackAllocationForCallee+registerSaveArea), %sp
  -- allocate a register window and a register save area.
call ←save←regs
add %sp, spOffset+stackAllocationForCallee, %o0
  -- save←regs(@registerSaveArea).
sethi %hi(clientData), %o0
callclientProc
or  %lo(clientData), %o0
  -- clientProc(clientData).
call ←restore←regs
add %sp, spOffset + stackAllocationForCallee, %o0
  -- restore←regs(@registerSaveArea).
restore %sp, +(spOffset+stackAllocationForCallee+registerSaveArea), %sp
  -- deallocate the register window and register save area.
Constants.
registerSaveArea: NAT ~ 64 * BYTES[SPARCArchitecture.SPARCContents];
64 words for saving the rest of the registers.
Types.
Patches are self-describing, in that they include the address of the replaced instruction (in the header) and the replaced instruction (relocated into the patch).
PatchStruct: TYPE ~ MACHINE DEPENDENT RECORD [
closureCaller: ClosureCaller,
manger:  SPARCManger.Manger
];
ClosureCaller: TYPE ~ MACHINE DEPENDENT RECORD [
save:  SPARCArchitecture.SPARCInstruction,
callSaveRegs: SPARCArchitecture.SPARCInstruction,
argSaveAreaOnce: SPARCArchitecture.SPARCInstruction,
in the delay slot.
argHiClientData: SPARCArchitecture.SPARCInstruction,
callClientProc: SPARCArchitecture.SPARCInstruction,
argLoClientData: SPARCArchitecture.SPARCInstruction,
in the delay slot.
callRestoreRegs: SPARCArchitecture.SPARCInstruction,
argSaveAreaAgain: SPARCArchitecture.SPARCInstruction,
in the delay slot.
restore:  SPARCArchitecture.SPARCInstruction
];
}.