Hey,

Please review attached patch implementing Diagnostics.Debugger.IsAttached.

Cheers,
diff --git mcs/class/corlib/System.Diagnostics/Debugger.cs mcs/class/corlib/System.Diagnostics/Debugger.cs
index a7ab642..d8eed62 100644
--- mcs/class/corlib/System.Diagnostics/Debugger.cs
+++ mcs/class/corlib/System.Diagnostics/Debugger.cs
@@ -30,6 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using System.Runtime.CompilerServices;
 
 #if NET_2_0
 using System.Runtime.InteropServices;
@@ -46,13 +47,12 @@ namespace System.Diagnostics
 	[MonoTODO ("The Debugger class is not functional")]
 	public sealed class Debugger
 	{
-		private static bool isAttached;
-		
+
 		/// <summary>
 		/// Represents the default category of a message with a constant.
 		/// </summary>
 		public static readonly string DefaultCategory = "";
-		
+
 		/// <summary>
 		/// Returns a Boolean indicating whether a debugger is attached to a process.
 		/// </summary>
@@ -63,10 +63,13 @@ namespace System.Diagnostics
 		{
 			get
 			{
-				return isAttached;
+				return IsAttached_internal ();
 			}
 		}
-		
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		private extern static bool IsAttached_internal ();
+
 		/// <summary>
 		/// Causes a breakpoint to be signaled to an attached debugger.
 		/// </summary>
@@ -74,7 +77,7 @@ namespace System.Diagnostics
 		{
 			// The JIT inserts a breakpoint on the caller.
 		}
-		
+
 		/// <summary>
 		/// Checks to see if logging is enabled by an attached debugger.
 		/// </summary>
@@ -83,9 +86,8 @@ namespace System.Diagnostics
 			// Return false. DefaultTraceListener invokes this method, so throwing
 			// a NotImplementedException wouldn't be appropriate.
 			return false;
-
 		}
-		
+
 		/// <summary>
 		/// Launches and attaches a debugger to the process.
 		/// </summary>
@@ -94,7 +96,7 @@ namespace System.Diagnostics
 		{
 			throw new NotImplementedException();
 		}
-		
+
 		/// <summary>
 		/// Posts a message for the attached debugger.
 		/// </summary>
@@ -112,10 +114,10 @@ namespace System.Diagnostics
 			// Do nothing. DefaultTraceListener invokes this method, so throwing
 			// a NotImplementedException wouldn't be appropriate.
 		}
-		
+
 		public Debugger()
 		{
-			isAttached = false;
 		}
+
 	}
 }
diff --git mono/mono/metadata/icall-def.h mono/mono/metadata/icall-def.h
index a78ac7a..c032d93 100644
--- mono/mono/metadata/icall-def.h
+++ mono/mono/metadata/icall-def.h
@@ -163,6 +163,9 @@ ICALL_TYPE(DELEGATE, "System.Delegate", DELEGATE_1)
 ICALL(DELEGATE_1, "CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal)
 ICALL(DELEGATE_2, "SetMulticastInvoke", ves_icall_System_Delegate_SetMulticastInvoke)
 
+ICALL_TYPE(DEBUGR, "System.Diagnostics.Debugger", DEBUGR_1)
+ICALL(DEBUGR_1, "IsAttached_internal", ves_icall_System_Diagnostics_Debugger_IsAttached_internal)
+
 ICALL_TYPE(TRACEL, "System.Diagnostics.DefaultTraceListener", TRACEL_1)
 ICALL(TRACEL_1, "WriteWindowsDebugString", ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString)
 
diff --git mono/mono/metadata/icall.c mono/mono/metadata/icall.c
index 51aa9a5..81bad77 100644
--- mono/mono/metadata/icall.c
+++ mono/mono/metadata/icall.c
@@ -62,6 +62,7 @@
 #include <mono/metadata/security-manager.h>
 #include <mono/metadata/security-core-clr.h>
 #include <mono/metadata/mono-perfcounters.h>
+#include <mono/metadata/mono-debug.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/utils/strtod.h>
 #include <mono/utils/monobitset.h>
@@ -6862,6 +6863,12 @@ ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void)
 	return ipath;
 }
 
+static MonoBoolean
+ves_icall_System_Diagnostics_Debugger_IsAttached_internal (void)
+{
+	return mono_debug_using_mono_debugger ();
+}
+
 static void
 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message)
 {
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to