Inheritance: ObjectMirror
Exemple #1
0
 public AD7Thread(AD7Engine engine, DebuggedThread debuggedThread)//ThreadMirror threadMirror)
 {
     _engine = engine;
     
     ThreadMirror = debuggedThread.Thread;
     _debuggedThread = debuggedThread;
 }
		public SoftEvaluationContext (SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options): base (options)
		{
			Frame = frame;
			Thread = frame.Thread;

			string method = frame.Method.Name;
			if (frame.Method.DeclaringType != null)
				method = frame.Method.DeclaringType.FullName + "." + method;
			var location = new DC.SourceLocation (method, frame.FileName, frame.LineNumber);
			string language;

			if (frame.Method != null) {
				if (frame.IsNativeTransition) {
					language = "Transition";
				} else {
					language = "Managed";
				}
			} else {
				language = "Native";
			}
			
			Evaluator = session.GetEvaluator (new DC.StackFrame (frame.ILOffset, location, language, session.IsExternalCode (frame), true));
			Adapter = session.Adaptor;
			this.session = session;
			this.stackVersion = session.StackVersion;
			sourceAvailable = !string.IsNullOrEmpty (frame.FileName) && System.IO.File.Exists (frame.FileName);
		}
Exemple #3
0
        // name is a field name, local variable name, etc.
        // parent is a LiveStackFrame, ObjectMirror, ArrayMirror, etc. Parents are always non-null except for the LiveStackFrame parent.
        // key is an integral index, a FieldInfoMirror, LocalVariable, etc.
        // value is the object associated with the parent/key. It will be a Value or a primitive type (like char or int).
        public VariableItem(ThreadMirror thread, string name, VariableItem parent, object key, object value, int index)
            : base(NSObject.AllocAndInitInstance("VariableItem"))
        {
            Contract.Requires(thread != null);
            Contract.Requires(!string.IsNullOrEmpty(name));
            Contract.Requires(parent != null || value is LiveStackFrame);
            Contract.Requires(key != null || value is LiveStackFrame);
            Contract.Requires(value != null);					// null debugger values are PrimitiveValues with a null Value
            Contract.Requires(index >= 0);

            Parent = parent;
            Key = key;
            Value = value;
            m_index = index;
            m_actualName = name;
            m_actualValue = value;

            Details details = DoGetDetails(thread, name, parent, key, value);

            Value = details.Value;
            AttributedName = NSMutableAttributedString.Create(details.DisplayName).Retain();
            AttributedType = NSAttributedString.Create(details.DisplayType).Retain();
            AttributedValue = NSAttributedString.Create(details.DisplayValue).Retain();
            NumberOfChildren = details.NumberOfChildren;
        }
Exemple #4
0
        private string DoGetRefCount(ThreadMirror thread)
        {
            string result = null;

            // Using InvokeMethod causes the VM to exit. Not sure what calling InvokeMethod
            // does, but if it is working it takes forever to finish.
            #if DOES_NOT_WORK
            ObjectMirror value = Object as ObjectMirror;
            if (value != null && value.Type.IsType("MObjc.NSObject"))
            {
                MethodMirror method = value.Type.FindMethod("retainCount", 0);
                if (method != null)
                {
                    Value v = value.InvokeMethod(thread, method, new Value[0], InvokeOptions.DisableBreakpoints | InvokeOptions.SingleThreaded);
            //					var invoker = new InvokeMethod();
            //					Value v = invoker.Invoke(thread, value, "retainCount");
                    PrimitiveValue p = v as PrimitiveValue;
                    if (p != null)
                        result = string.Format(" (retainCount = {0})", p.Value);
                }
            }
            #endif

            return result;
        }
		internal StepEventRequest (VirtualMachine vm, ThreadMirror thread) : base (vm, EventType.Step) {
			if (thread == null)
				throw new ArgumentNullException ("thread");
			CheckMirror (vm, thread);
			this.step_thread = thread;
			Depth = StepDepth.Into;
			Size = StepSize.Min;
		}
 /*
  * FIXME: Decide on the way to request/handle debugging information:
  * - request the info in bulk for all frames/on demand for individual frames
  * - request the info from the runtime/request only the il offset, and compute
  *   everything else based on this info using the method debug info.
  */
 internal StackFrame(VirtualMachine vm, long id, ThreadMirror thread, MethodMirror method, int il_offset, StackFrameFlags flags)
     : base(vm, id)
 {
     this.thread = thread;
     this.method = method;
     this.il_offset = il_offset;
     this.flags = flags;
 }
 public DebuggedThread(ThreadMirror thread, AD7Engine engine)
 {
     Thread = thread;
     Id = thread.TID;
     Name = "";
     TargetId = thread.TID;
     AD7Thread ad7Thread = new AD7Thread(engine, this);
     Client = ad7Thread;
 }
		public SoftDebuggerBacktrace (SoftDebuggerSession session, MDB.ThreadMirror thread): base (session.Adaptor)
		{
			this.session = session;
			this.thread = thread;
			stackVersion = session.StackVersion;
			if (thread != null)
				this.frames = thread.GetFrames ();
			else
				this.frames = new MDB.StackFrame[0];
		}
 public static void Set(ThreadMirror thread, VariableItem item, InstanceValue parent, FieldInfoMirror key, Value newValue)
 {
     if (key.IsStatic)
     {
         key.DeclaringType.SetValue(key, newValue);
     }
     else
     {
         var o = (ObjectMirror) parent.Instance;
         o.SetValue(key, newValue);
     }
 }
 public SoftDebuggerBacktrace(SoftDebuggerSession session, MDB.ThreadMirror thread) : base(session.Adaptor)
 {
     this.session = session;
     this.thread  = thread;
     stackVersion = session.StackVersion;
     if (thread != null)
     {
         this.frames = thread.GetFrames();
     }
     else
     {
         this.frames = new MDB.StackFrame[0];
     }
 }
