[mono/mono] 4e6c494b: [sdb] Add an IncludeSubclasses property to ExceptionEventRequest, to control whenever to include subclasses of the exception type. Fixes #15541

"Zoltan Varga ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141dee38480-2704dbe6-aa47-4887-b566-fad30fd3e509-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/64eff753bdeb...4e6c494b3066

   Commit: 4e6c494b306682cc6ed21dcca175aabd6463f947
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-10-22 06:38:07 GMT
      URL: https://github.com/mono/mono/commit/4e6c494b306682cc6ed21dcca175aabd6463f947

[sdb] Add an IncludeSubclasses property to ExceptionEventRequest, to control whenever to include subclasses of the exception type. Fixes #15541

Changed paths:
  M mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
  M mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ExceptionEventRequest.cs
  M mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
  M mcs/class/Mono.Debugger.Soft/Test/dtest.cs
  M mono/mini/debugger-agent.c

Modified: mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
===================================================================
@@ -285,6 +285,9 @@ class ExceptionModifier : Modifier {
 		public bool Uncaught {
 			get; set;
 		}
+		public bool Subclasses {
+			get; set;
+		}
 	}
 
 	class AssemblyModifier : Modifier {
@@ -395,7 +398,7 @@ public abstract class Connection
 		 * with newer runtimes, and vice versa.
 		 */
 		internal const int MAJOR_VERSION = 2;
-		internal const int MINOR_VERSION = 24;
+		internal const int MINOR_VERSION = 25;
 
 		enum WPSuspendPolicy {
 			NONE = 0,
@@ -2174,6 +2177,11 @@ internal void SetSocketTimeouts (int send_timeout, int receive_timeout, int keep
 						} else if (!em.Caught || !em.Uncaught) {
 							throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
 						}
+						if (Version.MajorVersion > 2 || Version.MinorVersion > 24) {
+							w.WriteBool (em.Subclasses);
+						} else if (!em.Subclasses) {
+							throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
+						}
 					} else if (mod is AssemblyModifier) {
 						w.WriteByte ((byte)ModifierKind.ASSEMBLY_ONLY);
 						var amod = (mod as AssemblyModifier);

Modified: mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ExceptionEventRequest.cs
===================================================================
@@ -6,7 +6,7 @@ namespace Mono.Debugger.Soft
 	public sealed class ExceptionEventRequest : EventRequest {
 
 		TypeMirror exc_type;
-		bool caught, uncaught;
+		bool caught, uncaught, subclasses;
 		
 		internal ExceptionEventRequest (VirtualMachine vm, TypeMirror exc_type, bool caught, bool uncaught) : base (vm, EventType.Exception) {
 			if (exc_type != null) {
@@ -18,6 +18,7 @@ public sealed class ExceptionEventRequest : EventRequest {
 			this.exc_type = exc_type;
 			this.caught = caught;
 			this.uncaught = uncaught;
+			this.subclasses = true;
 		}
 
 		public TypeMirror ExceptionType {
@@ -26,9 +27,21 @@ public sealed class ExceptionEventRequest : EventRequest {
 			}
 		}
 
+		// Defaults to true
+		// Supported since protocol version 2.25
+		public bool IncludeSubclasses {
+			get {
+				return subclasses;
+			}
+			set {
+				vm.CheckProtocolVersion (2, 25);
+				subclasses = value;
+			}
+		}
+
 		public override void Enable () {
 			var mods = new List <Modifier> ();
-			mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught });
+			mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught, Subclasses = subclasses });
 			SendReq (mods);
 		}
 	}

Modified: mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
===================================================================
@@ -869,6 +869,15 @@ class Class3 {
 			throw new OverflowException ();
 		} catch (Exception) {
 		}
+		// no subclasses
+		try {
+			throw new OverflowException ();
+		} catch (Exception) {
+		}
+		try {
+			throw new Exception ();
+		} catch (Exception) {
+		}
 
 		object o = null;
 		try {

Modified: mcs/class/Mono.Debugger.Soft/Test/dtest.cs
===================================================================
@@ -2503,6 +2503,17 @@ public class DebuggerTests
 		Assert.AreEqual ("OverflowException", (e as ExceptionEvent).Exception.Type.Name);
 		req.Disable ();
 
+		// no subclasses
+		req.IncludeSubclasses = false;
+		req.Enable ();
+
+		vm.Resume ();
+
+		e = GetNextEvent ();
+		Assert.IsInstanceOfType (typeof (ExceptionEvent), e);
+		Assert.AreEqual ("Exception", (e as ExceptionEvent).Exception.Type.Name);
+		req.Disable ();
+
 		// Implicit exceptions
 		req = vm.CreateExceptionRequest (null);
 		req.Enable ();

Modified: mono/mini/debugger-agent.c
===================================================================
@@ -283,7 +283,7 @@ struct _InvokeData
 #define HEADER_LENGTH 11
 
 #define MAJOR_VERSION 2
-#define MINOR_VERSION 24
+#define MINOR_VERSION 25
 
 typedef enum {
 	CMD_SET_VM = 1,
@@ -528,7 +528,7 @@ struct _InvokeData
 		GHashTable *type_names; /* For kind == MONO_KIND_TYPE_NAME_ONLY */
 		StepFilter filter; /* For kind == MOD_KIND_STEP */
 	} data;
-	gboolean caught, uncaught; /* For kind == MOD_KIND_EXCEPTION_ONLY */
+	gboolean caught, uncaught, subclasses; /* For kind == MOD_KIND_EXCEPTION_ONLY */
 } Modifier;
 
 typedef struct{
@@ -3363,7 +3363,9 @@ static void CALLBACK notify_thread_apc (ULONG_PTR param)
 					if (mod->data.thread != mono_thread_internal_current ())
 						filtered = TRUE;
 				} else if (mod->kind == MOD_KIND_EXCEPTION_ONLY && ei) {
-					if (mod->data.exc_class && !mono_class_is_assignable_from (mod->data.exc_class, ei->exc->vtable->klass))
+					if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, ei->exc->vtable->klass))
+						filtered = TRUE;
+					if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != ei->exc->vtable->klass)
 						filtered = TRUE;
 					if (ei->caught && !mod->caught)
 						filtered = TRUE;
@@ -6993,7 +6995,11 @@ static void CALLBACK notify_thread_apc (ULONG_PTR param)
 					return err;
 				req->modifiers [i].caught = decode_byte (p, &p, end);
 				req->modifiers [i].uncaught = decode_byte (p, &p, end);
-				DEBUG(1, fprintf (log_file, "[dbg] \tEXCEPTION_ONLY filter (%s%s%s).\n", exc_class ? exc_class->name : "all", req->modifiers [i].caught ? ", caught" : "", req->modifiers [i].uncaught ? ", uncaught" : ""));
+				if (CHECK_PROTOCOL_VERSION (2, 25))
+					req->modifiers [i].subclasses = decode_byte (p, &p, end);
+				else
+					req->modifiers [i].subclasses = TRUE;
+				DEBUG(1, fprintf (log_file, "[dbg] \tEXCEPTION_ONLY filter (%s%s%s%s).\n", exc_class ? exc_class->name : "all", req->modifiers [i].caught ? ", caught" : "", req->modifiers [i].uncaught ? ", uncaught" : "", req->modifiers [i].subclasses ? ", include-subclasses" : ""));
 				if (exc_class) {
 					req->modifiers [i].data.exc_class = exc_class;
 


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.