private void ResetBreakPoints(DebuggerAction action)
		{
			SourceCode src = m_Script.GetSourceCode(action.SourceID);
			ResetBreakPoints(src, new HashSet<int>(action.Lines));
		}
		private bool ToggleBreakPoint(DebuggerAction action, bool? state)
		{
			SourceCode src = m_Script.GetSourceCode(action.SourceID);

			bool found = false;
			foreach (SourceRef srf in src.Refs)
			{
				if (srf.CannotBreakpoint)
					continue;

				if (srf.IncludesLocation(action.SourceID, action.SourceLine, action.SourceCol))
				{
					found = true;

					//System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on contains", srf, srf.Type));

					if (state == null)
						srf.Breakpoint = !srf.Breakpoint;
					else
						srf.Breakpoint = state.Value;

					if (srf.Breakpoint)
					{
						m_Debug.BreakPoints.Add(srf);
					}
					else
					{
						m_Debug.BreakPoints.Remove(srf);
					}
				}
			}

			if (!found)
			{
				int minDistance = int.MaxValue;
				SourceRef nearest = null;

				foreach (SourceRef srf in src.Refs)
				{
					if (srf.CannotBreakpoint)
						continue;

					int dist = srf.GetLocationDistance(action.SourceID, action.SourceLine, action.SourceCol);

					if (dist < minDistance)
					{
						minDistance = dist;
						nearest = srf;
					}
				}

				if (nearest != null)
				{
					//System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on distance {2}", nearest, nearest.Type, minDistance));

					if (state == null)
						nearest.Breakpoint = !nearest.Breakpoint;
					else
						nearest.Breakpoint = state.Value;

					if (nearest.Breakpoint)
					{
						m_Debug.BreakPoints.Add(nearest);
					}
					else
					{
						m_Debug.BreakPoints.Remove(nearest);
					}

					return true;
				}
				else
					return false;
			}
			else
				return true;
		}
Пример #3
0
		public void QueueAction(DebuggerAction action)
		{
			m_QueuedActions.Enqueue(action);
		}
Пример #4
0
		void DebugAction(DebuggerAction action)
		{
			bool savedState = timerFollow.Enabled;
			timerFollow.Enabled = false;

			m_NextAction = action;
			m_WaitLock.Set();

			if (!m_WaitBack.WaitOne(1000))
			{
				MessageBox.Show(this, "Operation timed out", "Timeout");
			}
			else
			{
				timerFollow.Enabled = savedState;
			}
		}
Пример #5
0
		DebuggerAction IDebugger.GetAction(int ip, SourceRef sourceCodeRef)
		{
			m_Ctx.Post(o =>
			{
				codeView.ActiveLine = ip;
				RefreshCodeView(sourceCodeRef);
			}, null);

			m_WaitLock.WaitOne();

			DebuggerAction action = m_NextAction;
			m_NextAction = null;

			m_WaitBack.Set();

			return action;
		}
		DebuggerAction IDebugger.GetAction(int ip, SourceRef sourceref)
		{
			PauseRequested = false;

			lock (m_Lock)
				if (Client != null)
				{
					Client.SendStopEvent();
				}

			while (true)
			{
				lock (m_Lock)
				{
					if (Client == null)
					{
						return new DebuggerAction() { Action = DebuggerAction.ActionType.Run };
					}

					if (m_PendingAction != null)
					{
						var action = m_PendingAction;
						m_PendingAction = null;
						return action;
					}
				}

				Sleep(10);
			}
		}
		public void QueueAction(DebuggerAction action)
		{
			while (true)
			{
				lock (m_Lock)
					if (m_PendingAction == null)
					{
						m_PendingAction = action;
						break;
					}

				Sleep(10);
			}
		}