Exemple #11
0
        // Like the above except exceptions are allowed to escape.
        public Value UnsafeInvoke(ThreadMirror thread, Value target, string name)
        {
            Contract.Requires(thread != null, "thread is null");
            Contract.Requires(target != null, "target is null");
            Contract.Requires(target is ObjectMirror || target is StructMirror, "target is a " + target.GetType().FullName);
            Contract.Requires(!name.IsNullOrWhiteSpace());

            Value result;
            if (target is ObjectMirror)
                result = DoInvoke(thread, (ObjectMirror) target, name);
            else
                result = DoInvoke(thread, (StructMirror) target, name);

            return result;
        }
Exemple #12
0
        public void Write(System.IO.StreamWriter stream, ThreadMirror thread, int indent)
        {
            for (int i = 0; i < indent; ++i)
            {
                stream.Write('\t');
            }

            string refCount = DoGetRefCount(thread);
            stream.WriteLine("{0}{1}\t\t\t\t{2}", Name, refCount, Type);

            foreach (Trace child in Children)
            {
                child.Write(stream, thread, indent + 1);
            }
        }
        public static string GetThreadName(ThreadMirror thread)
        {
            string name = thread.Name;

            if (thread.Id == 1)				// TODO: should we be using ThreadId here?
                name =  "main";
            else if (thread.Id == 2)
                name =  "finalizer";

            if (!string.IsNullOrEmpty(name))
                name = string.Format("{0} ({1})", name, thread.Id);
            else
                name = thread.Id.ToString();

            return name;
        }
        public static void Set(ThreadMirror thread, VariableItem item, InstanceValue parent, int key, Value newValue)
        {
            FieldInfoMirror field = parent.Type.GetFields()[key];
            Contract.Assert(!field.IsStatic);

            ObjectMirror o = parent.Instance as ObjectMirror;
            if (o != null)
            {
                o.SetValue(field, newValue);
            }
            else
            {
                var s = (StructMirror) parent.Instance;
                s.Fields[key] = newValue;
                SetValue.Invoke(thread, item.Parent, item.Parent.Parent.Value, item.Parent.Key, s);
            }
        }
        public static VariableItem GetChild(ThreadMirror thread, VariableItem parentItem, LiveStackFrame parent, int index)
        {
            VariableItem child;

            IList<LocalVariable> locals = parent.GetVisibleVariables();
            if (index < locals.Count)
            {
                LocalVariable local = locals[index];

                string name = local.Name;
                if (string.IsNullOrEmpty(name))
                    name = "$" + local.Index;			// temporary variable

                Value v = parent.GetValue(local);
                child = new VariableItem(thread, name, parentItem, local, v, index);
            }
            else
            {
                FieldInfoMirror[] fields = parent.Method.DeclaringType.GetAllFields().ToArray();
                Contract.Assert(fields.Length > 0);

                object v = null;
                string name = "this";
                if (parent.ThisPtr is ObjectMirror)
                {
                    v = new InstanceValue((ObjectMirror) parent.ThisPtr, fields);
                }
                else if (parent.ThisPtr is StructMirror)
                {
                    v = new InstanceValue((StructMirror) parent.ThisPtr, fields);
                }
                else if (parent.ThisPtr == null || parent.ThisPtr.IsNull())
                {
                    v = new TypeValue(parent.Method.DeclaringType);
                    name = "statics";
                }
                else
                {
                    Contract.Assert(false, parent.ThisPtr.TypeName() + " is bogus");
                }

                child = new VariableItem(thread, name, parentItem, index, v, index);
            }

            return child;
        }
		public SoftEvaluationContext (SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options): base (options)
		{
			Frame = frame;
			Thread = frame.Thread;
		
		
			string method = frame.Method.Name;
			if (frame.Method.DeclaringType != null)
				method = frame.Method.DeclaringType.FullName + "." + method;
			var location = new DC.SourceLocation (method, frame.FileName, frame.LineNumber);
			var lang = frame.Method != null? "Managed" : "Native";
			
			Evaluator = session.GetResolver (new DC.StackFrame (frame.ILOffset, location, lang, session.IsExternalCode (frame), true));
			Adapter = session.Adaptor;
			this.session = session;
			this.stackVersion = session.StackVersion;
		}
