Browse Source

Exception dialog uses TextBox and is bit more informative

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@248 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
b0f3900260
  1. 42
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs
  2. 17
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  4. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

42
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs

@ -7,6 +7,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core;
using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Services namespace ICSharpCode.SharpDevelop.Services
{ {
@ -14,20 +16,33 @@ namespace ICSharpCode.SharpDevelop.Services
{ {
public enum Result {Break, Continue, Ignore}; public enum Result {Break, Continue, Ignore};
public Result result = Result.Continue; private Result result = Result.Continue;
public System.Windows.Forms.Label label; private System.Windows.Forms.TextBox textBox;
private System.Windows.Forms.Button buttonContinue; private System.Windows.Forms.Button buttonContinue;
private System.Windows.Forms.Button buttonIgnore; private System.Windows.Forms.Button buttonIgnore;
public System.Windows.Forms.PictureBox pictureBox; private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button buttonBreak; private System.Windows.Forms.Button buttonBreak;
public ExceptionForm() private ExceptionForm()
{ {
InitializeComponent(); InitializeComponent();
} }
public static Result Show(DebuggerLibrary.Exception exception)
{
ExceptionForm form = new ExceptionForm();
form.textBox.Text = "Exception " +
exception.Type +
" was thrown in debugee:\r\n" +
exception.Message + "\r\n\r\n" +
exception.Callstack.Replace("\n","\r\n");
form.pictureBox.Image = ResourceService.GetBitmap((exception.ExceptionType != ExceptionType.DEBUG_EXCEPTION_UNHANDLED)?"Icons.32x32.Warning":"Icons.32x32.Error");
form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
return form.result;
}
#region Windows Forms Designer generated code #region Windows Forms Designer generated code
/// <summary> /// <summary>
/// This method is required for Windows Forms designer support. /// This method is required for Windows Forms designer support.
@ -39,7 +54,7 @@ namespace ICSharpCode.SharpDevelop.Services
this.pictureBox = new System.Windows.Forms.PictureBox(); this.pictureBox = new System.Windows.Forms.PictureBox();
this.buttonIgnore = new System.Windows.Forms.Button(); this.buttonIgnore = new System.Windows.Forms.Button();
this.buttonContinue = new System.Windows.Forms.Button(); this.buttonContinue = new System.Windows.Forms.Button();
this.label = new System.Windows.Forms.Label(); this.textBox = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -85,19 +100,22 @@ namespace ICSharpCode.SharpDevelop.Services
// //
// label // label
// //
this.label.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.label.Location = new System.Drawing.Point(91, 16); this.textBox.Location = new System.Drawing.Point(91, 16);
this.label.Name = "label"; this.textBox.Name = "textBox";
this.label.Size = new System.Drawing.Size(528, 144); this.textBox.Multiline = true;
this.label.TabIndex = 4; this.textBox.WordWrap = false;
this.label.Text = "label"; this.textBox.ReadOnly = true;
this.textBox.Size = new System.Drawing.Size(528, 138);
this.textBox.TabIndex = 4;
this.textBox.Text = "";
// //
// ExceptionForm // ExceptionForm
// //
this.ClientSize = new System.Drawing.Size(638, 203); this.ClientSize = new System.Drawing.Size(638, 203);
this.Controls.Add(this.label); this.Controls.Add(this.textBox);
this.Controls.Add(this.pictureBox); this.Controls.Add(this.pictureBox);
this.Controls.Add(this.buttonIgnore); this.Controls.Add(this.buttonIgnore);
this.Controls.Add(this.buttonContinue); this.Controls.Add(this.buttonContinue);

17
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -246,6 +246,7 @@ namespace ICSharpCode.SharpDevelop.Services
debugger = new NDebugger(); debugger = new NDebugger();
debugger.LogMessage += new EventHandler<MessageEventArgs>(LogMessage); debugger.LogMessage += new EventHandler<MessageEventArgs>(LogMessage);
debugger.DebuggerTraceMessage += new EventHandler<MessageEventArgs>(TraceMessage);
debugger.ProcessStarted += new EventHandler<ProcessEventArgs>(ProcessStarted); debugger.ProcessStarted += new EventHandler<ProcessEventArgs>(ProcessStarted);
debugger.ProcessExited += new EventHandler<ProcessEventArgs>(ProcessExited); debugger.ProcessExited += new EventHandler<ProcessEventArgs>(ProcessExited);
debugger.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(DebuggingPaused); debugger.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(DebuggingPaused);
@ -313,7 +314,12 @@ namespace ICSharpCode.SharpDevelop.Services
void LogMessage(object sender, MessageEventArgs e) void LogMessage(object sender, MessageEventArgs e)
{ {
DebuggerService.PrintDebugMessage(e.Message); DebuggerService.PrintDebugMessage(">" + e.Message);
}
void TraceMessage(object sender, MessageEventArgs e)
{
DebuggerService.PrintDebugMessage(e.Message + "\n");
} }
void ProcessStarted(object sender, ProcessEventArgs e) void ProcessStarted(object sender, ProcessEventArgs e)
@ -349,14 +355,7 @@ namespace ICSharpCode.SharpDevelop.Services
JumpToCurrentLine(); JumpToCurrentLine();
ExceptionForm form = new ExceptionForm(); switch (ExceptionForm.Show(debugger.CurrentThread.CurrentException)) {
form.label.Text = "Exception " +
debugger.CurrentThread.CurrentException.Type +
" was thrown in debugee:\n" +
debugger.CurrentThread.CurrentException.Message;
form.pictureBox.Image = ResourceService.GetBitmap((debugger.CurrentThread.CurrentException.ExceptionType != ExceptionType.DEBUG_EXCEPTION_UNHANDLED)?"Icons.32x32.Warning":"Icons.32x32.Error");
form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
switch (form.result) {
case ExceptionForm.Result.Break: case ExceptionForm.Result.Break:
break; break;
case ExceptionForm.Result.Continue: case ExceptionForm.Result.Continue:

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -144,7 +144,7 @@ namespace DebuggerLibrary
protected internal virtual void OnLogMessage(string message) protected internal virtual void OnLogMessage(string message)
{ {
TraceMessage ("Debugger event: OnLogMessage(\"" + message + "\")"); TraceMessage ("Debugger event: OnLogMessage");
if (LogMessage != null) { if (LogMessage != null) {
LogMessage(this, new MessageEventArgs(this, message)); LogMessage(this, new MessageEventArgs(this, message));
} }

20
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
@ -24,6 +25,7 @@ namespace DebuggerLibrary
ExceptionType exceptionType; ExceptionType exceptionType;
SourcecodeSegment location; SourcecodeSegment location;
DateTime creationTime; DateTime creationTime;
string callstack;
string type; string type;
string message; string message;
@ -47,7 +49,17 @@ namespace DebuggerLibrary
message = runtimeVariableException.SubVariables["_message"].Value.ToString(); message = runtimeVariableException.SubVariables["_message"].Value.ToString();
} }
location = thread.CurrentFunction.NextStatement; location = thread.LastFunctionWithLoadedSymbols.NextStatement;
callstack = "";
foreach(Function function in thread.Callstack) {
SourcecodeSegment loc = function.NextStatement;
callstack += function.Name + "()";
if (loc != null) {
callstack += " - " + loc.SourceFullFilename + ":" + loc.StartLine + "," + loc.StartColumn;
}
callstack += "\n";
}
type = runtimeVariable.Type; type = runtimeVariable.Type;
} }
@ -69,6 +81,12 @@ namespace DebuggerLibrary
} }
} }
public string Callstack {
get {
return callstack;
}
}
public ExceptionType ExceptionType{ public ExceptionType ExceptionType{
get { get {
return exceptionType; return exceptionType;

Loading…
Cancel
Save