RCTWSchemas.mesa
Copyright Ó 1989, 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Hopcroft August 18, 1989 11:46:08 am PDT
Last changed by Theimer on October 9, 1989 2:06:55 pm PDT
Sturgis, January 2, 1990 12:21:29 pm PST
Last tweaked by Mike Spreitzer on April 10, 1992 4:25 pm PDT
Philip James, August 27, 1991 3:33 pm PDT
Laurie Horton, May 19, 1992 1:26 pm PDT
Willie-s, June 11, 1992 4:16 pm PDT
DIRECTORY
CCTypes USING[CCError, CCErrorCase],
CirioNubAccess USING [Handle, --HandleBody,-- RemoteAddress],
CirioTypes USING[CompilerContext],
IO USING [PutFR, PutFR1],
LoadStateAccess USING [BasicPCInfo, GetLoadedModuleInfoFromStemName, LoadedModuleInfo, LoadStateHandle],
NewRMTW USING[CedarModuleSet],
ObjectFiles USING [FileSegmentPC, GetLineNumForPC, GetPCForLineNum],
PFS USING [nullUniqueID, PATH, PathFromRope, RopeFromPath, UniqueID],
RCTW USING [CBreakAddress, RopeList],
RMTWPrivate USING [GetNamePartsFromFullPathName, NameParts, SeekCSource],
Rope USING[ROPE],
SourceFileOps,
SystemInterface;
RCTWSchemas:
CEDAR
PROGRAM
IMPORTS CCTypes, IO, LoadStateAccess, ObjectFiles, PFS, RMTWPrivate, SystemInterface
EXPORTS RCTW
= BEGIN OPEN LSA:LoadStateAccess, ObjF:ObjectFiles;
CCError: ERROR[case: CCTypes.CCErrorCase, msg: Rope.ROPE ¬ NIL] ¬ CCTypes.CCError;
CCE: ERROR[case: CCTypes.CCErrorCase, msg: Rope.ROPE ¬ NIL] ¬ CCTypes.CCError;
CC: TYPE = CirioTypes.CompilerContext;
RemoteAddress: TYPE = CirioNubAccess.RemoteAddress;
InvalidRemoteAddress: CirioNubAccess.RemoteAddress ¬ [NIL, 0, 0, FALSE, FALSE];
Source mapping
GetSourcePosition:
PUBLIC
PROC [absPC:
CARD, cms: NewRMTW.CedarModuleSet, basicInfo:
REF
LSA.BasicPCInfo, ledo:
REF LoadStateAccess.LoadedModuleInfo]
RETURNS [SourceFileOps.Position] ~ {
containingDotORelativePC: CARD ~ absPC - ledo.lsi[text].base;
cln: CARD ~ ObjF.GetLineNumForPC[ledo.module, [[0, ""], containingDotORelativePC]];
file: SystemInterface.CirioFile ~ RMTWPrivate.SeekCSource[cms, basicInfo, ledo];
RETURN [[
fileName: IF file#NIL THEN file.GetNameOfFile[] ELSE PFS.PathFromRope["I-dont-know-the-filename.c"],
uniqueID: IF file#NIL THEN file.GetFileInfo.uniqueID ELSE PFS.nullUniqueID,
index: [line: [cln]]]]};
DescribeCBreakAddress:
PUBLIC
PROC [addr:
REF
RCTW.CBreakAddress]
RETURNS [
RCTW.RopeList] ~ {
IF addr=NIL THEN RETURN[LIST["failed to set break"]];
{srcName: PFS.PATH ~ SystemInterface.GetNameOfFile[addr.source];
RETURN[
LIST[
IO.PutFR["setting break at line %g of %g", [cardinal[addr.givenLineNumber]], [rope[PFS.RopeFromPath[srcName]]] ],
IO.PutFR1[" module relative pos = %g", [cardinal[addr.moduleRelativePC.relPC]] ],
IO.PutFR1[" statement begins at line %g", [cardinal[addr.stmtLineNumber]] ],
IO.PutFR1[" absolute PC = %g", [cardinal[addr.absPC]] ]
]]}};
GetAbsAddressForBreak:
PUBLIC
PROC [fileSet: SystemInterface.FileSet, src: SystemInterface.CirioFile, loadState: LoadStateAccess.LoadStateHandle, sourceLine:
CARD]
RETURNS [
REF
RCTW.CBreakAddress] ~ {
lmi: REF LoadStateAccess.LoadedModuleInfo ~ GetLoadedModuleForC[fileSet, src, loadState];
parsedRelativePC: ObjF.FileSegmentPC;
IF lmi=NIL THEN RETURN [NIL];
parsedRelativePC ¬ ObjF.GetPCForLineNum[lmi.module, sourceLine];
RETURN [
NEW[
RCTW.CBreakAddress ¬ [
source: src,
givenLineNumber: sourceLine,
moduleRelativePC: [[0, ""], parsedRelativePC.relPC - lmi.moduleRelativeBaseAddr],
This crockaloid construction is copied from RMTWModules on Dec 12, 1991 by MJS, who doesn't know why we're making such a mess.
absPC: lmi.lsi[text].base+parsedRelativePC.relPC,
stmtLineNumber: ObjF.GetLineNumForPC[lmi.module, parsedRelativePC],
loadedModule: lmi]] ]};
GetLoadedModuleForC:
PROC [fileSet: SystemInterface.FileSet, src: SystemInterface.CirioFile, loadState: LoadStateAccess.LoadStateHandle]
RETURNS [lmi:
REF LoadStateAccess.LoadedModuleInfo ¬
NIL] ~ {
srcName: PFS.PATH ¬ SystemInterface.GetNameOfFile[src];
parts: RMTWPrivate.NameParts ¬ RMTWPrivate.GetNamePartsFromFullPathName[srcName];
stemRope: Rope.ROPE ¬ parts.nameStem;
lmi ¬ LoadStateAccess.GetLoadedModuleInfoFromStemName[loadState, parts.nameStem, 1];
};
END..