Exemple #17
0
        // Target should be a ObjectMirror or a StructMirror. Name should be the name of a
        // property (e.g. Count), field (eg Empty), or nullary method. Returns an error string.
        public static Value Evaluate(ThreadMirror thread, Value target, string name)
        {
            Contract.Requires(thread != null, "thread is null");
            Contract.Requires(target != null, "target is null");
            Contract.Requires(!string.IsNullOrEmpty(name), "name is null or empty");

            Value result = null;

            // Try fields,
            if (target is ObjectMirror)
                result = DoGetField((ObjectMirror) target, name, thread);

            else if (target is StructMirror)
                result = DoGetField((StructMirror) target, name, thread);

            // properties.
            if (result == null)
            {
                if (target is ObjectMirror)
                    result = DoEvaluateProperty(thread, (ObjectMirror) target, name);

                else if (target is StructMirror)
                    result = DoEvaluateProperty(thread, (StructMirror) target, name);
            }

            // and methods.
            if (result == null)
            {
                if (target is ObjectMirror)
                    result = DoEvaluateMethod(thread, (ObjectMirror) target, name);

                else if (target is StructMirror)
                    result = DoEvaluateMethod(thread, (StructMirror) target, name);

                else
                    Contract.Assert(false, "Expected an ObjectMirror or StructMirror but got a " + target.GetType().FullName);
            }

            if (result == null)
                result = target.VirtualMachine.RootDomain.CreateString(string.Empty);	// usually ShouldEvaluate was false

            return result;
        }
Exemple #18
0
        private const int Timeout = 500; // TODO: might want to allow this to be set (especially when we get an immediate window)

        #endregion Fields

        #region Methods

        // Invokes a nullary method on an ObjectMirror or StructMirror. If the call
        // times out a StringMirror is returned with an error message.
        public Value Invoke(ThreadMirror thread, Value target, string name)
        {
            Contract.Requires(thread != null, "thread is null");
            Contract.Requires(target != null, "target is null");
            Contract.Requires(target is ObjectMirror || target is StructMirror, "target is a " + target.GetType().FullName);
            Contract.Requires(!name.IsNullOrWhiteSpace());

            Value result;

            try
            {
                result = UnsafeInvoke(thread, target, name);
            }
            catch (Exception e)
            {
                result = thread.Domain.CreateString(e.Message);
            }

            return result;
        }
		ThreadInfo GetThread (ProcessInfo process, ThreadMirror thread)
		{
			long tid = GetId (thread);
			foreach (var t in OnGetThreads (process.Id))
				if (t.Id == tid)
					return t;
			return null;
		}
Exemple #20
0
		internal static void AbortInvoke (VirtualMachine vm, ThreadMirror thread, int id)
		{
			vm.conn.VM_AbortInvoke (thread.Id, id);
		}
