Browse Source

fix #549: Breaking on all but one exception type does not work as expected

pull/517/head
Siegfried Pammer 11 years ago
parent
commit
e97402bb4d
  1. 5
      data/resources/StringResources.resx
  2. 29
      src/AddIns/Debugger/Debugger.AddIn/Service/DebuggeeExceptionForm.Designer.cs
  3. 32
      src/AddIns/Debugger/Debugger.AddIn/Service/DebuggeeExceptionForm.cs
  4. 6
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  5. 17
      src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs

5
data/resources/StringResources.resx

@ -8211,9 +8211,12 @@ a line break</value> @@ -8211,9 +8211,12 @@ a line break</value>
<value>Break on</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ExceptionFilter.ColumnExpression" xml:space="preserve">
<value>Exception name expression (wildcards are allowed)</value>
<value>Full exception name</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ChooseExceptions" xml:space="preserve">
<value>Choose exceptions</value>
</data>
<data name="MainWindow.Windows.Debug.ExceptionForm.BreakOnHandled" xml:space="preserve">
<value>Break on handled ${ExceptionName}</value>
</data>
</root>

29
src/AddIns/Debugger/Debugger.AddIn/Service/DebuggeeExceptionForm.Designer.cs generated

@ -37,6 +37,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -37,6 +37,7 @@ namespace ICSharpCode.SharpDevelop.Services
this.btnStop = new System.Windows.Forms.Button();
this.btnBreak = new System.Windows.Forms.Button();
this.btnContinue = new System.Windows.Forms.Button();
this.chkBreakOnHandled = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
@ -45,9 +46,9 @@ namespace ICSharpCode.SharpDevelop.Services @@ -45,9 +46,9 @@ namespace ICSharpCode.SharpDevelop.Services
this.pictureBox.Location = new System.Drawing.Point(4, 12);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(48, 52);
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
//
// lblExceptionText
//
@ -69,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -69,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Services
this.exceptionView.Location = new System.Drawing.Point(4, 70);
this.exceptionView.Name = "exceptionView";
this.exceptionView.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth;
this.exceptionView.Size = new System.Drawing.Size(635, 290);
this.exceptionView.Size = new System.Drawing.Size(635, 283);
this.exceptionView.TabIndex = 2;
this.exceptionView.Text = "";
//
@ -77,7 +78,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -77,7 +78,7 @@ namespace ICSharpCode.SharpDevelop.Services
//
this.btnStop.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnStop.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnStop.Location = new System.Drawing.Point(385, 366);
this.btnStop.Location = new System.Drawing.Point(385, 380);
this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(115, 30);
this.btnStop.TabIndex = 3;
@ -90,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -90,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.Services
//
this.btnBreak.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnBreak.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnBreak.Location = new System.Drawing.Point(143, 366);
this.btnBreak.Location = new System.Drawing.Point(143, 380);
this.btnBreak.Name = "btnBreak";
this.btnBreak.Size = new System.Drawing.Size(115, 30);
this.btnBreak.TabIndex = 4;
@ -103,7 +104,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -103,7 +104,7 @@ namespace ICSharpCode.SharpDevelop.Services
//
this.btnContinue.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnContinue.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnContinue.Location = new System.Drawing.Point(264, 366);
this.btnContinue.Location = new System.Drawing.Point(264, 380);
this.btnContinue.Name = "btnContinue";
this.btnContinue.Size = new System.Drawing.Size(115, 30);
this.btnContinue.TabIndex = 5;
@ -112,11 +113,23 @@ namespace ICSharpCode.SharpDevelop.Services @@ -112,11 +113,23 @@ namespace ICSharpCode.SharpDevelop.Services
this.btnContinue.UseVisualStyleBackColor = true;
this.btnContinue.Click += new System.EventHandler(this.BtnContinueClick);
//
// chkBreakOnHandled
//
this.chkBreakOnHandled.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.chkBreakOnHandled.Location = new System.Drawing.Point(4, 350);
this.chkBreakOnHandled.Name = "chkBreakOnHandled";
this.chkBreakOnHandled.Size = new System.Drawing.Size(635, 24);
this.chkBreakOnHandled.TabIndex = 6;
this.chkBreakOnHandled.Text = "checkBox1";
this.chkBreakOnHandled.UseVisualStyleBackColor = true;
//
// DebuggeeExceptionForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(642, 399);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(642, 413);
this.Controls.Add(this.chkBreakOnHandled);
this.Controls.Add(this.btnContinue);
this.Controls.Add(this.btnBreak);
this.Controls.Add(this.btnStop);
@ -128,6 +141,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -128,6 +141,7 @@ namespace ICSharpCode.SharpDevelop.Services
this.Resize += new System.EventHandler(this.FormResize);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
private System.Windows.Forms.Button btnContinue;
private System.Windows.Forms.Button btnBreak;
@ -135,6 +149,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -135,6 +149,7 @@ namespace ICSharpCode.SharpDevelop.Services
private System.Windows.Forms.RichTextBox exceptionView;
private System.Windows.Forms.Label lblExceptionText;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.CheckBox chkBreakOnHandled;
#endregion
}

