From 026b3f41b51880530e740b3b0affb69372b1f3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sun, 24 Jul 2005 22:43:44 +0000 Subject: [PATCH] Bugfixing, handled exceptions handled faster git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@246 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Service/ExceptionForm.cs | 1 - .../Project/Src/Service/WindowsDebugger.cs | 6 ++-- .../Src/Debugger/Internal/ManagedCallback.cs | 28 +++++++++++++++---- .../Project/Src/Debugger/NDebugger.cs | 15 ++++++++-- .../PrivateEventHandlersSink/MyProxy.cs | 2 +- .../Project/Src/Threads/Function.cs | 10 ++++++- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs index d3b2ee26e2..2cebc8caa5 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/ExceptionForm.cs @@ -96,7 +96,6 @@ namespace ICSharpCode.SharpDevelop.Services // // ExceptionForm // - this.AutoScaleBaseSize = new System.Drawing.Size(7, 19); this.ClientSize = new System.Drawing.Size(638, 203); this.Controls.Add(this.label); this.Controls.Add(this.pictureBox); diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index f0797e250e..804deedcaa 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -338,8 +338,6 @@ namespace ICSharpCode.SharpDevelop.Services isProcessRunningCache = false; OnIsProcessRunningChanged(EventArgs.Empty); - JumpToCurrentLine(); - if (e.Reason == PausedReason.Exception) { exceptionHistory.Add(debugger.CurrentThread.CurrentException); OnExceptionHistoryModified(); @@ -348,6 +346,8 @@ namespace ICSharpCode.SharpDevelop.Services e.ResumeDebuggingAfterEvent(); return; } + + JumpToCurrentLine(); ExceptionForm form = new ExceptionForm(); form.label.Text = "Exception " + @@ -365,6 +365,8 @@ namespace ICSharpCode.SharpDevelop.Services case ExceptionForm.Result.Ignore: throw new NotImplementedException(); } + } else { + JumpToCurrentLine(); } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs index 9ac0be53ca..307cbf66c2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs @@ -93,9 +93,9 @@ namespace DebuggerLibrary } debugger.CurrentThread.DeactivateAllSteppers(); - debugger.OnDebuggingPaused(reason); - handlingCallback = false; + + debugger.OnDebuggingPaused(reason); } @@ -155,7 +155,7 @@ namespace DebuggerLibrary // Exception2 is used in .NET Framework 2.0 - ExitCallback_Paused(PausedReason.Exception); + ExitCallback_Continue(); } #endregion @@ -392,8 +392,18 @@ namespace DebuggerLibrary EnterCallback("Exception2", pThread); debugger.CurrentThread.CurrentExceptionType = (ExceptionType)dwEventType; - - ExitCallback_Paused(PausedReason.Exception); + + if (ExceptionType.DEBUG_EXCEPTION_UNHANDLED != (ExceptionType)dwEventType) { + // Handled exception + if (debugger.PauseOnHandledException) { + ExitCallback_Paused(PausedReason.Exception); + } else { + ExitCallback_Continue(); + } + } else { + // Unhandled exception + ExitCallback_Paused(PausedReason.Exception); + } } public void ExceptionUnwind(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags) @@ -419,7 +429,13 @@ namespace DebuggerLibrary public void MDANotification(ICorDebugController c, ICorDebugThread t, ICorDebugMDA mda) { - EnterCallback("MDANotification"); + if (c is ICorDebugAppDomain) { + EnterCallback("MDANotification", (ICorDebugAppDomain)c); + } else if (c is ICorDebugProcess){ + EnterCallback("MDANotification", (ICorDebugProcess)c); + } else { + throw new System.Exception("Unknown callback argument"); + } ExitCallback_Continue(); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs index c82a32b322..3122f20462 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs @@ -26,6 +26,8 @@ namespace DebuggerLibrary ApartmentState requiredApartmentState; EvalQueue evalQueue; + + bool pauseOnHandledException = false; internal EvalQueue EvalQueue { get { @@ -44,7 +46,16 @@ namespace DebuggerLibrary return corDebug; } } - + + public bool PauseOnHandledException { + get { + return pauseOnHandledException; + } + set { + pauseOnHandledException = value; + } + } + internal ManagedCallback ManagedCallback { get { return managedCallback; @@ -153,7 +164,7 @@ namespace DebuggerLibrary internal void TraceMessage(string message) { - Console.WriteLine("Trace:" + message); + System.Diagnostics.Debug.WriteLine("Debugger:" + message); OnDebuggerTraceMessage(message); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/RemotingSinks/PrivateEventHandlersSink/MyProxy.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/RemotingSinks/PrivateEventHandlersSink/MyProxy.cs index e38d6dfdb0..95f4a6e25d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/RemotingSinks/PrivateEventHandlersSink/MyProxy.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/RemotingSinks/PrivateEventHandlersSink/MyProxy.cs @@ -45,7 +45,7 @@ namespace CustomSinks try { RemotingServices.GetRealProxy(realObject).InitializeServerObject(ctorMsg); - } catch (Exception e) { + } catch { } ObjRef objRef = RemotingServices.Marshal(realObject); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs index 828e1e556d..f3c72455ba 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs @@ -108,7 +108,15 @@ namespace DebuggerLibrary internal ISymbolMethod symMethod { get { - return symReader.GetMethod(new SymbolToken((int)methodProps.Token)); + if (symReader == null) { + return null; + } else { + try { + return symReader.GetMethod(new SymbolToken((int)methodProps.Token)); + } catch { + return null; + } + } } }