Exemple #21
0
        //
        // Implementation of InvokeMultiple
        //

        internal static IInvokeAsyncResult BeginInvokeMultiple(VirtualMachine vm, ThreadMirror thread, MethodMirror[] methods, Value this_obj, IList <IList <Value> > arguments, InvokeOptions options, AsyncCallback callback, object state)
        {
            if (thread == null)
            {
                throw new ArgumentNullException("thread");
            }
            if (methods == null)
            {
                throw new ArgumentNullException("methods");
            }
            foreach (var m in methods)
            {
                if (m == null)
                {
                    throw new ArgumentNullException("method");
                }
            }
            if (arguments == null)
            {
                arguments = new List <IList <Value> > ();
                for (int i = 0; i < methods.Length; ++i)
                {
                    arguments.Add(new Value [0]);
                }
            }
            else
            {
                // FIXME: Not needed for property evaluation
                throw new NotImplementedException();
            }
            if (callback == null)
            {
                throw new ArgumentException("A callback argument is required for this method.", "callback");
            }

            InvokeFlags f = InvokeFlags.NONE;

            if ((options & InvokeOptions.DisableBreakpoints) != 0)
            {
                f |= InvokeFlags.DISABLE_BREAKPOINTS;
            }
            if ((options & InvokeOptions.SingleThreaded) != 0)
            {
                f |= InvokeFlags.SINGLE_THREADED;
            }

            InvokeAsyncResult r = new InvokeAsyncResult {
                AsyncState = state, AsyncWaitHandle = new ManualResetEvent(false), VM = vm, Thread = thread, Callback = callback, NumPending = methods.Length, IsMultiple = true
            };

            var mids = new long [methods.Length];

            for (int i = 0; i < methods.Length; ++i)
            {
                mids [i] = methods [i].Id;
            }
            var args = new List <ValueImpl[]> ();

            for (int i = 0; i < methods.Length; ++i)
            {
                args.Add(vm.EncodeValues(arguments [i]));
            }
            thread.InvalidateFrames();
            r.ID = vm.conn.VM_BeginInvokeMethods(thread.Id, mids, this_obj != null ? vm.EncodeValue(this_obj) : vm.EncodeValue(vm.CreateValue(null)), args, f, InvokeMultipleCB, r);

            return(r);
        }
Exemple #22
0
		public Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
			var tcs = new TaskCompletionSource<InvokeResult> ();
			BeginInvokeMethod (thread, method, arguments, options, iar =>
					{
						try {
							tcs.SetResult (EndInvokeMethodInternalWithResult (iar));
						} catch (OperationCanceledException) {
							tcs.TrySetCanceled ();
						} catch (Exception ex) {
							tcs.TrySetException (ex);
						}
					}, null);
			return tcs.Task;
		}
Exemple #23
0
		internal static IInvokeAsyncResult BeginInvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state) {
			if (thread == null)
				throw new ArgumentNullException ("thread");
			if (method == null)
				throw new ArgumentNullException ("method");
			if (arguments == null)
				arguments = new Value [0];

			InvokeFlags f = InvokeFlags.NONE;

			if ((options & InvokeOptions.DisableBreakpoints) != 0)
				f |= InvokeFlags.DISABLE_BREAKPOINTS;
			if ((options & InvokeOptions.SingleThreaded) != 0)
				f |= InvokeFlags.SINGLE_THREADED;
			if ((options & InvokeOptions.ReturnOutThis) != 0)
				f |= InvokeFlags.OUT_THIS;
			if ((options & InvokeOptions.ReturnOutArgs) != 0)
				f |= InvokeFlags.OUT_ARGS;

			InvokeAsyncResult r = new InvokeAsyncResult { AsyncState = state, AsyncWaitHandle = new ManualResetEvent (false), VM = vm, Thread = thread, Callback = callback };
			thread.InvalidateFrames ();
			r.ID = vm.conn.VM_BeginInvokeMethod (thread.Id, method.Id, this_obj != null ? vm.EncodeValue (this_obj) : vm.EncodeValue (vm.CreateValue (null)), vm.EncodeValues (arguments), f, InvokeCB, r);

			return r;
		}
		public ObjectMirror GetExceptionObject (ThreadMirror thread)
		{
			ObjectMirror obj;
			if (activeExceptionsByThread.TryGetValue (thread.ThreadId, out obj))
				return obj;
			else
				return null;
		}
Exemple #25
0
		public Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options) {
			return InvokeMethod (vm, thread, method, this, arguments, options);
		}
Exemple #26
0
 internal void AddThreadToInvalidateList(ThreadMirror threadMirror)
 {
     lock (threadsToInvalidate) {
         threadsToInvalidate.Add(threadMirror);
     }
 }
