public static void Show(Process process, string title, string message, string stacktrace, Bitmap icon)
		{
			DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);
			form.Text = title;
			form.pictureBox.Image = icon;
			form.lblExceptionText.Text = message;
			form.exceptionView.Text = stacktrace;
			
			form.Show(WorkbenchSingleton.MainWin32Window);
		}
예제 #2
0
        public static void Show(Process process, string title, string message, string stacktrace, Bitmap icon)
        {
            DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);

            form.Text                  = title;
            form.pictureBox.Image      = icon;
            form.lblExceptionText.Text = message;
            form.exceptionView.Text    = stacktrace;

            form.Show(WorkbenchSingleton.MainWin32Window);
        }
		public static void Show(Process process, string title, string message, string stacktrace, Bitmap icon, bool isUnhandled, Debugger.Exception exception)
		{
			DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);
			form.Text = title;
			form.pictureBox.Image = icon;
			form.lblExceptionText.Text = message;
			form.exceptionView.Text = stacktrace;
			form.isUnhandled = isUnhandled;
			form.btnContinue.Enabled = !isUnhandled;
			form.Exception = exception;
			
			form.Show(WorkbenchSingleton.MainWin32Window);
		}
예제 #4
0
        public static void Show(Process process, string title, string message, string stacktrace, Bitmap icon, bool isUnhandled, Debugger.Exception exception)
        {
            DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);

            form.Text                  = title;
            form.pictureBox.Image      = icon;
            form.lblExceptionText.Text = message;
            form.exceptionView.Text    = stacktrace;
            form.isUnhandled           = isUnhandled;
            form.btnContinue.Enabled   = !isUnhandled;
            form.Exception             = exception;

            form.Show(WorkbenchSingleton.MainWin32Window);
        }
		public static bool Show(Process process, string title, string type, string stacktrace, Bitmap icon, bool isUnhandled)
		{
			DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);
			form.Text = title;
			form.pictureBox.Image = icon;
			form.lblExceptionText.Text = type;
			form.exceptionView.Text = stacktrace;
			form.btnContinue.Enabled = !isUnhandled;
			
			// Showing the form as dialg seems like a resonable thing in the presence of potentially multiple
			// concurent debugger evetns
			form.ShowDialog(SD.WinForms.MainWin32Window);
			
			return form.Break;
		}
