From f300c7cc0bafbbb0680e458d346aa5c94817a94c Mon Sep 17 00:00:00 2001 From: Justin Dearing Date: Tue, 29 Apr 2008 17:18:35 +0000 Subject: [PATCH] Exposing InnerException data in the Debugger.Exception class via a new Debugger.DebuggerInnerException class. I am not exposing this to the user yet. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3044 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Debugger.Core.csproj | 1 + .../Project/Src/Debugger/Exception.cs | 27 ++++++++ .../Project/Src/Debugger/InnerException.cs | 68 +++++++++++++++++++ .../Project/Src/Internal/ManagedCallback.cs | 2 +- 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj index c0d38c2e5f..9ea8a1113e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -60,6 +60,7 @@ + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs index 1f2a16f349..273cae06a2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs @@ -13,6 +13,13 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { + /// + /// This class contains data from an Exception throw by an application + /// being debugged. Since the System.Exception object being thrown + /// lives in the debugged application and not in debugger, this class is + /// neccessary. + /// + /// public class Exception: DebuggerObject { Thread thread; @@ -43,12 +50,32 @@ namespace Debugger } } + + /// + /// The GetType().FullName of the exception. + /// + /// public string Type { get { return this.RuntimeValue.Type.FullName; } } + /// + /// The InnerException property of the exception. + /// + /// + public DebuggerInnerException InnerException { + get { + Debugger.Value exVal = this.RuntimeValue.GetMemberValue("_innerException"); + return (exVal.IsNull) ? null : new DebuggerInnerException(exVal); + } + } + + /// + /// The Message property of the exception. + /// + /// public string Message { get { return this.RuntimeValue.GetMemberValue("_message").AsString; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs new file mode 100644 index 0000000000..8132b1ae8a --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs @@ -0,0 +1,68 @@ +// +// +// +// +// $Revision: 2900 $ +// + +using System.Text; +using Debugger.Wrappers.CorDebug; + +namespace Debugger +{ + /// + /// This contains the nested InnerExceptions of a Debugger.Exception class + /// + /// + /// + public class DebuggerInnerException + { + Debugger.Value exceptionValue; + + internal DebuggerInnerException (Debugger.Value exception) { + this.exceptionValue = exception; + } + + /// + /// The InnerException property of the exception. + /// + /// + public DebuggerInnerException InnerException { + get { + Debugger.Value exVal = this.exceptionValue.GetMemberValue("_innerException"); + return (exVal.IsNull) ? null : new DebuggerInnerException(exVal); + } + } + + /// + /// The Message property of the exception. + /// + /// + public string Message { + get { + return this.exceptionValue.GetMemberValue("_message").AsString; + } + } + + /// + /// The GetType().FullName of the exception. + /// + /// + public string Type { + get { + return this.exceptionValue.Type.FullName; + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Type: {0}", this.Type); + sb.AppendLine(); + sb.AppendLine("Message:"); + sb.Append(this.Message); + + return sb.ToString(); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs index 3a2717cef2..c9fe4c4359 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs @@ -459,7 +459,7 @@ namespace Debugger EnterCallback(PausedReason.Exception, "Exception2 (type=" + exceptionType.ToString() + ")", pThread); // This callback is also called from Exception(...)!!!! (the .NET 1.1 version) - // Whatch out for the zeros and null! + // Watch out for the zeros and null! // Exception -> Exception2(pAppDomain, pThread, null, 0, exceptionType, 0); process.SelectedThread.CurrentException = new Exception(process.SelectedThread, (ExceptionType)exceptionType);