Exemple #27
0
 public Task <InvokeResult> InvokeMethodAsyncWithResult(ThreadMirror thread, MethodMirror method, IList <Value> arguments, InvokeOptions options = InvokeOptions.None)
 {
     return(ObjectMirror.InvokeMethodAsyncWithResult(vm, thread, method, this, arguments, options));
 }
Exemple #28
0
 public Value InvokeMethod(ThreadMirror thread, MethodMirror method, IList <Value> arguments, InvokeOptions options)
 {
     return(ObjectMirror.InvokeMethod(vm, thread, method, this, arguments, options));
 }
Exemple #29
0
 public Value NewInstance(ThreadMirror thread, MethodMirror method, IList <Value> arguments, InvokeOptions options)
 {
     return(ObjectMirror.InvokeMethod(vm, thread, method, null, arguments, options));
 }
Exemple #30
0
 public Value InvokeMethod(ThreadMirror thread, MethodMirror method, IList <Value> arguments)
 {
     return(ObjectMirror.InvokeMethod(vm, thread, method, null, arguments, InvokeOptions.None));
 }
Exemple #31
0
        internal T GetObject <T> (long id, long domain_id, long type_id) where T : ObjectMirror
        {
            ObjectMirror obj = null;

            lock (objects_lock) {
                if (objects == null)
                {
                    objects = new Dictionary <long, ObjectMirror> ();
                }
                objects.TryGetValue(id, out obj);
            }

            if (obj == null)
            {
                /*
                 * Obtain the domain/type of the object to determine the type of
                 * object we need to create. Do this outside the lock.
                 */
                if (domain_id == 0 || type_id == 0)
                {
                    if (conn.Version.AtLeast(2, 5))
                    {
                        var info = conn.Object_GetInfo(id);
                        domain_id = info.domain_id;
                        type_id   = info.type_id;
                    }
                    else
                    {
                        if (domain_id == 0)
                        {
                            domain_id = conn.Object_GetDomain(id);
                        }
                        if (type_id == 0)
                        {
                            type_id = conn.Object_GetType(id);
                        }
                    }
                }
                AppDomainMirror d = GetDomain(domain_id);
                TypeMirror      t = GetType(type_id);

                if (t.Assembly == d.Corlib && t.Namespace == "System.Threading" && t.Name == "Thread")
                {
                    obj = new ThreadMirror(this, id, t, d);
                }
                else if (t.Assembly == d.Corlib && t.Namespace == "System" && t.Name == "String")
                {
                    obj = new StringMirror(this, id, t, d);
                }
                else if (typeof(T) == typeof(ArrayMirror))
                {
                    obj = new ArrayMirror(this, id, t, d);
                }
                else
                {
                    obj = new ObjectMirror(this, id, t, d);
                }

                // Publish
                lock (objects_lock) {
                    ObjectMirror prev_obj;
                    if (objects.TryGetValue(id, out prev_obj))
                    {
                        obj = prev_obj;
                    }
                    else
                    {
                        objects [id] = obj;
                    }
                }
            }
            return((T)obj);
        }
Exemple #32
0
 public StepEventRequest CreateStepRequest(ThreadMirror thread)
 {
     return(new StepEventRequest(this, thread));
 }
Exemple #33
0
 public IAsyncResult BeginInvokeMethod(ThreadMirror thread, MethodMirror method, IList <Value> arguments, InvokeOptions options, AsyncCallback callback, object state)
 {
     return(ObjectMirror.BeginInvokeMethod(vm, thread, method, this, arguments, options, callback, state));
 }
 public Value NewInstance(ThreadMirror thread, MethodMirror method, IList <Value> arguments)
 {
     return(NewInstance(thread, method, arguments, InvokeOptions.None));
 }
		Backtrace GetThreadBacktrace (ThreadMirror thread)
		{
			return new Backtrace (new SoftDebuggerBacktrace (this, thread));
		}