예제 #6
0
        public static bool Show(Process process, string title, string type, string stacktrace, Bitmap icon, bool isUnhandled)
        {
            DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);

            form.Text                  = title;
            form.pictureBox.Image      = icon;
            form.lblExceptionText.Text = type;
            form.exceptionView.Text    = stacktrace;
            form.btnContinue.Enabled   = !isUnhandled;

            // Showing the form as dialg seems like a resonable thing in the presence of potentially multiple
            // concurent debugger evetns
            form.ShowDialog(SD.WinForms.MainWin32Window);

            return(form.Break);
        }
		public static bool Show(Process process, string exceptionType, string stacktrace, bool isUnhandled)
		{
			DebuggeeExceptionForm form = new DebuggeeExceptionForm(process, exceptionType);
			string type = string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Message}"), exceptionType);
			Bitmap icon = WinFormsResourceService.GetBitmap(isUnhandled ? "Icons.32x32.Error" : "Icons.32x32.Warning");

			form.Text = isUnhandled ? StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Unhandled}") : StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Handled}");
			form.pictureBox.Image = icon;
			form.lblExceptionText.Text = type;
			form.exceptionView.Text = stacktrace;
			form.btnContinue.Enabled = !isUnhandled;
			form.chkBreakOnHandled.Visible = !isUnhandled;
			form.chkBreakOnHandled.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.BreakOnHandled}", new StringTagPair("ExceptionName", exceptionType));
			form.chkBreakOnHandled.Checked = true;
			
			// Showing the form as dialg seems like a resonable thing in the presence of potentially multiple
			// concurent debugger evetns
			form.ShowDialog(SD.WinForms.MainWin32Window);
			
			return form.Break;
		}
        public static bool Show(Process process, string exceptionType, string stacktrace, bool isUnhandled)
        {
            DebuggeeExceptionForm form = new DebuggeeExceptionForm(process, exceptionType);
            string type = string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Message}"), exceptionType);
            Bitmap icon = WinFormsResourceService.GetBitmap(isUnhandled ? "Icons.32x32.Error" : "Icons.32x32.Warning");

            form.Text                      = isUnhandled ? StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Unhandled}") : StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Handled}");
            form.pictureBox.Image          = icon;
            form.lblExceptionText.Text     = type;
            form.exceptionView.Text        = stacktrace;
            form.btnContinue.Enabled       = !isUnhandled;
            form.chkBreakOnHandled.Visible = !isUnhandled;
            form.chkBreakOnHandled.Text    = StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.BreakOnHandled}", new StringTagPair("ExceptionName", exceptionType));
            form.chkBreakOnHandled.Checked = true;

            // Showing the form as dialg seems like a resonable thing in the presence of potentially multiple
            // concurent debugger evetns
            form.ShowDialog(SD.WinForms.MainWin32Window);

            return(form.Break);
        }
        void debuggedProcess_ExceptionThrown(object sender, ExceptionEventArgs e)
        {
            JumpToCurrentLine();

            StringBuilder stacktraceBuilder = new StringBuilder();

            if (e.IsUnhandled)
            {
                // Need to intercept now so that we can evaluate properties
                if (e.Process.SelectedThread.InterceptException(e.Exception))
                {
                    stacktraceBuilder.AppendLine(e.Exception.ToString());
                    string stackTrace;
                    try {
                        stackTrace = e.Exception.GetStackTrace(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.EndOfInnerException}"));
                    } catch (GetValueException) {
                        stackTrace = e.Process.SelectedThread.GetStackTrace(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.Symbols}"), StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.NoSymbols}"));
                    }
                    stacktraceBuilder.Append(stackTrace);
                }
                else
                {
                    // For example, happens on stack overflow
                    stacktraceBuilder.AppendLine(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Error.CannotInterceptException}"));
                    stacktraceBuilder.AppendLine(e.Exception.ToString());
                    stacktraceBuilder.Append(e.Process.SelectedThread.GetStackTrace(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.Symbols}"), StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.NoSymbols}")));
                }
            }
            else
            {
                stacktraceBuilder.AppendLine(e.Exception.ToString());
                stacktraceBuilder.Append(e.Process.SelectedThread.GetStackTrace(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.Symbols}"), StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.NoSymbols}")));
            }

            string title   = e.IsUnhandled ? StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Unhandled}") : StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Handled}");
            string message = string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Message}"), e.Exception.Type);
            Bitmap icon    = WinFormsResourceService.GetBitmap(e.IsUnhandled ? "Icons.32x32.Error" : "Icons.32x32.Warning");

            DebuggeeExceptionForm.Show(debuggedProcess, title, message, stacktraceBuilder.ToString(), icon, e.IsUnhandled, e.Exception);
        }
