Exemple #1
0
 internal void queue_event_set(EventSet es)
 {
     lock (queue_monitor) {
         queue.Enqueue(es);
         Monitor.Pulse(queue_monitor);
     }
 }
Exemple #2
0
 void add_event_set(EventSet set)
 {
     lock (queue_monitor) {
         queue.Enqueue(set);
         Monitor.Pulse(queue_monitor);
     }
 }
		public Event GetNextEvent () {
			lock (queue_monitor) {
				if (current_es == null || current_es_index == current_es.Events.Length) {
					if (queue.Count == 0)
						Monitor.Wait (queue_monitor);
					current_es = (EventSet)queue.Dequeue ();
					current_es_index = 0;
				}
				return current_es.Events [current_es_index ++];
			}
		}
		public EventSet GetNextEventSet () {
			lock (queue_monitor) {
				if (queue.Count == 0)
					Monitor.Wait (queue_monitor);

				current_es = null;
				current_es_index = 0;

				return (EventSet)queue.Dequeue ();
			}
		}
        public EventSet GetNextEventSet(int timeoutInMilliseconds)
        {
            lock (queue_monitor) {
                if (queue.Count == 0)
                {
                    if (!Monitor.Wait(queue_monitor, timeoutInMilliseconds))
                    {
                        return(null);
                    }
                }

                current_es       = null;
                current_es_index = 0;

                return((EventSet)queue.Dequeue());
            }
        }
		// This method dispatches an event set.
		//
		// Based on the subset of events for which we register, and the contract for EventSet contents (equivalent to 
		// Java - http://download.oracle.com/javase/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/event/EventSet.html)
		// we know that event sets we receive are either:
		// 1) Set of step and break events for a location in a single thread.
		// 2) Set of catchpoints for a single exception.
		// 3) A single event of any other kind.
		// We verify these assumptions where possible, because things will break in horrible ways if they are wrong.
		//
		// If we are currently stopped on a thread, and the break events are on a different thread, we must queue
		// that event set and dequeue it next time we resume. This eliminates race conditions when multiple threads
		// hit breakpoints or catchpoints simultaneously.
		//
		void HandleEventSet (EventSet es)
		{
#if DEBUG_EVENT_QUEUEING
			if (!(es[0] is TypeLoadEvent))
				Console.WriteLine ("pp eventset({0}): {1}", es.Events.Length, es[0]);
#endif
			
			bool isBreakEvent = es[0] is BreakpointEvent || es[0] is ExceptionEvent || es[0] is StepEvent;
			
			if (isBreakEvent) {
				if (current_thread != null && es[0].Thread.Id != current_thread.Id) {
					QueueBreakEventSet (es.Events);
				} else {
					HandleBreakEventSet (es.Events, false);
				}
			} else {
				if (es.Events.Length != 1)
					throw new InvalidOperationException ("EventSet has unexpected combination of events");
				HandleEvent (es[0]);
				vm.Resume ();
			}
		}
		void add_event_set (EventSet set) {
			lock (queue_monitor) {
				queue.Enqueue (set);
				Monitor.Pulse (queue_monitor);
			}
		}
		// This method dispatches an event set.
		//
		// Based on the subset of events for which we register, and the contract for EventSet contents (equivalent to 
		// Java - http://download.oracle.com/javase/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/event/EventSet.html)
		// we know that event sets we receive are either:
		// 1) Set of step and break events for a location in a single thread.
		// 2) Set of catchpoints for a single exception.
		// 3) A single event of any other kind.
		// We verify these assumptions where possible, because things will break in horrible ways if they are wrong.
		//
		// If we are currently stopped on a thread, and the break events are on a different thread, we must queue
		// that event set and dequeue it next time we resume. This eliminates race conditions when multiple threads
		// hit breakpoints or catchpoints simultaneously.
		//
		void HandleEventSet (EventSet es)
		{
#if DEBUG_EVENT_QUEUEING
			if (!(es[0] is TypeLoadEvent))
				Console.WriteLine ("pp eventset({0}): {1}", es.Events.Length, es[0]);
#endif
			var type = es[0].EventType;
			bool isBreakEvent = type == EventType.Step || type == EventType.Breakpoint || type == EventType.Exception || type == EventType.UserBreak;
			
			if (isBreakEvent) {
				if (current_thread != null && es[0].Thread.Id != current_thread.Id) {
					QueueBreakEventSet (es.Events);
				} else {
					HandleBreakEventSet (es.Events, false);
				}
			} else {
				if (es.Events.Length != 1)
					throw new InvalidOperationException ("EventSet has unexpected combination of events");
				try {
					HandleEvent(es[0]);
				} catch (InvalidOperationException ioe) {
					// The VM is not suspended!
					return;
				} catch (AppDomainUnloadedException aue) {
					// AppDomain unloaded, but we can recover
				} catch (ObjectCollectedException oce) {
					// Object GCed, but we can recover
				}
				try {
					if (es.SuspendPolicy != SuspendPolicy.None)
						vm.Resume();
				} catch (InvalidOperationException) {
					// We want the VM resumed;
					// keep eating "VM is not suspended"
				}
			}
		}