CirioDeltaFaceSunImpl.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Linda Howe, January 19, 1990 9:59:53 am PST
Sturgis: March 23, 1990 12:05 pm PST
Spreitze, August 15, 1991 7:58 am PDT
Coolidge, July 29, 1990 3:58 pm PDT
Laurie Horton, September 25, 1991 3:23 pm PDT
Katsuyuki Komatsu January 21, 1993 5:52 pm PST
Willie-s, March 2, 1993 3:45 pm PST
DIRECTORY
CirioDeltaFace,
CirioNubAccess USING [FileEntry, FileEntryBody, Handle, PCInfo, PCInfoBody, Read32BitsAsCard, SymEntry, SymEntryBody],
MorePfsNames,
Process USING [PauseMsec, Yield],
PFS USING [PathFromRope],
PFSNames USING [Component, ComponentRope, ConstructName, Fetch, IsAbsolute, PATH],
Rope USING [Equal, EqualSubstrs, IsPrefix, Length, ROPE, Substr],
UXStrings USING [Create, CString, ToRope]
;
CirioDeltaFaceSunImpl: CEDAR PROGRAM
IMPORTS CirioNubAccess, MorePfsNames, PFS, PFSNames, Process, Rope, UXStrings
EXPORTS CirioDeltaFace
= BEGIN OPEN MPN:MorePfsNames;
PATH: TYPE ~ PFSNames.PATH;
IsMachineDependentSubdirectory: PUBLIC PROC [part: PFSNames.Component] RETURNS [BOOLEAN] = {
cr: Rope.ROPE ~ part.ComponentRope;
RETURN [Rope.IsPrefix["sun4", cr, FALSE] AND (cr.Length[]=4 OR cr.EqualSubstrs[start1: 4, s2: "-o3", case: FALSE] OR cr.EqualSubstrs[start1: 4, s2: "O3", case: FALSE])]};
netComp: MPN.Component ~ MPN.ConstructComponent[["net"]];
DebuggeeNameToDebuggerName: PUBLIC PROC [name: PATH, debuggee: Rope.ROPE, Warning: PROC [Rope.ROPE]] RETURNS [PATH] ~ {
c1: MPN.Component;
c1r: Rope.ROPE;
exd: INT ¬ 0;
c1ndx: INT ¬ 0;
IF name.IsAbsolute THEN c1ndx ¬ 1;
c1 ¬ name.Fetch[c1ndx];
c1r ¬ c1.ComponentRope[];
IF c1r.Equal["tmp←mnt"] THEN {
exd ¬ 1;
c1 ¬ name.Fetch[c1ndx+exd];
c1r ¬ c1.ComponentRope[]};
IF debuggee.Equal["localhost", FALSE] OR c1r.Equal["net"] OR exd=1 OR c1r.Equal["symbolics"] OR c1r.Equal["project"] OR c1r.Equal["volume"] OR c1r.Equal["pseudo"] OR c1r.Equal["tilde"] OR c1r.Equal["sunos"] OR c1r.Equal["homes"] OR c1r.Equal["home"] OR c1r.Equal["X11R3"] OR c1r.Equal["dsbu"] OR c1r.Equal["import"] OR c1r.Equal["rhome"] THEN {
Debuggee is on same machine as debugger, or the file is automounted; assume equivalent mounting on debuggee.
List gleaned from (1) automount commands in /etc/rc*, and (2) the YP map `auto.master' on ypservers at Parc and Sunnyvale.
IF exd=1 THEN name ¬ MPN.Replace[name, c1ndx, 1, NIL];
RETURN [name]};
RETURN MPN.Replace[name, c1ndx, 0, PFSNames.ConstructName[LIST[netComp, MPN.ConstructComponent[[debuggee]] ], TRUE, TRUE]]};
<<
GetOurPrefixForUnixPrefix: PUBLIC PROC[volume: PATH, unixPrefix: PATH, serverName: Rope.ROPE, whichView: Rope.ROPE ¬ "ux"] RETURNS[PATH] =
BEGIN
volumeRope: Rope.ROPE ¬ PFS.RopeFromPath[volume];
unixPrefixRope: Rope.ROPE ¬ PFS.RopeFromPath[unixPrefix];
unixPrefixRope ¬ unixPrefixRope.Substr[0, unixPrefixRope.Length-1];
SELECT TRUE FROM
volumeRope.Equal["/net/"]
=> RETURN[ PFS.PathFromRope[Rope.Cat[volumeRope, unixPrefixRope, "/"]]];
volumeRope.Equal["/tmp←mnt/net/"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/net/", unixPrefixRope, "/"]]];
volumeRope.Equal["/volume/"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/eich-", whichView, "/", unixPrefixRope, "/"]]];
volumeRope.Equal["/pseudo/"]
=> IF unixPrefixRope.Equal["xrhome"] THEN RETURN[PFS.PathFromRope["/palain-ux/jaune/xrhome/"]]
ELSE RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
unixPrefixRope.Equal["home"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/", serverName, "-", whichView, "/home/"]]];
unixPrefixRope.Equal["jaune"],
unixPrefixRope.Equal["rouge"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/palain-", whichView, "/", unixPrefixRope, "/"]]];
unixPrefixRope.Equal["pixel1"],
unixPrefixRope.Equal["pixel2"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/eich-", whichView, "/", unixPrefixRope, "/"]]];
unixPrefixRope.Equal[""]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/nadreck-", whichView, "/", unixPrefixRope, "/"]]];
unixPrefixRope.Find["-"] > -1
=> RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
Are there more of these we should catch? Alternatively, should the check for
volume="/" below only check known unix volume names?
unixPrefixRope.Equal["PCedar2.0"],
unixPrefixRope.Equal["CedarChest7.0"],
unixPrefixRope.Equal["Cedar7.0"],
unixPrefixRope.Equal["CedarCommon"]
=> RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
unixPrefixRope.Equal["tmp"]
=> IF serverName # NIL AND ~ serverName.Equal["sameWorld"] THEN
RETURN[ PFS.PathFromRope[Rope.Cat[Rope.Cat["/net/", serverName, "/", serverName, "/"], unixPrefixRope, "/"]]]
ELSE RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
volumeRope.Equal["/"]
=> IF serverName # NIL AND ~ serverName.Equal["sameWorld"] THEN
RETURN[ PFS.PathFromRope[Rope.Cat["/net/", serverName, "/", unixPrefixRope, "/"]]]
ELSE RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
ENDCASE => RETURN[ PFS.PathFromRope[Rope.Cat["/", unixPrefixRope, "/"]]];
END;
AddFileSystemView: PUBLIC PROC[fileName: Rope.ROPE] RETURNS [Rope.ROPE] =
BEGIN
RETURN [Rope.Cat["-ux:", fileName]];
END;
>>
IsDMachine: PUBLIC PROC[] RETURNS [BOOLEAN] =
BEGIN
RETURN [FALSE];
END;
TargetVersionMapName: PUBLIC PROC[base: ATOM] RETURNS [ATOM]
~ {RETURN [base]};
The SWPCInfo MACHINE DEPENDENT RECORD overlays the CirioNubPCInfo structure defined in CirioNubTypes.h.
SWPCInfoPtr: TYPE ~ POINTER TO SWPCInfo;
SWPCInfo: TYPE = MACHINE DEPENDENT RECORD [
procName: UXStrings.CString,
procSymID: CARD,
fileName: UXStrings.CString,
fileSeqNum: CARD,
guessedEmbeddedFileName: UXStrings.CString,
guessedEmbeddedFileSymID: CARD
];
SameWorldPCtoInfo: PUBLIC PROC[pc: CARD] RETURNS[CirioNubAccess.PCInfo] = TRUSTED
BEGIN
PCtoInfoInner: PROC [pc: CARD, buf: SWPCInfoPtr] RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalPCtoInfo"
};
info: CirioNubAccess.PCInfo ¬ NEW[CirioNubAccess.PCInfoBody];
buf: SWPCInfo;
THROUGH [1..3] DO
result: INT ~ PCtoInfoInner[pc, @buf];
IF result = 0 THEN EXIT;
Process.PauseMsec[1D3];
REPEAT
FINISHED => RETURN [NIL];
ENDLOOP;
info.procName ¬ UXStrings.ToRope[buf.procName];
info.procSymID ¬ buf.procSymID;
info.fileName ¬ PFS.PathFromRope[UXStrings.ToRope[buf.fileName]];
info.fileSeqNum ¬ buf.fileSeqNum;
info.guessedEmbeddedFileName ¬ PFS.PathFromRope[UXStrings.ToRope[buf.guessedEmbeddedFileName]];
info.guessedEmbeddedFileSymID ¬ buf.guessedEmbeddedFileSymID;
RETURN[info];
END;
The SWFileEntry MACHINE DEPENDENT RECORD overlays the CirioNubFileEntry structure defined in CirioNubTypes.h.
SWFileEntryPtr: TYPE ~ POINTER TO SWFileEntry;
SWFileEntry: TYPE = MACHINE DEPENDENT RECORD [
seqNum: CARD,
commitPoint: CARD, -- this is a bool in the C structure;
fileName: UXStrings.CString,
fOffset: CARD,
fMagic: CARD,
size: CARD,
mTime: CARD,
sMagic: CARD,
stamp: CARD,
stampSize: CARD,
readerData: CARD,
readerDataSize: CARD,
patchReloc: CARD,
patchSize: CARD,
textReloc: CARD,
textSize: CARD,
dataReloc: CARD,
dataSize: CARD,
bssReloc: CARD,
bssSize: CARD,
commonReloc: CARD,
commonSize: CARD];
SameWorldGetFileEntry: PUBLIC PROC[seqNum: CARD] RETURNS[CirioNubAccess.FileEntry] = TRUSTED
BEGIN
GetFileEntryInner: PROC [seqNum: CARD, buf: SWFileEntryPtr] RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalGetFileEntry"
};
entry: CirioNubAccess.FileEntry ¬ NEW[CirioNubAccess.FileEntryBody];
buf: SWFileEntry;
result: INT ¬ GetFileEntryInner[seqNum, @buf];
IF result # 0 THEN ERROR;
entry.seqNum ¬ buf.seqNum;
entry.commitPoint ¬ LOOPHOLE[buf.commitPoint];
entry.fileName ¬ PFS.PathFromRope[UXStrings.ToRope[buf.fileName]];
entry.fOffset ¬ buf.fOffset;
entry.fmagic ¬ buf.fMagic;
entry.size ¬ buf.size;
entry.mtime ¬ buf.mTime;
entry.smagic ¬ buf.sMagic;
entry.stamp ¬ NIL;
(we should read in the stamp at this point)
entry.readerData ¬ buf.readerData;
entry.readerDataSize ¬ buf.readerDataSize;
entry.patchReloc ¬ buf.patchReloc;
entry.patchSize ¬ buf.patchSize;
entry.textReloc ¬ buf.textReloc;
entry.textSize ¬ buf.textSize;
entry.dataReloc ¬ buf.dataReloc;
entry.dataSize ¬ buf.dataSize;
entry.bssReloc ¬ buf.bssReloc;
entry.bssSize ¬ buf.bssSize;
entry.commonReloc ¬ buf.commonReloc;
entry.commonSize ¬ buf.commonSize;
RETURN[entry];
END;
The SWSymEntry MACHINE DEPENDENT RECORD overlays the CirioNubSymEntry structure defined in CirioNubTypes.h.
SWSymEntryPtr: TYPE ~ POINTER TO SWSymEntry;
SWSymEntry: TYPE = MACHINE DEPENDENT RECORD [
symID: CARD,
name: UXStrings.CString,
type: CARD,
value: CARD,
size: CARD,
fileSeqNum: CARD];
SameWorldLookupSymEntryByName: PUBLIC PROC [
sym: Rope.ROPE,
caseSensitive: BOOLEAN,
externOnly: BOOLEAN,
numToSkip: INT]
RETURNS [CirioNubAccess.SymEntry] = TRUSTED
BEGIN
LookupSymEntryByNameInner: PROC [
sym: UXStrings.CString,
caseSensitive: BOOLEAN,
externOnly: BOOLEAN,
numToSkip: INT,
buf: SWSymEntryPtr]
RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalLookupSymEntryByName"
};
buf: SWSymEntry;
result: INT ¬ LookupSymEntryByNameInner[UXStrings.Create[sym], caseSensitive, externOnly, numToSkip, @buf];
RETURN[SameWorldComputeSymEntry[result, buf]];
END;
SameWorldLookupSymEntryByValue: PUBLIC PROC [
val: CARD,
numToSkip: INT]
RETURNS [CirioNubAccess.SymEntry] = TRUSTED
BEGIN
LookupSymEntryByValueInner: PROC [
val: CARD,
numToSkip: INT,
buf: SWSymEntryPtr]
RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalLookupSymEntryByValue"
};
buf: SWSymEntry;
result: INT ¬ LookupSymEntryByValueInner[val, numToSkip, @buf];
RETURN[SameWorldComputeSymEntry[result, buf]];
END;
SameWorldLookupSymEntryByID: PUBLIC PROC[symID: CARD] RETURNS[CirioNubAccess.SymEntry] = TRUSTED
BEGIN
LookupSymEntryByIDInner: PROC[symID: CARD, buf: SWSymEntryPtr] RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalLookupSymEntryByID"
};
buf: SWSymEntry;
result: INT ¬ LookupSymEntryByIDInner[symID, @buf];
RETURN[SameWorldComputeSymEntry[result, buf]];
END;
SameWorldLookupMatchingSymEntryByName: PUBLIC PROC [
symID: CARD,
pattern: Rope.ROPE,
caseSensitive: BOOLEAN,
wantedTypes: CARD,
ignoreClasses: CARD,
numToSkip: INT]
RETURNS[CirioNubAccess.SymEntry] = TRUSTED
BEGIN
LookupMatchingSymEntryByNameInner: PROC [
symID: CARD,
pattern: UXStrings.CString,
caseSensitive: BOOLEAN,
wantedTypes: CARD,
ignoreClasses: CARD,
numToSkip: INT,
buf: SWSymEntryPtr]
RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalGetMatchingSymEntryByName"
};
buf: SWSymEntry;
result: INT ¬ LookupMatchingSymEntryByNameInner[symID, UXStrings.Create[pattern], caseSensitive, wantedTypes, ignoreClasses, numToSkip, @buf];
RETURN[SameWorldComputeSymEntry[result, buf]];
END;
SameWorldLookupMatchingSymEntryByValue: PUBLIC PROC [
symID: CARD,
val: CARD,
wantedTypes: CARD,
ignoreClasses: CARD,
numToSkip: INT]
RETURNS[CirioNubAccess.SymEntry] = TRUSTED
BEGIN
LookupMatchingSymEntryByValueInner: PROC [
symID: CARD,
val: CARD,
wantedTypes: CARD,
ignoreClasses: CARD,
numToSkip: INT,
buf: SWSymEntryPtr]
RETURNS [INT] = TRUSTED MACHINE CODE {
"CirioNubLocalGetMatchingSymEntryByValue"
};
buf: SWSymEntry;
result: INT ¬ LookupMatchingSymEntryByValueInner[symID, val, wantedTypes, ignoreClasses, numToSkip, @buf];
RETURN[SameWorldComputeSymEntry[result, buf]];
END;
SameWorldComputeSymEntry: PROC[result: INT, buf: SWSymEntry] RETURNS[CirioNubAccess.SymEntry] =
BEGIN
IF result = 0
THEN
BEGIN
entry: CirioNubAccess.SymEntry ¬ NEW[CirioNubAccess.SymEntryBody];
entry.symID ¬ buf.symID;
entry.name ¬ UXStrings.ToRope[buf.name];
entry.type ¬ buf.type;
entry.value ¬ buf.value;
entry.size ¬ buf.size;
entry.fileSeqNum ¬ buf.fileSeqNum;
RETURN[entry];
END
ELSE
RETURN[NIL];
END;
JmpBufPtr: TYPE ~ POINTER TO JmpBuf;
JmpBuf: TYPE = PACKED ARRAY [0..3) OF WORD;
GetCallersSPandPC: PUBLIC PROC[nub: CirioNubAccess.Handle] RETURNS[callerInfo: CirioDeltaFace.CallerInfo] = TRUSTED {
SetJmp: PROC [jb: JmpBufPtr] RETURNS [INT]
~ TRUSTED MACHINE CODE {"XR←setjmp"};
GetOurStackPointer: PROC [jb: JmpBufPtr] RETURNS [CARD]
= TRUSTED MACHINE CODE {"CirioNubLocalSPFromJmpBuf"};
jb: JmpBuf;
result: INT;
ourStackPointerC: CARD;
ourStackPointerI: INT;
Flush the stack into memory.
Process.Yield[];
Save the current context.
result ¬ SetJmp[@jb];
IF result # 0 THEN ERROR;
Get the callers stack pointer and PC. Our framepointer (fp) is the callers stackpointer (sp).
ourStackPointerC ¬ GetOurStackPointer[@jb];
ourStackPointerI ¬ LOOPHOLE[ourStackPointerC];
callerInfo.callersPC ¬ CirioNubAccess.Read32BitsAsCard[[nub, ourStackPointerI+(15*4), 0, FALSE, TRUE]];
callerInfo.callersStackPointer ¬ CirioNubAccess.Read32BitsAsCard[[nub, ourStackPointerI+(14*4), 0, FALSE, TRUE]];
RETURN [callerInfo]};
END.