PROC[remoteName: Rope.
OF Rope.
IO.
outerMsg: Rope.ROPE ← CirioBackstop.Protect[Openit, reports];
FunctionalOpen:
PROC
RETURNS[Connection] ~ {
nub: CirioNubAccess.Handle ← NIL;
target: CirioTargets.Target ← NIL;
fileSet: SystemInterface.FileSet;
breaks: CirioBreakAccess.CirioBreakSet;
searchDirs: LIST OF PFSNames.PATH ← NIL;
lastSearchDir: LIST OF PFSNames.PATH ← NIL;
defaultSearchDirs:
LIST
OF PFSNames.
PATH ←
LIST[
PFS.PathFromRope["/PCedar/Cirio/"],
PFS.PathFromRope["/PCedar/CirioThings/"],
PFS.PathFromRope["/PCedar/Atom/"],
PFS.PathFromRope["/PCedar/Rope/"] ];
A remote world needs to have the navel examination in CreateRemoteMimosaTargetWorld succeed; that requires finding CirioThings/CirioRopeHelper.mob, Rope/Rope.mob, and Atom/AtomPrivate.mob (on August 17, 1991).
ClearBreaksForOpen:
PROC
RETURNS[Rope.
ROPE] = {
CirioBreakAccess.ClearAllBreaks[breaks];
RETURN[NIL]};
Build the list of search directories, starting with the user supplied directories.
searchDirs ← LIST [PFS.PathFromRope["-compiled:/CirioCompiledData/"]];
lastSearchDir ← searchDirs;
FOR thisDir:
LIST
OF Rope.
ROPE ← workingDirectories, thisDir.rest
WHILE thisDir #
NIL
DO
lastSearchDir.rest ← LIST [PFS.AbsoluteName[PFS.PathFromRope[thisDir.first]]];
lastSearchDir ← lastSearchDir.rest;
ENDLOOP;
Join the user supplied and default search directories.
lastSearchDir.rest ← defaultSearchDirs;
nub ← CirioNubAccess.CreateRemoteNub[debuggee: remoteName, port: portNum, timeoutMsec: 10000
!CirioNub.Error => {
reports.PutF["Failed to open DebugNub connection to port %g on %g.\n", [cardinal[portNum]], [rope[remoteName]] ];
CONTINUE}];
IF nub=NIL THEN RETURN [NIL];
target ← CirioTargets.CreateTarget[nub];
target ← NARROW[nub.target];
fileSet ← SystemInterface.CreateFileSet[];
breaks ← CirioBreakAccess.CreateCirioBreakSet[nub, "CirioThingsImpl", "CallDebugger"];
IF breaks.BreakSetBroken[] THEN reports.PutRope["You won't be able to set breakpoints in the debuggee, because I was unable to find CirioThingsImpl.CallDebugger in the debuggee. Are you sure you loaded an unoptimized version of CirioThingsImpl into the debuggee somewhere along the line?\n"];
We nest a block so that we can provide an unwind catch phrase to close the nub in the event of trouble before we hand responsibility to our caller. (We also close the file set and clear all breaks.)
{
ENABLE
UNWIND => {
-- all attempts to give a report will be ignored
finalMsg: Rope.ROPE ← CirioBackstop.Protect[ClearBreaksForOpen, reports];
CirioNubAccess.DestroyNub[nub];
SystemInterface.CloseFileSet[fileSet];
IF Rope.Length[finalMsg] # 0 THEN IO.PutF[reports, "%g\N", IO.rope[finalMsg]];
};
cc, lcc: CC;
cedarModules: NewRMTW.CedarModuleSet;
lsh: LoadStateAccess.LoadStateHandle;
rmtw: NewRMTW.RemoteMimosaTargetWorld;
ampersandContext1, ampersandContext2: CirioTypes.Node;
aph: NewAmpersandProcs.Handle;
connection: Connection;
IF NOT CirioNubAccess.Null[nub, 7] THEN CCE[cirioError, "debuggee doesn't implement debug nub protocol version 7"];
cc ← CCTypes.CreateCedarCompilerContext[];
cedarModules ← NewRMTW.CreateCedarModuleSet[fileSet, remoteName];
NewRMTW.ResetSearchPaths[cedarModules, searchDirs, BasicTime.Now[]];
lsh ← LoadStateAccess.CreateLoadStateHandle[remoteName, nub, fileSet];
rmtw ← NewRMTW.CreateRemoteMimosaTargetWorld[remoteName, nub, cc, cedarModules, lsh, reports, TRUE];
ampersandContext1 ← AmpersandContext.CreateAnAmpersandContext[cc];
ampersandContext2 ← AmpersandContext.CreateAnAmpersandContext[cc];
aph ←
NEW[NewAmpersandProcs.HandleBody←[
out: NIL, -- filled in during a line interpretation in StackCirioImpl
rmtw: rmtw,
cedarModules: cedarModules,
nub: nub,
fileSet: fileSet,
lsh: lsh]];
connection←
NEW[ConnectionBody←[
open: TRUE,
doradoWorkingDirectory: workingDirectories.first,
serverName: remoteName,
searchDirectories: searchDirs,
ampersandContext1: ampersandContext1,
ampersandContext2: ampersandContext2,
cc: cc,
localCc: lcc,
localConnection: LocalCirio.GetConnection[LocalCirio.nilBreakDest, reports],
rmtw: rmtw,
cedarModules: cedarModules,
nub: nub,
target: target,
daemon: NIL,
daemonKillFlag: FALSE,
breaks: breaks,
fileSet: fileSet,
lsh: lsh,
aph: aph,
cParserTable: NIL]];
connection.localCc ← LocalCirio.ExtractCcFromConnection[connection.localConnection];
connection.ampersandContext1 ← AmpersandContext.CreateAnAmpersandContext[connection.localCc];
connection.ampersandContext2 ← AmpersandContext.CreateAnAmpersandContext[connection.localCc];
ampersandContext1 ← connection.ampersandContext1;
ampersandContext2 ← connection.ampersandContext2;
NewAmpersandProcs.InstallItems[connection.ampersandContext2, aph, connection.localCc];
InstallBreakCheckDaemon[connection, reports];
IF CirioDeltaFace.IsDMachine[] = FALSE THEN RETURN[connection];
IF
TRUE
THEN
RETURN[connection];
disables the following ampersand routines. Should move any useful ones to NewAmpersandProcs.
InstallOneAmpersandItem[ampersandContext2, "&&H", CCTypes.CreateNodeFromRefAny[NEW[Connection ← connection], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&RdCards", CCTypes.CreateNodeFromRefAny[NEW[PROC[a: CirioTypes.CirioAddress, nCards: CARD] ← RdCards], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&RdHexCards", CCTypes.CreateNodeFromRefAny[NEW[PROC[a: CirioTypes.CirioAddress, nCards: CARD] ← RdHexCards], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&RdBytes", CCTypes.CreateNodeFromRefAny[NEW[PROC[a: CirioTypes.CirioAddress, nBytes: CARD] ← RdBytes], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&RdChars", CCTypes.CreateNodeFromRefAny[NEW[PROC[a: CirioTypes.CirioAddress, nChars: CARD] ← RdChars], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&RdRope", CCTypes.CreateNodeFromRefAny[NEW[PROC[a: CirioTypes.CirioAddress, nChars: CARD ← 100] ← RdRope], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&MkAddress", CCTypes.CreateNodeFromRefAny[NEW[PROC[byteAddress: CARD, h: Connection] RETURNS[CirioTypes.CirioAddress] ← MkAddress], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&FrameDiagnosticInfo", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection] ← FrameDiagnosticInfo], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&SetBreakAtAbsAddr", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, absAddr: CARD32, mesaPos: SourceFileOpsExtras.Position, stopAll: BOOLEAN] ← SetBreakAtAbsAddr], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ListBreaks", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection] ← ListBreaks], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ClearBreakAtAbsAddr", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, absAddr: CARD32] ← ClearBreakAtAbsAddr], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ClearBreakAtIndex", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, index: CARD] ← ClearBreakAtIndex], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ClearAllBreaks", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection] ← ClearAllBreaks], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&AddDir", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, dirName: Rope.ROPE, reports: IO.STREAM] ← AddDir], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ListDir", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection] ← ListDir], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&ClearDir", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection] ← ClearDir], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&LookupSym", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, name: Rope.ROPE, numToSkip: INT ← 0, externOnly: BOOL ← TRUE] RETURNS[CirioNubAccess.SymEntry] ← LookupSym], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&LookupAddr", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, val: CARD, numToSkip: INT ← 0] RETURNS[CirioNubAccess.SymEntry] ← LookupAddr], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&LookupID", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, symID: CARD] RETURNS[CirioNubAccess.SymEntry] ← LookupID], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&LookupFile", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, seqNum: CARD] RETURNS[entry: CirioNubAccess.FileEntry] ← LookupFile], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&GetPCInfo", CCTypes.CreateNodeFromRefAny[NEW[PROC[h: Connection, absPC: CARD] RETURNS[CirioNubAccess.PCInfo] ← GetPCInfo], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&GetRelPCForCLine", CCTypes.CreateNodeFromRefAny[NEW[PROC[dotOName: Rope.ROPE, cLineNum: CARD, h: Connection] RETURNS[CARD] ← GetRelPCForCLine], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&GetCLineForRelPC", CCTypes.CreateNodeFromRefAny[NEW[PROC[dotOName: Rope.ROPE, relPC: CARD, h: Connection] RETURNS[CARD] ← GetCLineForRelPC], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&DebugOn", CCTypes.CreateNodeFromRefAny[NEW[PROC[] ← DebugOn], cc], cc];
InstallOneAmpersandItem[ampersandContext2, "&&DebugOff", CCTypes.CreateNodeFromRefAny[NEW[PROC[] ← DebugOff], cc], cc];
RETURN[connection]}};