32
src/AddIns/Debugger/Debugger.AddIn/Service/DebuggeeExceptionForm.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Debugger;
using ICSharpCode.Core;
@ -30,16 +31,18 @@ namespace ICSharpCode.SharpDevelop.Services @@ -30,16 +31,18 @@ namespace ICSharpCode.SharpDevelop.Services
internal sealed partial class DebuggeeExceptionForm
{
Process process;
string exceptionType;
public bool Break { get; set; }
DebuggeeExceptionForm(Process process)
DebuggeeExceptionForm(Process process, string exceptionType)
{
InitializeComponent();
this.Break = true;
this.process = process;
this.exceptionType = exceptionType;
this.process.Exited += ProcessHandler;
this.process.Resumed += ProcessHandler;
@ -75,14 +78,20 @@ namespace ICSharpCode.SharpDevelop.Services @@ -75,14 +78,20 @@ namespace ICSharpCode.SharpDevelop.Services
this.process.Resumed -= ProcessHandler;
}
public static bool Show(Process process, string title, string type, string stacktrace, Bitmap icon, bool isUnhandled)
public static bool Show(Process process, string exceptionType, string stacktrace, bool isUnhandled)
{
DebuggeeExceptionForm form = new DebuggeeExceptionForm(process);
form.Text = title;
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
@ -91,6 +100,21 @@ namespace ICSharpCode.SharpDevelop.Services @@ -91,6 +100,21 @@ namespace ICSharpCode.SharpDevelop.Services
return form.Break;
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
if (chkBreakOnHandled.Visible && !chkBreakOnHandled.Checked) {
var list = process.Debugger.Options.ExceptionFilterList.ToList();
var entry = list.FirstOrDefault(item => item.Expression.Equals(exceptionType, StringComparison.OrdinalIgnoreCase));
if (entry == null) {
list.Add(new ExceptionFilterEntry(exceptionType) { IsActive = false });
} else {
entry.IsActive = false;
}
process.Debugger.Options.ExceptionFilterList = list;
}
base.OnClosing(e);
}
void ExceptionViewDoubleClick(object sender, EventArgs e)
{
string fullText = exceptionView.Text;

6
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

@ -534,11 +534,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -534,11 +534,7 @@ namespace ICSharpCode.SharpDevelop.Services
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)) {
if (DebuggeeExceptionForm.Show(e.Process, exception.Type.FullName, stacktrace, isUnhandled)) {
breakProcess = true;
// The dialog box is allowed to kill the process
if (e.Process.HasExited) {

17
src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs

@ -557,7 +557,7 @@ namespace Debugger @@ -557,7 +557,7 @@ namespace Debugger
ExitCallback();
}
Regex filterRegex;
Dictionary<string, bool> exceptionFilter;
static string ConvertWildcardsToRegex(string searchPattern)
{
@ -587,17 +587,18 @@ namespace Debugger @@ -587,17 +587,18 @@ namespace Debugger
{
IType exceptionType = thread.CurrentException.Type;
if (filterRegex == null) {
var exceptionFilterList = thread.Process.Options.ExceptionFilterList.Where(i => i.IsActive).Select(s => "(" + ConvertWildcardsToRegex(s.Expression) + ")");
filterRegex = new Regex(string.Join("|", exceptionFilterList), RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
if (exceptionFilter == null) {
exceptionFilter = thread.Process.Options.ExceptionFilterList
.ToDictionary(e => e.Expression, e => e.IsActive, StringComparer.OrdinalIgnoreCase);
}
foreach (var baseType in exceptionType.GetNonInterfaceBaseTypes()) {
if (filterRegex.IsMatch(baseType.ReflectionName))
return true;
foreach (var baseType in exceptionType.GetNonInterfaceBaseTypes().Reverse()) {
bool isActive;
if (exceptionFilter.TryGetValue(baseType.ReflectionName, out isActive))
return isActive;
}
return false;
return true;
}
public void ExceptionUnwind(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)

Loading…
Cancel
Save