Inheritance: CorThreadEventArgs
		void OnException2 (object sender, CorException2EventArgs e)
		{
			lock (debugLock) {
				if (evaluating) {
					e.Continue = true;
					return;
				}
			}
			
			TargetEventArgs args = null;
			
			switch (e.EventType) {
				case CorDebugExceptionCallbackType.DEBUG_EXCEPTION_FIRST_CHANCE:
					if (!this.Options.ProjectAssembliesOnly && IsCatchpoint (e))
						args = new TargetEventArgs (TargetEventType.ExceptionThrown);
					break;
				case CorDebugExceptionCallbackType.DEBUG_EXCEPTION_USER_FIRST_CHANCE:
					if (IsCatchpoint (e))
						args = new TargetEventArgs (TargetEventType.ExceptionThrown);
					break;
				case CorDebugExceptionCallbackType.DEBUG_EXCEPTION_CATCH_HANDLER_FOUND:
					break;
				case CorDebugExceptionCallbackType.DEBUG_EXCEPTION_UNHANDLED:
					args = new TargetEventArgs (TargetEventType.UnhandledException);
					break;
			}
			
			if (args != null) {
				OnStopped ();
				e.Continue = false;
				// If an exception is thrown while stepping, cancel the stepping operation
				if (stepper != null && stepper.IsActive ())
					stepper.Deactivate ();

				SetActiveThread (e.Thread);
				
				args.Process = GetProcess (process);
				args.Thread = GetThread (e.Thread);
				args.Backtrace = new Backtrace (new CorBacktrace (e.Thread, this));
				OnTargetEvent (args);	
			}
		}
		private bool IsCatchpoint (CorException2EventArgs e)
		{
			// Build up the exception type hierachy
			CorValue v = e.Thread.CurrentException;
			List<string> exceptions = new List<string>();
			CorType t = v.ExactType;
			while (t != null) {
				exceptions.Add(t.GetTypeInfo(this).FullName);
				t = t.Base;
			}
			
			// See if a catchpoint is set for this exception.
			foreach (Catchpoint cp in Breakpoints.GetCatchpoints()) {
				if (cp.Enabled && exceptions.Contains(cp.ExceptionName)) {
					return true;
				}
			}
			
			return false;
		}
示例#3
0
        private void OnException2EventHandler(Object sender, CorException2EventArgs e)
        {
            Trace.WriteLine("ManagedCallback::OnException2");
            BeginManagedDebugEvent();
            try
            {
                if (InternalHandleRawMode(ManagedCallbackType.OnException2, e))
                    return;

                if (e.EventType == CorDebugExceptionCallbackType.DEBUG_EXCEPTION_UNHANDLED &&
                    m_engine.Options.StopOnUnhandledException)
                {
                    e.Continue = false;
                    // just for historical reasons we are stopping with different StopReason
                    InternalSignalRuntimeIsStopped(e.Thread, new UnhandledExceptionThrownStopReason(e.AppDomain, e.Thread, e.Frame,
                                                                                                   e.Offset, e.EventType, e.Flags));
                    return;
                }

                if (e.EventType == CorDebugExceptionCallbackType.DEBUG_EXCEPTION_FIRST_CHANCE &&
                    m_engine.Options.StopOnException)
                {
                    e.Continue = false;
                    InternalSignalRuntimeIsStopped(e.Thread, new ExceptionThrownStopReason(e.AppDomain, e.Thread, e.Frame,
                                                                                          e.Offset, e.EventType, e.Flags));
                    return;
                }

                if (HandleCustomPostCallback(ManagedCallbackType.OnException2, e))
                    return;

                // if user has requested stops on enhanced exception,
                // we should always stop
                if (m_engine.Options.StopOnExceptionEnhanced)
                {
                    e.Continue = false;
                    InternalSignalRuntimeIsStopped(e.Thread, new ExceptionThrownStopReason(e.AppDomain, e.Thread, e.Frame,
                                                                                           e.Offset, e.EventType, e.Flags));
                    return;
                }
            }
            finally
            {
                EndManagedDebugEvent(e);
            }
        }