<<>> <> <> <> <> <> <> <> <> <> <> DIRECTORY Buttons USING [Button, ButtonProc, Create], CCTypes USING[CCError, CCErrorCase], CirioButtons USING[ButtonSet, ButtonSize, ChoiceList, CreateButtonSet, CreateViewer, GetButtonSize, InstallCommandButton, InstallLabelButton, InstallSourceLanguageButton, InstallRule, InstallShowFrameButton, InstallSourcePositionButton, InstallWalkStackButton, KillButtonSet, MainActionProc, MoveToX, MoveToY, NewLine, SkipX, ViewerControl], CirioTypes USING[CompilerContext], Commander USING[CommandProc, Register], CommanderOps USING[ParseToList], Containers USING[ChildXBound, Create], Convert USING[CardFromRope, Error, RopeFromAtom, RopeFromCard], DisassembleSPARC, FileNames USING[CurrentWorkingDirectory], IO USING[PutF, PutF1, PutRope, rope, STREAM], Labels USING [Set], NetworkName USING[AddressFromName, Error], Process USING[Detach], RemoteCirio USING[AbortThread, AddSearchDirectory, CloseConnection, Connection, DbxExamineThread, DestroyRemoteWorld, FindThreadsWithProperty, FlushUnknownFileCache, FocusOnThread, FreezeThread, GetDummyStack, GetStackForCurrentThread, GetThreadTitleText, InstallBreakCheckDaemon, KillThread, ListSearchDirectory, OpenConnection, ProceedThread, ResumeRemoteWorld, ResumeRemoteWorldWithOnlyVP0, ShowQuickSummary, StopBreakCheckDaemon, StopRemoteWorld, ThreadIDFromIndex], Rope USING[Cat, Concat, Equal, Find, Length, ROPE], SourceFileOpsExtras USING [FullFormatPosition, FullGetSelection, FullOpenSource, noPosition, Position], SystemNames USING[MachineName], StackCirio USING[ClearAllBreakPoints, ClearBreakPoint, Disassemble, FormatPrompt, InterpretTextLine, ListBreakPoints, ResetStack, SetBreakPointAtAddress, SetBreakPointAtPosition, Stack], Termination USING[CallBeforeQuitWorld], TiogaOps USING[FindText, FindWord, SearchDir], WindowSystemInterface USING[GetSelectionContents], ViewerClasses USING[MouseButton, Viewer], ViewerOps USING[BlinkViewer, PaintViewer]; RemoteDriver3: CEDAR MONITOR LOCKS d USING d: MyViewerData IMPORTS Buttons, CCTypes, CirioButtons, Commander, CommanderOps, Containers, Convert, DisassembleSPARC, FileNames, IO, Labels, NetworkName, Process, RemoteCirio, Rope, SourceFileOpsExtras, StackCirio, SystemNames, Termination, TiogaOps, WindowSystemInterface, ViewerOps = BEGIN ROPE: TYPE ~ Rope.ROPE; CC: TYPE = CirioTypes.CompilerContext; CCE: ERROR[case: CCTypes.CCErrorCase, msg: Rope.ROPE ¬ NIL] ¬ CCTypes.CCError; <> <> MyViewerData: TYPE = REF MyViewerDataBody; MyViewerDataBody: TYPE = MONITORED RECORD[ vc: CirioButtons.ViewerControl ¬ NIL, connection: RemoteCirio.Connection, dummyStack: StackCirio.Stack, serverName: ROPE, portNum: CARD, threadsInfo: REF ThreadsInfo, remoteWorldGone: BOOLEAN ¬ FALSE, runningFlag: BOOLEAN ¬ TRUE, runningLabel: ViewerClasses.Viewer, stopAllFlag: BOOLEAN ¬ FALSE, stopAllLabel: ViewerClasses.Viewer, dbxFlag: BOOLEAN ¬ FALSE, lineH: CARD ¬ 0, worldControlY: INTEGER ¬ 0, worldControlH: INTEGER ¬ 0, worldControlButtonSet: CirioButtons.ButtonSet, threadControlY: INTEGER ¬ 0, threadControlH: INTEGER ¬ 0, threadControlButtonSet: CirioButtons.ButtonSet, threadListControlButtonsInstalled: BOOL ¬ FALSE, rule1Y: INTEGER ¬ 0, threadButtonsY: INTEGER ¬ 0, threadButtonsH: INTEGER ¬ 0, threadButtonsButtonSet: CirioButtons.ButtonSet, activeThread: REF ThreadButtonInfo ¬ NIL, activeThreadRemoteIndex: CARD, currentStack: StackCirio.Stack, rule2Y: INTEGER ¬ 0, stopFlag: REF BOOLEAN ¬ NIL, generalButtonsY: INTEGER ¬ 0, generalButtonsH: INTEGER ¬ 0, generalButtonsButtonSet: CirioButtons.ButtonSet, stackButtonsY: INTEGER ¬ 0, stackButtonsH: INTEGER ¬ 0, stackButtonsButtonSet: CirioButtons.ButtonSet, frameLabel: ViewerClasses.Viewer, rule3Y: INTEGER ¬ 0, findButtonsY: INTEGER ¬ 0, findButtonsH: INTEGER ¬ 0, findButton: ViewerClasses.Viewer, wordButton: ViewerClasses.Viewer, <> rule4Y: INTEGER ¬ 0, scriptY: INTEGER ¬ 0 ]; ThreadsInfo: TYPE = RECORD[SEQUENCE nThreads: CARDINAL OF REF ThreadButtonInfo]; ThreadButtonInfo: TYPE = RECORD[d: MyViewerData, index: CARD, visible: BOOLEAN, label: ViewerClasses.Viewer]; toolIDInfo: TYPE ~ RECORD [ valid: BOOL ¬ FALSE, localPort: CARD ¬ 0, localName: Rope.ROPE ¬ NIL, localHostIP: Rope.ROPE ¬ NIL ]; thisTool: toolIDInfo ¬ []; GetPortNum: PROC RETURNS[CARD] = TRUSTED MACHINE CODE {"CirioNubLocalGetPort"}; Driver: Commander.CommandProc = { d: MyViewerData ¬ NEW[MyViewerDataBody]; args: LIST OF ROPE; numArgs: NAT; serverName: ROPE; serverNameIP: ROPE; portNum: CARDINAL; wDirs: LIST OF ROPE ¬ NIL; lastWDir: LIST OF ROPE ¬ NIL; cDir: LIST OF ROPE ¬ LIST[FileNames.CurrentWorkingDirectory[]]; [args, numArgs] ¬ CommanderOps.ParseToList[cmd]; { ENABLE { Convert.Error => {GOTO usage}; NetworkName.Error => { errRope: Rope.ROPE ¬ NIL; IO.PutF[cmd.out, "\nProblem(s) occured while looking up host %g (%g", [rope[serverName]], [rope[msg]]]; FOR problems: LIST OF ATOM ¬ codes, problems.rest WHILE problems # NIL DO errRope ¬ Convert.RopeFromAtom[problems.first, FALSE]; IO.PutF1[cmd.out, ", %g", [rope[errRope]]]; ENDLOOP; IO.PutRope[cmd.out, ")\nPlease verify the correct and and try again.\n\n"]; GOTO done; }; }; IF numArgs<1 THEN GOTO usage; serverName ¬ args.first; serverNameIP ¬ NetworkName.AddressFromName[family: $ARPA, name: serverName, portHint: NIL, components: host].addr; portNum ¬ IF numArgs < 2 THEN 4815 ELSE CARDINAL[Convert.CardFromRope[args.rest.first]]; EXITS usage => RETURN [$Failure, "Usage: CirioRemote [ []]"]; done => RETURN; }; <> wDirs ¬ IF numArgs < 3 THEN NIL ELSE args.rest.rest; IF wDirs # NIL THEN { FOR thisDir: LIST OF ROPE ¬ wDirs, thisDir.rest WHILE thisDir # NIL DO lastWDir ¬ thisDir; ENDLOOP; lastWDir.rest ¬ cDir; } ELSE { wDirs ¬ cDir; }; <> { localhost: Rope.ROPE ¬ "localhost"; <> anonMachine: Rope.ROPE ¬ "AnonymousMachine"; IF NOT thisTool.valid THEN { thisTool.localPort ¬ GetPortNum[]; thisTool.localName ¬ SystemNames.MachineName[]; IF (Rope.Equal[thisTool.localName, anonMachine]) THEN { thisTool.localName ¬ localhost; IO.PutRope[cmd.out, "\nSystemNames.MachineName reports AnonymousMachine. Using localhost instead.\n\n"]; }; thisTool.localHostIP ¬ NetworkName.AddressFromName[family: $ARPA, name: thisTool.localName, portHint: NIL, components: host].addr; thisTool.valid ¬ TRUE; }; IF (portNum = thisTool.localPort AND (Rope.Equal[thisTool.localHostIP, serverNameIP] OR Rope.Equal[localhost, serverName])) THEN { IO.PutF[cmd.out, "\nYou are attempting to connect Cirio to itself.\nPlease verify the correct and and try again.\n\n"]; RETURN; }; }; d.lineH ¬ CirioButtons.GetButtonSize["Sample"].h+1; d.worldControlY ¬ 1; d.worldControlH ¬ d.lineH; d.threadControlY ¬ d.worldControlY+d.worldControlH; d.threadControlH ¬ 2*d.lineH; d.rule1Y ¬ d.threadControlY+d.threadControlH; d.threadButtonsY ¬ d.rule1Y+2; d.threadButtonsH ¬ 6*d.lineH; d.rule2Y ¬ d.threadButtonsY+d.threadButtonsH+1; d.generalButtonsY ¬ d.rule2Y+1; d.generalButtonsH ¬ d.lineH; d.stackButtonsY ¬ d.generalButtonsY+d.generalButtonsH+1; d.stackButtonsH ¬ d.lineH; d.rule3Y ¬ d.stackButtonsY+d.stackButtonsH+1; d.findButtonsY ¬ d.stackButtonsY + d.generalButtonsH + 1; d.findButtonsH ¬ d.lineH; d.rule4Y ¬ d.findButtonsY+d.findButtonsH+1; d.scriptY ¬ d.rule4Y+1; d.vc ¬ CirioButtons.CreateViewer[Rope.Cat["Cirio remote ", serverName, " (", Convert.RopeFromCard[portNum], ")"], d.scriptY, FormatPrompt, InterpretTextLine, ShutDown, d]; d.connection ¬ RemoteCirio.OpenConnection[serverName, portNum, wDirs, d.vc.out]; IF d.connection=NIL THEN { TRUSTED{Process.Detach[FORK CirioButtons.MainActionProc[d.vc]]}; --so delete works RETURN [$Failure, "Debugging session abandoned because couldn't open connection"]}; <> BEGIN ENABLE UNWIND => {CleanupConnection[d]}; Termination.CallBeforeQuitWorld[CleanupConnection, d]; RemoteCirio.InstallBreakCheckDaemon[d.connection, d.vc.out]; d.dummyStack ¬ RemoteCirio.GetDummyStack[d.connection, d.vc.out]; d.serverName ¬ serverName; d.portNum ¬ portNum; d.stopFlag ¬ NEW[BOOLEAN¬FALSE]; InstallRules[d]; InstallWorldControlButtons[d]; InstallFindButtons[d]; TRUSTED{Process.Detach[FORK CirioButtons.MainActionProc[d.vc]]}; SetThreadControlToRunning[d]; END; RETURN}; <> <<>> CleanupConnection: PROC [x: REF] = { d: MyViewerData ¬ NARROW[x]; IF d # NIL AND d.vc.self # NIL THEN RemoteCirio.CloseConnection[d.connection, d.vc.out]; }; <> <<>> FormatPrompt: PROC [counter: INT, clientData: REF ANY] RETURNS [ROPE] ~ { d: MyViewerData ¬ NARROW[clientData]; stack: StackCirio.Stack ¬ IF d.currentStack # NIL THEN d.currentStack ELSE d.dummyStack; IF d.connection=NIL THEN RETURN["broken!"]; RETURN StackCirio.FormatPrompt[stack, counter]}; InterpretTextLine: PROC[line: ROPE, reports: IO.STREAM, clientData: REF ANY] RETURNS[ROPE] = { d: MyViewerData ¬ NARROW[clientData]; stack: StackCirio.Stack ¬ IF d.currentStack # NIL THEN d.currentStack ELSE d.dummyStack; IF d.connection=NIL THEN RETURN["I'm broken, you fool"]; RETURN[StackCirio.InterpretTextLine[stack, line, reports]]; }; <<>> <> InstallFindButtons: PROC[d: MyViewerData] = BEGIN d.findButton ¬ Buttons.Create[info: [wx: 0, wy: d.findButtonsY + 1, ww: 50, wh: d.findButtonsH, name: "Find", parent: d.vc.self, border: FALSE], proc: FindAction, clientData: d.vc.script]; d.wordButton ¬ Buttons.Create[info: [wx: 50, wy: d.findButtonsY + 1, ww: 50, wh: d.findButtonsH, name: "Word", parent: d.vc.self, border: FALSE], proc: WordAction, clientData: d.vc.script]; END; <> <> <> <<[] _ CirioButtons.InstallCommandButton[bs: findButtonSet, name: "Find", clientData1: d.vc, choices: LIST[[$Forward], [$Anywhere], [$Backward]], proc2: FindAction];>> <<[] _ CirioButtons.InstallCommandButton[bs: findButtonSet, name: "Word", clientData1: d.vc, choices: LIST[[$Forward], [$Anywhere], [$Backward]], proc2: FindAction];>> <> <<>> FindAction: Buttons.ButtonProc ~ { script: ViewerClasses.Viewer ¬ NARROW[clientData]; IF ~TiogaOps.FindText[viewer: script, rope: NIL, whichDir: DirFromClick[mouseButton], which: primary, case: ~shift] THEN ViewerOps.BlinkViewer[script, 300]; }; WordAction: Buttons.ButtonProc ~ { script: ViewerClasses.Viewer ¬ NARROW[clientData]; IF ~TiogaOps.FindWord[viewer: script, rope: NIL, whichDir: DirFromClick[mouseButton], which: primary, case: ~shift] THEN ViewerOps.BlinkViewer[script, 300]; }; <> <> <> <> <> <> <<};>> <<>> <> <> <> <> <> <> <<};>> <<>> <> <