Exemple #36
0
 public SdbThreadMirror(MDS.ThreadMirror threadMirror)
     : base(threadMirror)
 {
 }
		void HandleBreakEventSet (Event[] es, bool dequeuing)
		{
			if (dequeuing && exited)
				return;
			
			OnHandleBreakEventSet (es);
			
			bool resume = true;
			ObjectMirror exception = null;
			TargetEventType etype = TargetEventType.TargetStopped;
			BreakEvent breakEvent = null;
			
			if (es[0] is ExceptionEvent) {
				var bad = es.FirstOrDefault (ee => !(ee is ExceptionEvent));
				if (bad != null)
					throw new Exception ("Catchpoint eventset had unexpected event type " + bad.GetType ());
				var ev = (ExceptionEvent)es[0];
				if (ev.Request == unhandledExceptionRequest)
					etype = TargetEventType.UnhandledException;
				else
					etype = TargetEventType.ExceptionThrown;
				exception = ev.Exception;
				if (ev.Request != unhandledExceptionRequest || exception.Type.FullName != "System.Threading.ThreadAbortException")
					resume = false;
			}
			else {
				//always need to evaluate all breakpoints, some might be tracepoints or conditional bps with counters
				foreach (Event e in es) {
					BreakpointEvent be = e as BreakpointEvent;
					if (be != null) {
						if (!HandleBreakpoint (e.Thread, be.Request)) {
							etype = TargetEventType.TargetHitBreakpoint;
							BreakInfo binfo;
							if (breakpoints.TryGetValue (be.Request, out binfo))
								breakEvent = binfo.BreakEvent;
							resume = false;
						}
					} else if (e is StepEvent) {
						etype = TargetEventType.TargetStopped;
						resume = false;
					} else {
						throw new Exception ("Break eventset had unexpected event type " + e.GetType ());
					}
				}
			}
			
			if (resume) {
				//all breakpoints were conditional and evaluated as false
				vm.Resume ();
				DequeueEventsForFirstThread ();
			} else {
				if (currentStepRequest != null) {
					currentStepRequest.Enabled = false;
					currentStepRequest = null;
				}
				current_thread = recent_thread = es[0].Thread;
				TargetEventArgs args = new TargetEventArgs (etype);
				args.Process = OnGetProcesses () [0];
				args.Thread = GetThread (args.Process, current_thread);
				args.Backtrace = GetThreadBacktrace (current_thread);
				args.BreakEvent = breakEvent;
				
				if (exception != null)
					activeExceptionsByThread [current_thread.ThreadId] = exception;
				
				OnTargetEvent (args);
			}
		}
Exemple #38
0
 internal static Value InvokeMethod(VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList <Value> arguments, InvokeOptions options)
 {
     return(EndInvokeMethodInternal(BeginInvokeMethod(vm, thread, method, this_obj, arguments, options, null, null)));
 }
		void DequeueEventsForFirstThread ()
		{
			List<List<Event>> dequeuing;
			lock (queuedEventSets) {
				if (queuedEventSets.Count < 1)
					return;
				
				dequeuing = new List<List<Event>> ();
				var node = queuedEventSets.First;
				
				//making this the current thread means that all events from other threads will get queued
				current_thread = node.Value[0].Thread;
				while (node != null) {
					if (node.Value[0].Thread.Id == current_thread.Id) {
						var d = node;
						node = node.Next;
						dequeuing.Add (d.Value);
						queuedEventSets.Remove (d);
					} else {
						node = node.Next;
					}
				}
			}

#if DEBUG_EVENT_QUEUEING
			foreach (var e in dequeuing)
				Console.WriteLine ("dq eventset({0}): {1}", e.Count, e[0]);
#endif

			//firing this off in a thread prevents possible infinite recursion
			ThreadPool.QueueUserWorkItem (delegate {
				if (!exited) {
					foreach (var es in dequeuing) {
						try {
							 HandleBreakEventSet (es.ToArray (), true);
						} catch (VMDisconnectedException ex) {
							if (!HandleException (ex))
								OnDebuggerOutput (true, ex.ToString ());
							break;
						} catch (Exception ex) {
							if (!HandleException (ex))
								OnDebuggerOutput (true, ex.ToString ());
						}
					}
				}
			});
		}
Exemple #40
0
 //
 // Invoke the members of METHODS one-by-one, calling CALLBACK after each invoke was finished. The IAsyncResult will be marked as completed after all invokes have
 // finished. The callback will be called with a different IAsyncResult that represents one method invocation.
 // From protocol version 2.22.
 //
 public IAsyncResult BeginInvokeMultiple(ThreadMirror thread, MethodMirror[] methods, IList <IList <Value> > arguments, InvokeOptions options, AsyncCallback callback, object state)
 {
     return(BeginInvokeMultiple(vm, thread, methods, this, arguments, options, callback, state));
 }