예제 #10
0
        void debuggedProcess_DebuggingPaused(object sender, DebuggerPausedEventArgs e)
        {
            OnIsProcessRunningChanged(EventArgs.Empty);

            CurrentProcess = e.Process;
            if (e.Thread != null)
            {
                CurrentThread = e.Thread;
            }
            else if (CurrentThread != null && CurrentThread.HasExited)
            {
                CurrentThread = null;
            }
            CurrentStackFrame = CurrentThread != null ? CurrentThread.MostRecentStackFrame : null;

            // We can have several events happening at the same time
            bool breakProcess = e.Break;

            // Handle thrown exceptions
            foreach (Thread exceptionThread in e.ExceptionsThrown)
            {
                JumpToCurrentLine();

                Thread evalThread = exceptionThread;

                bool         isUnhandled     = (exceptionThread.CurrentExceptionType == ExceptionType.Unhandled);
                Value        exception       = exceptionThread.CurrentException.GetPermanentReferenceOfHeapValue();
                List <Value> innerExceptions = new List <Value>();
                for (Value innerException = exception; !innerException.IsNull; innerException = innerException.GetFieldValue("_innerException"))
                {
                    innerExceptions.Add(innerException.GetPermanentReferenceOfHeapValue());
                }

                // Get the exception description
                string stacktrace = string.Empty;
                for (int i = 0; i < innerExceptions.Count; i++)
                {
                    if (i > 0)
                    {
                        stacktrace += " ---> ";
                    }
                    stacktrace += innerExceptions[i].Type.FullName;
                    Value messageValue = innerExceptions[i].GetFieldValue("_message");
                    if (!messageValue.IsNull)
                    {
                        stacktrace += ": " + messageValue.AsString();
                    }
                }
                stacktrace += Environment.NewLine + Environment.NewLine;

                // Get the stacktrace
                string formatSymbols   = StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.Symbols}");
                string formatNoSymbols = StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.NoSymbols}");
                if (isUnhandled)
                {
                    // Need to intercept now so that we can evaluate properties
                    // Intercept may fail (eg StackOverflow)
                    if (exceptionThread.InterceptException())
                    {
                        try {
                            // Try to evaluate the StackTrace property to get the .NET formated stacktrace
                            for (int i = innerExceptions.Count - 1; i >= 0; i--)
                            {
                                Value stackTraceValue = innerExceptions[i].GetPropertyValue(evalThread, "StackTrace");
                                if (!stackTraceValue.IsNull)
                                {
                                    stacktrace += stackTraceValue.AsString() + Environment.NewLine;
                                }
                                if (i > 0)
                                {
                                    stacktrace += "   " + StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.LineFormat.EndOfInnerException}") + Environment.NewLine;
                                }
                            }
                        } catch (GetValueException) {
                            stacktrace += exceptionThread.GetStackTrace(formatSymbols, formatNoSymbols);
                        }
                    }
                    else
                    {
                        stacktrace += StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Error.CannotInterceptException}") + Environment.NewLine + Environment.NewLine;
                        stacktrace += exceptionThread.GetStackTrace(formatSymbols, formatNoSymbols);
                    }
                }
                else
                {
                    // Do not intercept handled expetions
                    stacktrace += exceptionThread.GetStackTrace(formatSymbols, formatNoSymbols);
                }

                string title = isUnhandled ? StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Unhandled}") : StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Title.Handled}");
                string type  = string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.ExceptionForm.Message}"), exception.Type);
                Bitmap icon  = WinFormsResourceService.GetBitmap(isUnhandled ? "Icons.32x32.Error" : "Icons.32x32.Warning");

                if (DebuggeeExceptionForm.Show(e.Process, title, type, stacktrace, icon, isUnhandled))
                {
                    breakProcess = true;
                    // The dialog box is allowed to kill the process
                    if (e.Process.HasExited)
                    {
                        return;
                    }
                    // Intercept handled exception *after* the user decided to break
                    if (!isUnhandled)
                    {
                        if (!exceptionThread.InterceptException())
                        {
                            MessageService.ShowError("${res:MainWindow.Windows.Debug.ExceptionForm.Error.CannotInterceptHandledException}");
                        }
                    }
                }
            }

            // Handle breakpoints
            foreach (Breakpoint breakpoint in e.BreakpointsHit)
            {
                var bookmark = SD.BookmarkManager.Bookmarks.OfType <BreakpointBookmark>().First(bm => bm.InternalBreakpointObject == breakpoint);

                if (string.IsNullOrEmpty(bookmark.Condition))
                {
                    breakProcess = true;
                }
                else
                {
                    if (EvaluateCondition(bookmark.Condition))
                    {
                        breakProcess = true;
                        BaseDebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition));
                    }
                }
            }

            if (breakProcess)
            {
                JumpToCurrentLine();
                RefreshPads();
            }
            else
            {
                e.Process.AsyncContinue();
            }
        }