MobObjectFiles.mesa
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Sturgis, June 22, 1989 3:49:00 pm PDT
Last tweaked by Mike Spreitzer on May 27, 1991 4:28 pm PDT
Philip James, August 27, 1991 3:28 pm PDT
Baran, October 21, 1991 3:08 pm PDT
DIRECTORY
IO USING[STREAM],
MobAccess USING[BTH, BTR, CTXH, CTXR, MobCookie, SEH, SER],
ObjectFiles USING[BracketPair, Module, Parsed, VarLoc, VarLocBody],
Rope USING[ROPE];
MobObjectFiles: CEDAR DEFINITIONS =
BEGIN
This interface provides information that requires joint inspection of mob and dotO files.
1) Given a pc, delivers the bth of the block most tightly enclosing the given pc. (Actually, the most tightly enclosing recognized block.) In addition, ensures that an association between bracket pairs and bths is constructed for the result bth and for all enclosing bths. (In so far as the association can be constructed from the dotO and mob.)
2) Given a bth and the seh for a variable occurring in the context of the bth, returns the field offset information for that variable. (This works only for blocks for which the bracket-pair-bth association has been constructed.) [Not yet installed]
BTH: TYPE = MobAccess.BTH;
BTR: TYPE = MobAccess.BTR;
CTXH: TYPE = MobAccess.CTXH;
CTXR: TYPE = MobAccess.CTXR;
SEH: TYPE = MobAccess.SEH;
SER: TYPE = MobAccess.SER;
Global data
JointMobParsedInfo: TYPE = REF JointMobParsedInfoBody;
JointMobParsedInfoBody: TYPE;
CreateJointMobParsedInfo: PROC[mob: MobAccess.MobCookie, whole: ObjectFiles.Parsed, module: ObjectFiles.Module] RETURNS[JointMobParsedInfo];
Stack Pointer Offset
Stack Pointer for a frame is obtained by adding SPOffset to the Frame Pointer.
GetSPOffset: PROC[callableBTH: BTH, jmpi: JointMobParsedInfo] RETURNS[INT];
This routine returns 0 if the SPOffset can not be obtained. Currently this is coded by inspecting the compiled instruction sequence. Hence, if the actual initial protocol is not as expected, this routine returns 0.
PC analysis
The following procedure performs two actions
1) Finds the BTH for the tightest recognized block enclosing the given PC
2) assures the BTH/BracketPair association for the found BTH and for the BTHs of all enclosing blocks (in so far as they are recognizable).
We return a list of BTHs. The first is the tightest callable BTH enclosing the given PC, successive BTHs are immediate descendents of the preceeding BTH, and the last BTH is the tightest BTH enclosing the given PC. (At least, the tightest recognizable.)
We return a list because we can currently only recognize the tightest callable BTH enclosing the given PC by checking for entries in the FB hash table. That is, the Mob does not mark catch phrase BTHs as callable.)
FindNearBTHAncestorsForPC: PROC[pc: CARD, jmpi: JointMobParsedInfo] RETURNS[LIST OF BTH];
The following procedure finds the BTH for the tightest recognized block enclosing the given block
Note that this procedure can only be called after we have called FindNearBTHAncestorsForPC on some enclosed block, and hence by action 2 of that routine, the appropriate BTH/BracketPair associations have already been made.
FindNearBTHAncestorsForBlock: PROC[block: BTH, jmpi: JointMobParsedInfo] RETURNS[LIST OF BTH];
GetRootBTH: PROC[jmdi: JointMobParsedInfo] RETURNS[BTH];
GetEntryPCofCallableBTH: PROC[callableBTH: BTH, jmpi: JointMobParsedInfo] RETURNS [CARD];
var info
VarLoc: TYPE = ObjectFiles.VarLoc;
VarLocBody: TYPE = ObjectFiles.VarLocBody;
GetVarLoc: PROC[seh: SEH, bth: BTH, jmpi: JointMobParsedInfo] RETURNS[VarLoc];
Assumes that seh is an id entry for a field in a local frame. Assumes that the seh is in the context associated with bth.
GetLocalFrameExtensionVar: PROC[bth: BTH, jmpi: JointMobParsedInfo] RETURNS[SEH];
Returns the seh of the field which is the local frame extension. This field is guaranteed to be in the stack frame, not the extension.
GetGlobalLinkVar: PROC[bth: BTH, jmpi: JointMobParsedInfo] RETURNS[SEH];
Returns the seh of the field which contains a pointer to the enclosing global frame. This field is guaranteed to be in the stack frame, not the extension.
GetStaticLinkVar: PROC[bth: BTH, jmpi: JointMobParsedInfo] RETURNS[SEH];
Returns the seh of the field which contains a pointer to the frame extension of the enclosing procedure frame. This field is guaranteed to be in the stack frame, not the extension.
GetStrandedStaticLinkLoc: PROC[bth: BTH, jmpi: JointMobParsedInfo] RETURNS[VarLoc];
Returns the static link for ENABLE scopes.
GetCatchPhraseStrandedStaticLinkLoc: PROC[bth: BTH, jmpi: JointMobParsedInfo] RETURNS[VarLoc];
Returns the static link for Catch phrase procedures.
GetGlobalFrameVarLoc: PROC[jmpi: JointMobParsedInfo] RETURNS[VarLoc];
Returns the VarLoc of the field which is the global frame. This field is a c-variable in the global frame of the module.
For debugging
The following procedure is useful for debugging. It should be called after CreateJointMobDotOInfo.
PerformJMDITest: PROC[what: Rope.ROPE, jmpi: JointMobParsedInfo, out: IO.STREAM];
The following procedure generates one PC for each bracket pair. This PC will be in the bracket but not in any nested bracket. (If there are no such PCs, then nothing is generated.)
GenInterestingPCs: PROC[module: ObjectFiles.Module, for: PROC[bp: ObjectFiles.BracketPair, pc: CARD]];
END..