public static ExitInfo Excute(string fileName, string arguments, string workingDirectory) { ProcessStartInfo processStartInfo = new ProcessStartInfo(); //指定启动文件名 processStartInfo.FileName = fileName; //指定启动该文件时的命令、参数 processStartInfo.Arguments = arguments; //指定启动窗口模式:隐藏 processStartInfo.WindowStyle = ProcessWindowStyle.Hidden; //指定压缩后到达路径 processStartInfo.WorkingDirectory = workingDirectory; ExitInfo exitInfo = new ExitInfo(); //创建进程对象 Process process = new Process(); //指定进程对象启动信息对象 process.StartInfo = processStartInfo; //启动进程 process.Start(); //指定进程自行退行为止 process.WaitForExit(); exitInfo.Error = process.StandardError.ReadToEnd(); exitInfo.ExitCode = process.ExitCode; exitInfo.Result = process.StandardOutput.ReadToEnd(); return(exitInfo); }
protected override Exit SelectExit(Actor self, ActorInfo producee, string productionType, Func <Exit, bool> p) { var mobileInfo = producee.TraitInfoOrDefault <MobileInfo>(); var exit = base.SelectExit(self, producee, productionType, null); var spawn = self.World.Map.CellContaining(self.CenterPosition + exit.Info.SpawnOffset); for (var y = 1; y <= info.MaximumDistance; y++) { for (var x = -y; x <= y; x++) { var candidate = new CVec(x, y); if (!mobileInfo.CanEnterCell(self.World, self, spawn + candidate, self)) { continue; } var exitInfo = new ExitInfo(); exitInfo.GetType().GetField("SpawnOffset").SetValue(exitInfo, exit.Info.SpawnOffset); exitInfo.GetType().GetField("ExitCell").SetValue(exitInfo, spawn - self.Location + candidate); exitInfo.GetType().GetField("Facing").SetValue(exitInfo, exit.Info.Facing); return(new Exit(null, exitInfo)); } } return(null); }
private void RoomCheck(GameObject Room, Transform Exit) { bool Check = ColliderCheck(Room); if (Check) {//Good room _rooms.Enqueue(Room); Room.transform.parent = _levelMap; Room.transform.name = _roomCount.ToString(); ExitInfo EI = _joinedExit.GetComponent <ExitInfo>(); EI.SetExit(true); EI.ConnectExit(Exit); EI.ExitUpdate(); Exit.GetComponent <ExitInfo>().ConnectExit(_joinedExit); Exit.GetComponent <ExitInfo>().ExitUpdate(); _roomCount++; } else {//Invalid Exit Close and move on Debug.Log("Invalid Exit Close and move on"); Room.transform.position = _grave.position; Room.transform.parent = _grave; Exit.GetComponent <ExitInfo>().SetExit(false); ManageRoomChildren(Room, false); Room.GetComponent <BoxCollider>().enabled = false; Destroy(Room.gameObject); } }
public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string raceVariant) { var exit = self.Location + exitinfo.ExitCell; var spawn = self.CenterPosition + exitinfo.SpawnOffset; var to = self.World.Map.CenterOfCell(exit); var fi = producee.Traits.GetOrDefault<IFacingInfo>(); var initialFacing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, fi == null ? 0 : fi.GetInitialFacing()) : exitinfo.Facing; var exitLocation = rp.Value != null ? rp.Value.Location : exit; var target = Target.FromCell(self.World, exitLocation); var bi = producee.Traits.GetOrDefault<BuildableInfo>(); if (bi != null && bi.ForceRace != null) raceVariant = bi.ForceRace; self.World.AddFrameEndTask(w => { var td = new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(exit), new CenterPositionInit(spawn), new FacingInit(initialFacing) }; if (raceVariant != null) td.Add(new RaceInit(raceVariant)); var newUnit = self.World.CreateActor(producee.Name, td); var move = newUnit.TraitOrDefault<IMove>(); if (move != null) { if (exitinfo.MoveIntoWorld) { if (exitinfo.ExitDelay > 0) newUnit.QueueActivity(new Wait(exitinfo.ExitDelay)); newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); newUnit.QueueActivity(new AttackMoveActivity( newUnit, move.MoveTo(exitLocation, 1))); } } newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false); if (!self.IsDead) foreach (var t in self.TraitsImplementing<INotifyProduction>()) t.UnitProduced(self, newUnit, exit); var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>(); foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit); foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>()) t.BuildingComplete(newUnit); }); }
public void IfErrorWhenError() { var expected = new Exception(); var ei = ExitInfo.Error(expected); Exception actual = null; ei.IfError(e => actual = e); Assert.AreEqual(expected, actual); }
public RallyPointIndicator(Actor building, RallyPoint rp, ExitInfo[] exits) { this.building = building; this.rp = rp; this.exits = exits; flag = new Animation(building.World, rp.Info.Image); flag.PlayRepeating(rp.Info.FlagSequence); circles = new Animation(building.World, rp.Info.Image); circles.Play(rp.Info.CirclesSequence); }
public void HandleResultWhenNormal(ExitReason expected) { var ei = ExitInfo.Normal(expected); ExitReason?actual = null; Exception error = null; ei.HandleResult( onNormal: r => actual = r, onError: ex => error = ex);; Assert.AreEqual(expected, actual); Assert.IsNull(error); }
public void IfErrorWhenNormal() { var ei = ExitInfo.Normal(ExitReason.Unknown); var isCalled = false; Action <Exception> a = ex => { isCalled = true; }; ei.IfError(a); Assert.IsFalse(isCalled); }
public void HandleResultWhenError() { var expected = new Exception(); var ei = ExitInfo.Error(expected); Exception actual = null; var normalCalled = false; ei.HandleResult( onNormal: _ => normalCalled = true, onError: e => actual = e); Assert.AreEqual(expected, actual); Assert.IsFalse(normalCalled); }
public int Detach() { DetachRequested = true; if (!_lldbProcess.Detach()) { DetachRequested = false; return(VSConstants.E_FAIL); } // Send the ProgramDestroyEvent immediately, so that Visual Studio can't cause a // deadlock by waiting for the event while preventing us from accessing the main thread. // TODO: Block and wait for LldbEventHandler to send the event _debugEngineHandler.Abort(this, ExitInfo.Normal(ExitReason.DebuggerDetached)); return(VSConstants.S_OK); }
public void AbortSendsProgramDestroyEvent(ExitReason exitReason) { ProgramDestroyEvent destroyEvent = null; debugEngineHandler.SendEvent( Arg.Do <DebugEvent>(e => destroyEvent = e as ProgramDestroyEvent), Arg.Any <IGgpDebugProgram>(), Arg.Any <IDebugThread2>()) .Returns(VSConstants.S_OK); debugEngineHandler.Abort(program, ExitInfo.Normal(exitReason)); debugEngineHandler.Received(1).SendEvent( Arg.Is <DebugEvent>(e => e is ProgramDestroyEvent), program, (IDebugThread2)null); destroyEvent.ExitInfo.HandleResult( r => Assert.That(r, Is.EqualTo(exitReason)), ex => Assert.Fail("Unexpected error: " + ex.ToString())); }
protected void SetSpawnedFacing(Actor spawned, Actor spawner, ExitInfo exit) { int facingOffset = facing == null ? 0 : facing.Facing; var exitFacing = exit != null ? exit.Facing : 0; var spawnFacing = spawned.TraitOrDefault <IFacing>(); if (spawnFacing != null) { spawnFacing.Facing = (facingOffset + exitFacing) % 256; } foreach (var t in spawned.TraitsImplementing <Turreted>()) { t.TurretFacing = (facingOffset + exitFacing) % 256; } }
private void OpenRoomExits(GameObject Room) {//Scan through Current Room's Exits to determine if they will be Used Debug.Log("Random Exits for " + Room); _currentRoomScript = Room.GetComponent <RoomInfo>(); for (int i = 0; i < _currentRoomScript.Exits.Length; i++) { ExitInfo ExitInfo = _currentRoomScript.Exits[i].gameObject.GetComponent <ExitInfo>(); int RND = Random.Range(0, 100); if (!ExitInfo.ExitState() && RND <= _exitChance) { if (ExitCheck(_currentRoomScript.Exits[i])) { ExitInfo.SetExit(true); _exits.Enqueue(_currentRoomScript.Exits[i]); } } } }
public int Terminate() { TerminationRequested = true; //TODO: remove the legacy launch flow. if (!_lldbProcess.Kill()) { // Visual Studio waits for the ProgramDestroyEvent regardless of whether // Terminate() succeeds, so we send the event on failure as well as on success. _debugEngineHandler.Abort( this, ExitInfo.Error(new TerminateProcessException(ErrorStrings.FailedToStopGame))); return(VSConstants.E_FAIL); } // Send the ProgramDestroyEvent immediately, so that Visual Studio can't cause a // deadlock by waiting for the event while preventing us from accessing the main thread. // TODO: Block and wait for LldbEventHandler to send the event _debugEngineHandler.Abort(this, ExitInfo.Normal(ExitReason.DebuggerTerminated)); return(VSConstants.S_OK); }
protected async Task setGetOut(int venue_uid) { ExitInfo nwexit = new ExitInfo(); nwexit.usr_id = Preferences.Get("customer_id", 0); nwexit.vnu_uid = venue_uid; DateTime now = DateTime.Now.ToLocalTime(); string currentTime = (string.Format("{0}", now)); nwexit.ext_time = currentTime.Substring(9, 9); var newExitJSONString = JsonConvert.SerializeObject(nwexit); var content = new StringContent(newExitJSONString, Encoding.UTF8, "application/json"); var request = new HttpRequestMessage(); request.RequestUri = new Uri("https://61vdohhos4.execute-api.us-west-1.amazonaws.com/dev/api/v2/get_out"); request.Method = HttpMethod.Put; request.Content = content; var client = new HttpClient(); HttpResponseMessage response = await client.SendAsync(request); }
/// <summary> /// Called to abort the debug engine. /// </summary> public static void Abort(this IDebugEngineHandler handler, IGgpDebugProgram program, ExitInfo exitInfo) => handler.SendEvent(new ProgramDestroyEvent(exitInfo), program);
public ILldbAttachedProgram Create( IDebugProcess2 debugProcess, Guid programId, IDebugEngine2 debugEngine, IDebugEventCallback2 callback, SbDebugger debugger, RemoteTarget target, LldbListenerSubscriber listenerSubscriber, SbProcess process, SbCommandInterpreter commandInterpreter, bool isCoreAttach, IExceptionManager exceptionManager, IModuleSearchLogHolder moduleSearchLogHolder, uint remotePid) { // Required due to an issue triggered by the proxy used to wrap debugProgramFactory. // TODO: Remove assertion once the issue with Castle.DynamicProxy is // fixed. _taskContext.ThrowIfNotOnMainThread(); var debugEngineHandler = _debugEngineHandlerFactory.Create(debugEngine, callback); var binaryLoader = _binaryLoaderFactory.Create(target); var symbolLoader = _symbolLoaderFactory.Create(commandInterpreter); var moduleFileLoader = _moduleFileLoaderFactory.Create(symbolLoader, binaryLoader, moduleSearchLogHolder); var debugModuleCache = _debugModuleCacheFactory.Create( (lldbModule, loadOrder, ggpProgram) => _debugModuleFactory.Create( moduleFileLoader, moduleSearchLogHolder, lldbModule, loadOrder, debugEngineHandler, ggpProgram)); var ad7FrameInfoCreator = new AD7FrameInfoCreator(debugModuleCache); var stackFrameCreator = new StackFramesProvider.StackFrameCreator( (frame, thread, program) => _debugStackFrameCreator( ad7FrameInfoCreator, frame, thread, debugEngineHandler, program)); var threadCreator = new DebugProgram.ThreadCreator( (thread, program) => _debugThreadCreatorDelegate( ad7FrameInfoCreator, stackFrameCreator, thread, program)); var debugProgram = _debugProgramFactory.Create( debugEngineHandler, threadCreator, debugProcess, programId, process, target, debugModuleCache, isCoreAttach); _taskExecutor.StartAsyncTasks( ex => debugEngineHandler.Abort(debugProgram, ExitInfo.Error(ex))); var breakpointManager = _breakpointManagerFactory.Create(debugEngineHandler, debugProgram); var eventManager = _eventManagerFactory.Create(debugEngineHandler, breakpointManager, debugProgram, process, listenerSubscriber); // TODO: Listen for module load/unload events from LLDB binaryLoader.LldbModuleReplaced += (o, args) => { debugModuleCache.GetOrCreate(args.AddedModule, debugProgram); debugModuleCache.Remove(args.RemovedModule); }; debugModuleCache.ModuleAdded += (o, args) => debugEngineHandler.OnModuleLoad(args.Module, debugProgram); debugModuleCache.ModuleRemoved += (o, args) => debugEngineHandler.OnModuleUnload(args.Module, debugProgram); return(new LldbAttachedProgram(breakpointManager, eventManager, _lldbShell, moduleFileLoader, debugEngineHandler, _taskExecutor, debugProgram, debugger, target, process, exceptionManager, debugModuleCache, listenerSubscriber, remotePid)); }
void LldbListenerOnExceptionOccured(object sender, ExceptionOccuredEventArgs e) { Trace.WriteLine("Exception in listener: " + e); _debugEngineHandler.Abort(_program, ExitInfo.Error(e.Exception)); }
public void SpawnDeliveryVehicle(Actor self, ActorInfo actorInfo, ExitInfo exitInfo, Actor returning) { var exit = CPos.Zero; var exitLocations = new List <CPos>(); var td = new TypeDictionary(); if (exitInfo != null && self.OccupiesSpace != null && actorInfo.HasTraitInfo <IOccupySpaceInfo>()) { exit = self.Location + exitInfo.ExitCell; var spawn = self.CenterPosition + exitInfo.SpawnOffset; var to = self.World.Map.CenterOfCell(exit); WAngle initialFacing; if (!exitInfo.Facing.HasValue) { var delta = to - spawn; if (delta.HorizontalLengthSquared == 0) { var fi = actorInfo.TraitInfoOrDefault <IFacingInfo>(); initialFacing = fi != null?fi.GetInitialFacing() : WAngle.Zero; } else { initialFacing = delta.Yaw; } } else { initialFacing = exitInfo.Facing.Value; } exitLocations = rallyPoint.Value != null && rallyPoint.Value.Path.Count > 0 ? rallyPoint.Value.Path : new List <CPos> { exit }; td.Add(new LocationInit(exit)); td.Add(new CenterPositionInit(spawn)); td.Add(new FacingInit(initialFacing)); td.Add(new OwnerInit(self.Owner)); if (exitInfo != null) { td.Add(new CreationActivityDelayInit(exitInfo.ExitDelay)); } } self.World.AddFrameEndTask(w => { var deliveryVehicle = self.World.CreateActor(actorInfo.Name, td); deliveryVehicle.Trait <ResourceTransporter>().LinkedCollector = returning; var move = deliveryVehicle.TraitOrDefault <IMove>(); if (exitInfo != null && move != null) { foreach (var cell in exitLocations) { deliveryVehicle.QueueActivity(new Move(deliveryVehicle, cell)); } } }); }
/// <summary> /// Abort tells the SDM to stop debugging. /// </summary> public void Abort(ExitInfo exitInfo) => _debugEngineHandler.Abort(_debugProgram, exitInfo);
public override void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant, TypeDictionary init) { var exit = CPos.Zero; var exitLocation = CPos.Zero; var target = Target.Invalid; Actor respawner = self; var bi = producee.TraitInfoOrDefault <BuildableInfo>(); if (bi != null && bi.ForceFaction != null) { factionVariant = bi.ForceFaction; } var td = new TypeDictionary { new OwnerInit(self.Owner), }; if (self.OccupiesSpace != null) { exit = self.Location + exitinfo.ExitCell; var spawn = self.CenterPosition + exitinfo.SpawnOffset; var to = self.World.Map.CenterOfCell(exit); if (producee.HasTraitInfo <IPositionableInfo>()) { var cell = Util.RandomWalk(self.Location, self.World.SharedRandom) .Take(2) .SkipWhile(p => !producee.TraitInfo <IPositionableInfo>().CanEnterCell(self.World, self, p)) .Cast <CPos?>().FirstOrDefault(); if (cell != null) { spawn = self.World.Map.CenterOfCell(cell.Value); } } else if (producee.HasTraitInfo <MobileInfo>()) { var cell = Util.RandomWalk(self.Location, self.World.SharedRandom) .Take(2) .SkipWhile(p => !producee.TraitInfo <MobileInfo>().CanEnterCell(self.World, self, p)) .Cast <CPos?>().FirstOrDefault(); if (cell != null) { spawn = self.World.Map.CenterOfCell(cell.Value); } } var initialFacing = exitinfo.Facing; if (exitinfo.Facing < 0) { var delta = to - spawn; if (delta.HorizontalLengthSquared == 0) { var fi = producee.TraitInfoOrDefault <IFacingInfo>(); initialFacing = fi != null?fi.GetInitialFacing() : 0; } else { initialFacing = delta.Yaw.Facing; } } exitLocation = rp.Value != null ? rp.Value.Location : exit; respawner = self; var validreplacespawner = self.World.ActorsHavingTrait <UndeadGiantSpawner>() .Where(a => { return(a.Owner == self.Owner && a.TraitOrDefault <UndeadGiantSpawner>().Canspawn); }); if (validreplacespawner.Any()) { respawner = validreplacespawner.Random(self.World.SharedRandom); exit = respawner.Location + new CVec(respawner.Info.TraitInfo <UndeadGiantSpawnerInfo>().Exit.X, respawner.Info.TraitInfo <UndeadGiantSpawnerInfo>().Exit.Y); spawn = respawner.CenterPosition + new WVec(respawner.Info.TraitInfo <UndeadGiantSpawnerInfo>() .SpawnOffset.X, respawner.Info.TraitInfo <UndeadGiantSpawnerInfo>().SpawnOffset.Y, respawner.Info.TraitInfo <UndeadGiantSpawnerInfo>().SpawnOffset.Z); exitLocation = respawner.TraitOrDefault <RallyPoint>().Location; } td.Add(new LocationInit(exit)); td.Add(new CenterPositionInit(spawn)); td.Add(new FacingInit(initialFacing)); if (factionVariant != null) { td.Add(new FactionInit(factionVariant)); } } target = Target.FromCell(self.World, exitLocation); self.World.AddFrameEndTask(w => { var newUnit = self.World.CreateActor(producee.Name, td); if (newUnit.Info.HasTraitInfo <WithMakeAnimationInfo>() && respawner == self) { var move = newUnit.TraitOrDefault <IMove>(); if (move != null) { if (exitinfo.MoveIntoWorld) { if (exitinfo.ExitDelay > 0) { newUnit.QueueActivity(new Wait(exitinfo.ExitDelay, false)); } newUnit.Trait <WithMakeAnimation>().Forward(newUnit, () => { newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); newUnit.QueueActivity(new AttackMoveActivity( newUnit, move.MoveTo(exitLocation, 1))); newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false); if (!self.IsDead) { foreach (var t in self.TraitsImplementing <INotifyProduction>()) { t.UnitProduced(self, newUnit, exit); } } var notifyOthers = self.World.ActorsWithTrait <INotifyOtherProduction>(); foreach (var notify in notifyOthers) { notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, producee.Name); } foreach (var t in newUnit.TraitsImplementing <INotifyBuildComplete>()) { t.BuildingComplete(newUnit); } }); } } } else if (respawner == self) { var move = newUnit.TraitOrDefault <IMove>(); if (move != null) { if (exitinfo.MoveIntoWorld) { if (exitinfo.ExitDelay > 0) { newUnit.QueueActivity(new Wait(exitinfo.ExitDelay, false)); } newUnit.Trait <WithMakeAnimation>().Forward(newUnit, () => { newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); newUnit.QueueActivity(new AttackMoveActivity( newUnit, move.MoveTo(exitLocation, 1))); }); } } newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false); if (!self.IsDead) { foreach (var t in self.TraitsImplementing <INotifyProduction>()) { t.UnitProduced(self, newUnit, exit); } } var notifyOthers = self.World.ActorsWithTrait <INotifyOtherProduction>(); foreach (var notify in notifyOthers) { notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, producee.Name); } foreach (var t in newUnit.TraitsImplementing <INotifyBuildComplete>()) { t.BuildingComplete(newUnit); } } else { var move = newUnit.TraitOrDefault <IMove>(); newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); newUnit.QueueActivity(new AttackMoveActivity( newUnit, move.MoveTo(exitLocation, 1))); newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false); if (!self.IsDead) { foreach (var t in self.TraitsImplementing <INotifyProduction>()) { t.UnitProduced(self, newUnit, exit); } } var notifyOthers = self.World.ActorsWithTrait <INotifyOtherProduction>(); foreach (var notify in notifyOthers) { notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, producee.Name); } foreach (var t in newUnit.TraitsImplementing <INotifyBuildComplete>()) { t.BuildingComplete(newUnit); } respawner.TraitOrDefault <UndeadGiantSpawner>().Reset(); } }); }
static bool CanUseExit(Actor self, ActorInfo producee, ExitInfo s) { var mobileInfo = producee.TraitInfoOrDefault<MobileInfo>(); self.NotifyBlocker(self.Location + s.ExitCell); return mobileInfo == null || mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, self); }
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant) { var exit = CPos.Zero; var exitLocation = CPos.Zero; var target = Target.Invalid; var bi = producee.TraitInfoOrDefault<BuildableInfo>(); if (bi != null && bi.ForceFaction != null) factionVariant = bi.ForceFaction; var td = new TypeDictionary { new OwnerInit(self.Owner), }; if (self.OccupiesSpace != null) { exit = self.Location + exitinfo.ExitCell; var spawn = self.CenterPosition + exitinfo.SpawnOffset; var to = self.World.Map.CenterOfCell(exit); var initialFacing = exitinfo.Facing; if (exitinfo.Facing < 0) { var delta = to - spawn; if (delta.HorizontalLengthSquared == 0) { var fi = producee.TraitInfoOrDefault<IFacingInfo>(); initialFacing = fi != null ? fi.GetInitialFacing() : 0; } else initialFacing = delta.Yaw.Facing; } exitLocation = rp.Value != null ? rp.Value.Location : exit; target = Target.FromCell(self.World, exitLocation); td.Add(new LocationInit(exit)); td.Add(new CenterPositionInit(spawn)); td.Add(new FacingInit(initialFacing)); } self.World.AddFrameEndTask(w => { if (factionVariant != null) td.Add(new FactionInit(factionVariant)); var newUnit = self.World.CreateActor(producee.Name, td); var move = newUnit.TraitOrDefault<IMove>(); if (move != null) { if (exitinfo.MoveIntoWorld) { if (exitinfo.ExitDelay > 0) newUnit.QueueActivity(new Wait(exitinfo.ExitDelay, false)); newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); newUnit.QueueActivity(new AttackMoveActivity( newUnit, move.MoveTo(exitLocation, 1))); } } newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false); if (!self.IsDead) foreach (var t in self.TraitsImplementing<INotifyProduction>()) t.UnitProduced(self, newUnit, exit); var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>(); foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit); foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>()) t.BuildingComplete(newUnit); }); }
public ProgramDestroyEvent(ExitInfo exitInfo) : base((uint)enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS, new Guid("E147E9E3-6440-4073-A7B7-A65592C714B5")) { ExitInfo = exitInfo; }
// Called when we receive a state changed LLDB event. void OnStateChangedEvent(SbEvent sbEvent) { if (sbEvent == null) { return; } var type = sbEvent.GetStateType(); Debug.WriteLine("Received LLDB event: " + Enum.GetName(type.GetType(), type)); switch (type) { case StateType.STOPPED: if (sbEvent.GetProcessRestarted()) { break; } var currentThread = _lldbProcess.GetSelectedThread(); var currentStopReason = StopReason.INVALID; if (currentThread != null) { currentStopReason = currentThread.GetStopReason(); } // When stopping pick the most relevant thread based on the stop reason. if (currentThread == null || currentStopReason == StopReason.INVALID || currentStopReason == StopReason.NONE) { int numThreads = _lldbProcess.GetNumThreads(); RemoteThread planThread = null; RemoteThread otherThread = null; for (int i = 0; i < numThreads; ++i) { RemoteThread thread = _lldbProcess.GetThreadAtIndex(i); switch (thread.GetStopReason()) { case StopReason.INVALID: // fall-through case StopReason.NONE: break; case StopReason.SIGNAL: if (otherThread == null) { var signalNumber = thread.GetStopReasonDataAtIndex(0); var unixSignals = _lldbProcess.GetUnixSignals(); if (unixSignals != null && unixSignals.GetShouldStop((int)signalNumber)) { otherThread = thread; } } break; case StopReason.TRACE: // fall-through case StopReason.BREAKPOINT: // fall-through case StopReason.WATCHPOINT: // fall-through case StopReason.EXCEPTION: // fall-through case StopReason.EXEC: // fall-through case StopReason.EXITING: // fall-through case StopReason.INSTRUMENTATION: if (otherThread == null) { otherThread = thread; } break; case StopReason.PLAN_COMPLETE: if (planThread == null) { planThread = thread; } break; } } if (planThread != null) { currentThread = planThread; } else if (otherThread != null) { currentThread = otherThread; } else if (currentThread == null) { currentThread = _lldbProcess.GetThreadAtIndex(0); } if (currentThread == null) { Trace.WriteLine("Error: Cannot handle event. No thread found."); return; } _lldbProcess.SetSelectedThreadById(currentThread.GetThreadId()); currentStopReason = currentThread.GetStopReason(); } // Log specific information about the stop event. string message = "Received stop event. Reason: " + currentStopReason; var stopReasonDataCount = currentThread.GetStopReasonDataCount(); if (stopReasonDataCount > 0) { message += " Data:"; for (uint i = 0; i < stopReasonDataCount; i++) { message += " " + currentThread.GetStopReasonDataAtIndex(i); } } Trace.WriteLine(message); _taskContext.Factory.Run(async() => { // We run the event resolution on the main thread to make sure // we do not race with concurrent modifications in the breakpoint // manager class (we could just have hit breakpoint that is being // added by the main thread!). await _taskContext.Factory.SwitchToMainThreadAsync(); DebugEvent eventToSend = null; switch (currentStopReason) { case StopReason.BREAKPOINT: eventToSend = HandleBreakpointStop(currentThread); break; case StopReason.WATCHPOINT: eventToSend = HandleWatchpointStop(currentThread); break; case StopReason.SIGNAL: eventToSend = HandleSignalStop(currentThread); break; case StopReason.PLAN_COMPLETE: eventToSend = new StepCompleteEvent(); break; default: break; } if (eventToSend == null) { eventToSend = new BreakEvent(); } _debugEngineHandler.SendEvent(eventToSend,_program,currentThread); }); break; case StateType.EXITED: { // There are two ways to exit a debug session without an error: // - We call program.Terminate, which causes LLDB to send this event. // - Program exits by itself, resulting in this event. // We distinguish these events by checking if we called Terminate. ExitReason exitReason = _program.TerminationRequested ? ExitReason.DebuggerTerminated : ExitReason.ProcessExited; _debugEngineHandler.Abort(_program,ExitInfo.Normal(exitReason)); } break; case StateType.DETACHED: { // Normally the only way to detach the process is by program.Detach. // However, this check was retained to mirror the EXITED case and to // record unexpected instances of detaching through some other path. ExitReason exitReason = _program.DetachRequested ? ExitReason.DebuggerDetached : ExitReason.ProcessDetached; _debugEngineHandler.Abort(_program,ExitInfo.Normal(exitReason)); } break; } }