public void AttachToCoreWithEmptyTargetSucceeds() { int calls = 0; SshTarget expectedTarget = null; var attachReason = enum_ATTACH_REASON.ATTACH_REASON_LAUNCH; IDebugSessionLauncher debugSessionLauncher = CreateConfiguredDebugSessionLauncher(expectedTarget, x => { calls++; var attachedProgram = Substitute.For <ILldbAttachedProgram>(); return(Task.FromResult(attachedProgram)); }); IDebugSessionLauncherFactory debugSessionLauncherFactory = CreateDebugSessionLauncherFactory(debugSessionLauncher); IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory); var debugPort = Substitute.For <IDebugPort2>(); debugEngine.LaunchSuspended("", debugPort, _exePath, null, null, null, null, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out IDebugProcess2 _); var rgpPrograms = new[] { Substitute.For <IDebugProgram2>() }; var rgpProgramNodes = new[] { Substitute.For <IDebugProgramNode2>() }; int result = debugEngine.Attach(rgpPrograms, rgpProgramNodes, _celtPrograms, null, attachReason); Assert.Multiple(() => { debugPort.Received().GetProcess(Arg.Any <AD_PROCESS_ID>(), out _); Assert.That(result, Is.EqualTo(VSConstants.S_OK)); Assert.That(calls, Is.EqualTo(1)); }); }
public void AttachNeedsNumProgramsToEqual1([Values] enum_ATTACH_REASON attachReason) { IGgpDebugEngine debugEngine = CreateGgpDebugEngine(); int result = debugEngine.Attach(null, null, 2, null, attachReason); Assert.That(result, Is.EqualTo(VSConstants.E_INVALIDARG)); }
public void AddDebugEngine(IGgpDebugEngine debugEngine) { var entry = new DebugEngineEntry(debugEngine); debugEngines.Add(entry); debugEngine.SessionEnding += OnSessionEnding; Trace.WriteLine($"Added Debug Engine with id={entry.Id}"); }
public void AttachNotImplementedForAutoAttach() { IGgpDebugEngine debugEngine = CreateGgpDebugEngine(); int result = debugEngine.Attach(null, null, _celtPrograms, null, enum_ATTACH_REASON.ATTACH_REASON_AUTO); Assert.That(result, Is.EqualTo(VSConstants.E_NOTIMPL)); }
public void RunLogNatvisStatsWithoutDebugEngine() { // This will cause the debug engine to be purged from debugEngineManager when // the Natvis command calls GetDebugEngines(). debugEngineMock = null; GC.Collect(); Invoke("run logNatvisStats"); Assert.That(commandWindowText, Does.Contain("Failed to find an active debug session")); }
public void LaunchSuspendedWhenBothArgsAndOptionsCoreFilePathEmptyFails( [Values("", null)] string args, [Values("{}", "{\"CoreFilePath\":\"\"}")] string options) { var debugSessionLauncherFactory = Substitute.For <IDebugSessionLauncherFactory>(); IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory); int result = debugEngine.LaunchSuspended("", null, _exePath, args, null, null, options, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out var _); Assert.That(result, Is.EqualTo(VSConstants.E_FAIL)); }
public void LaunchSuspendedWhenOptionsNullAndArgsEmptySucceeds( [Values("", null)] string args) { var debugSessionLauncherFactory = Substitute.For <IDebugSessionLauncherFactory>(); IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory); string options = null; var debugPort = Substitute.For <IDebugPort2>(); int result = debugEngine.LaunchSuspended("", debugPort, _exePath, args, null, null, options, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out var _); Assert.That(result, Is.EqualTo(VSConstants.S_OK)); }
public DebugEngineEntry() { var compRoot = new DebugEngineFactoryCompRoot(); compRoot.GetJoinableTaskContext().ThrowIfNotOnMainThread(); // DebugEngineEntry is the external 'identity' of the debug engine, not the proxy or // inner DebugEngine class. Visual Studio will not work properly if we expose // something other than 'this'. debugEngine = compRoot.CreateDebugEngineFactory().Create(this); debugEngine.SessionEnding += DebugEngine_SessionEnding; debugEngine.SessionEnded += DebugEngine_SessionEnded; var debugEngineManager = compRoot.CreateServiceManager().GetGlobalService( typeof(SDebugEngineManager)) as IDebugEngineManager; debugEngineManager?.AddDebugEngine(this); }
public void LaunchSuspendedWhenEndpointSetSucceeds( [Values(StadiaEndpoint.AnyEndpoint, StadiaEndpoint.PlayerEndpoint, StadiaEndpoint.TestClient)] StadiaEndpoint endpoint) { var debugSessionLauncherFactory = Substitute.For <IDebugSessionLauncherFactory>(); IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory); string options = null; var launchParams = new LaunchParams { Endpoint = endpoint }; string args = Convert.ToBase64String( Encoding.UTF8.GetBytes(new JsonUtil().Serialize(launchParams))); var debugPort = Substitute.For <IDebugPort2>(); int result = debugEngine.LaunchSuspended("", debugPort, _exePath, args, null, null, options, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out var _); Assert.That(result, Is.EqualTo(VSConstants.S_OK)); }
public void AttachToGameletWithUnknownTargetFailsAsUserAbortedOperation() { var gamelet = new Gamelet { IpAddr = "" }; var attachReason = enum_ATTACH_REASON.ATTACH_REASON_USER; IGgpDebugEngine debugEngine = CreateGgpDebugEngine(); debugEngine.LaunchSuspended("", null, "", null, null, null, null, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out IDebugProcess2 _); IDebugPort2 debugPort = CreateDebugPort(gamelet); IDebugProgram2 program = CreateDebugProgram(debugPort); IDebugProgram2[] rgpPrograms = { program }; var rgpProgramNodes = new[] { Substitute.For <IDebugProgramNode2>() }; int result = debugEngine.Attach(rgpPrograms, rgpProgramNodes, _celtPrograms, null, attachReason); Assert.That(result, Is.EqualTo(VSConstants.E_ABORT)); }
public void SetUp() { logSpy = new LogSpy(); logSpy.Attach(); var taskContext = new JoinableTaskContext(); commandWindowText = ""; commandWindowMock = Substitute.For <IVsCommandWindow>(); commandWindowMock.Print(Arg.Do <string>(x => commandWindowText += x)); serviceProviderMock = Substitute.For <IServiceProvider>(); yetiService = new YetiVSIService(null); serviceProviderMock.GetService(typeof(YetiVSIService)).Returns(yetiService); serviceProviderMock.GetService(typeof(SVsCommandWindow)).Returns(commandWindowMock); debugEngineCommandsMock = Substitute.For <IDebugEngineCommands>(); // (internal): This needs to be a member variable since debugEngineManager tracks it // by weak reference only!. debugEngineMock = Substitute.For <IGgpDebugEngine>(); debugEngineMock.DebugEngineCommands.Returns(debugEngineCommandsMock); debugEngineManager = new DebugEngineManager(); debugEngineManager.AddDebugEngine(debugEngineMock); serviceProviderMock.GetService(typeof(SDebugEngineManager)) .Returns(debugEngineManager); menuCommandService = new OleMenuCommandService(serviceProviderMock); serviceProviderMock.GetService(typeof(IMenuCommandService)) .Returns(menuCommandService); DebuggerOptionsCommand.Register(taskContext, serviceProviderMock); }
public void RemoteDeployNotCalledDuringAttachToCore(enum_ATTACH_REASON attachReason) { var gamelet = new Gamelet { IpAddr = _gameletIp }; var expectedTarget = new SshTarget(gamelet); IDebugSessionLauncher debugSessionLauncher = CreateConfiguredDebugSessionLauncher(expectedTarget, x => { var attachedProgram = Substitute.For <ILldbAttachedProgram>(); return(Task.FromResult(attachedProgram)); }); IDebugSessionLauncherFactory debugSessionLauncherFactory = CreateDebugSessionLauncherFactory(debugSessionLauncher); int calls = 0; var remoteDeploy = Substitute.For <IRemoteDeploy>(); remoteDeploy.DeployLldbServerAsync(expectedTarget, Arg.Any <IAction>()).Returns(x => { calls++; return(Task.CompletedTask); }); IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory, remoteDeploy); IDebugPort2 debugPort = CreateDebugPort(gamelet); string options = null; debugEngine.LaunchSuspended("", debugPort, _exePath, null, null, null, options, enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null, out IDebugProcess2 _); IDebugProgram2 program = CreateDebugProgram(debugPort); IDebugProgram2[] rgpPrograms = { program }; var rgpProgramNodes = new[] { Substitute.For <IDebugProgramNode2>() }; debugEngine.Attach(rgpPrograms, rgpProgramNodes, _celtPrograms, null, attachReason); Assert.That(calls, Is.EqualTo(0)); }
public DebugEngineEntry(IGgpDebugEngine debugEngine) { debugEngineRef = new WeakReference <IGgpDebugEngine>(debugEngine, false); Id = debugEngine.Id; }