Exemple #41
0
		public IAsyncResult BeginInvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state) {
			return BeginInvokeMethod (vm, thread, method, this, arguments, options, callback, state);
		}
Exemple #42
0
        internal static Task <TResult> InvokeMethodAsync <TResult> (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList <Value> arguments, InvokeOptions options, Func <IAsyncResult, TResult> callback)
        {
            var tcs = new TaskCompletionSource <TResult> ();

            BeginInvokeMethod(vm, thread, method, this_obj, arguments, options, iar =>
            {
                try {
                    tcs.SetResult(callback(iar));
                } catch (OperationCanceledException) {
                    tcs.TrySetCanceled();
                } catch (Exception ex) {
                    tcs.TrySetException(ex);
                }
            }, null);
            return(tcs.Task);
        }
Exemple #43
0
		//
		// Invoke the members of METHODS one-by-one, calling CALLBACK after each invoke was finished. The IAsyncResult will be marked as completed after all invokes have
		// finished. The callback will be called with a different IAsyncResult that represents one method invocation.
		// From protocol version 2.22.
		//
		public IAsyncResult BeginInvokeMultiple (ThreadMirror thread, MethodMirror[] methods, IList<IList<Value>> arguments, InvokeOptions options, AsyncCallback callback, object state) {
			return BeginInvokeMultiple (vm, thread, methods, this, arguments, options, callback, state);
		}
Exemple #44
0
 internal static Task <InvokeResult> InvokeMethodAsyncWithResult(VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList <Value> arguments, InvokeOptions options)
 {
     return(InvokeMethodAsync(vm, thread, method, this_obj, arguments, options, EndInvokeMethodInternalWithResult));
 }
Exemple #45
0
		internal static Value InvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options) {
			return EndInvokeMethodInternal (BeginInvokeMethod (vm, thread, method, this_obj, arguments, options, null, null));
		}
Exemple #46
0
 public Task <Value> InvokeMethodAsync(ThreadMirror thread, MethodMirror method, IList <Value> arguments, InvokeOptions options = InvokeOptions.None)
 {
     return(InvokeMethodAsync(vm, thread, method, this, arguments, options));
 }
Exemple #47
0
		//
		// Implementation of InvokeMultiple
		//

		internal static IInvokeAsyncResult BeginInvokeMultiple (VirtualMachine vm, ThreadMirror thread, MethodMirror[] methods, Value this_obj, IList<IList<Value>> arguments, InvokeOptions options, AsyncCallback callback, object state) {
			if (thread == null)
				throw new ArgumentNullException ("thread");
			if (methods == null)
				throw new ArgumentNullException ("methods");
			foreach (var m in methods)
				if (m == null)
					throw new ArgumentNullException ("method");
			if (arguments == null) {
				arguments = new List<IList<Value>> ();
				for (int i = 0; i < methods.Length; ++i)
					arguments.Add (new Value [0]);
			} else {
				// FIXME: Not needed for property evaluation
				throw new NotImplementedException ();
			}
			if (callback == null)
				throw new ArgumentException ("A callback argument is required for this method.", "callback");

			InvokeFlags f = InvokeFlags.NONE;

			if ((options & InvokeOptions.DisableBreakpoints) != 0)
				f |= InvokeFlags.DISABLE_BREAKPOINTS;
			if ((options & InvokeOptions.SingleThreaded) != 0)
				f |= InvokeFlags.SINGLE_THREADED;

			InvokeAsyncResult r = new InvokeAsyncResult { AsyncState = state, AsyncWaitHandle = new ManualResetEvent (false), VM = vm, Thread = thread, Callback = callback, NumPending = methods.Length, IsMultiple = true };

			var mids = new long [methods.Length];
			for (int i = 0; i < methods.Length; ++i)
				mids [i] = methods [i].Id;
			var args = new List<ValueImpl[]> ();
			for (int i = 0; i < methods.Length; ++i)
				args.Add (vm.EncodeValues (arguments [i]));
			thread.InvalidateFrames ();
			r.ID = vm.conn.VM_BeginInvokeMethods (thread.Id, mids, this_obj != null ? vm.EncodeValue (this_obj) : vm.EncodeValue (vm.CreateValue (null)), args, f, InvokeMultipleCB, r);

			return r;
		}
Exemple #48
0
 internal static void AbortInvoke(VirtualMachine vm, ThreadMirror thread, int id)
 {
     vm.conn.VM_AbortInvoke(thread.Id, id);
 }