Example #1
0
        void debuggedProcess_ExceptionThrown(object sender, CorDbg.ExceptionEventArgs e)
        {
            if (!e.IsUnhandled)
            {
                // Ignore the exception
                e.Process.AsyncContinue();
                return;
            }

            //JumpToCurrentLine();

            StringBuilder stacktraceBuilder = new StringBuilder();

            // Need to intercept now so that we can evaluate properties
            if (e.Process.SelectedThread.InterceptCurrentException())
            {
                stacktraceBuilder.AppendLine(e.Exception.ToString());
                string stackTrace;
                try
                {
                    stackTrace = e.Exception.GetStackTrace("--- End of inner exception stack trace ---");
                }
                catch (GetValueException)
                {
                    stackTrace = e.Process.SelectedThread.GetStackTrace("at {0} in {1}:line {2}", "at {0}");
                }
                stacktraceBuilder.Append(stackTrace);
            }
            else
            {
                // For example, happens on stack overflow
                stacktraceBuilder.AppendLine("CannotInterceptException");
                stacktraceBuilder.AppendLine(e.Exception.ToString());
                stacktraceBuilder.Append(e.Process.SelectedThread.GetStackTrace("at {0} in {1}:line {2}", "at {0}"));
            }

            string title   = e.IsUnhandled ? "Unhandled" : "Handled";
            string message = string.Format("Message {0} {1}", e.Exception.Type, e.Exception.Message);

            MessageBox.Show(message + stacktraceBuilder.ToString(), title);
        }
Example #2
0
        /// <summary> Sets up the eviroment and raises user events </summary>
        internal void RaisePausedEvents()
        {
            AssertPaused();
            DisableAllSteppers();
            CheckSelectedStackFrames();
            SelectMostRecentStackFrameWithLoadedSymbols();

            if (this.PauseSession.PausedReason == PausedReason.Exception)
            {
                ExceptionEventArgs args = new ExceptionEventArgs(this, this.SelectedThread.CurrentException, this.SelectedThread.CurrentExceptionType, this.SelectedThread.CurrentExceptionIsUnhandled);
                OnExceptionThrown(args);
                // The event could have resumed or killed the process
                if (this.IsRunning || this.TerminateCommandIssued || this.HasExited)
                {
                    return;
                }
            }

            while (BreakpointHitEventQueue.Count > 0)
            {
                Breakpoint breakpoint = BreakpointHitEventQueue.Dequeue();
                breakpoint.NotifyHit();
                // The event could have resumed or killed the process
                if (this.IsRunning || this.TerminateCommandIssued || this.HasExited)
                {
                    return;
                }
            }

            OnPaused();
            // The event could have resumed the process
            if (this.IsRunning || this.TerminateCommandIssued || this.HasExited)
            {
                return;
            }
        }