Author: martin
Date: 2006-11-10 10:55:36 -0500 (Fri, 10 Nov 2006)
New Revision: 67674

Modified:
   trunk/debugger/backend/ThreadManager.cs
   trunk/debugger/interface/AddressDomain.cs
   trunk/debugger/interface/TargetAddress.cs
Log:
Fix the AddressDomain madness.

Modified: trunk/debugger/backend/ThreadManager.cs
===================================================================
--- trunk/debugger/backend/ThreadManager.cs     2006-11-10 15:48:54 UTC (rev 
67673)
+++ trunk/debugger/backend/ThreadManager.cs     2006-11-10 15:55:36 UTC (rev 
67674)
@@ -19,8 +19,6 @@
        {
                public static TimeSpan WaitTimeout = TimeSpan.FromMilliseconds 
(5000);
 
-               static int next_addressdomain_id;
-
                internal ThreadManager (DebuggerServant backend)
                {
                        this.backend = backend;
@@ -29,7 +27,7 @@
                        engine_hash = Hashtable.Synchronized (new Hashtable ());
                        processes = ArrayList.Synchronized (new ArrayList ());
                        
-                       address_domain = new AddressDomain ("global", 
++next_addressdomain_id);
+                       address_domain = AddressDomain.Global;
 
                        command_mutex = new DebuggerMutex ("command_mutex");
                        command_mutex.DebugFlags = DebugFlags.Wait;

Modified: trunk/debugger/interface/AddressDomain.cs
===================================================================
--- trunk/debugger/interface/AddressDomain.cs   2006-11-10 15:48:54 UTC (rev 
67673)
+++ trunk/debugger/interface/AddressDomain.cs   2006-11-10 15:55:36 UTC (rev 
67674)
@@ -30,12 +30,8 @@
        //     stack frame, the address will also become invalid.
        //
        // </summary>
-       // <remarks>
-       //   This is intentionally a class and not a struct - we must always 
pass this by
-       //   reference and not by value.
-       // </remarks>
        [Serializable]
-       public sealed class AddressDomain
+       public struct AddressDomain : IComparable
        {
                // <summary>
                //   `name' is just used in the error messages.
@@ -46,6 +42,8 @@
                        this.name = name;
                }
 
+               public static readonly AddressDomain Global = new AddressDomain 
("global", 0);
+
                int id;
                string name;
 
@@ -57,6 +55,36 @@
                        get { return name; }
                }
 
+               public bool IsGlobal {
+                       get { return (id == 0) && (name == "global"); }
+               }
+
+               public int CompareTo (object obj)
+               {
+                       AddressDomain domain = (AddressDomain) obj;
+
+                       if (id < domain.id)
+                               return -1;
+                       else if (id > domain.id)
+                               return 1;
+                       else
+                               return 0;
+               }
+
+               public override bool Equals (object o)
+               {
+                       if (o == null || !(o is AddressDomain))
+                               return false;
+
+                       AddressDomain b = (AddressDomain) o;
+                       return (id == b.id) && (name == b.name);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return id;
+               }
+
                public override string ToString ()
                {
                        return String.Format ("AddressDomain ({0}:{1})", ID, 
Name);

Modified: trunk/debugger/interface/TargetAddress.cs
===================================================================
--- trunk/debugger/interface/TargetAddress.cs   2006-11-10 15:48:54 UTC (rev 
67673)
+++ trunk/debugger/interface/TargetAddress.cs   2006-11-10 15:55:36 UTC (rev 
67674)
@@ -28,7 +28,7 @@
                //   (TargetAddress.Null is in the null domain and comparision 
between
                //    different domains is not allowed).
                // </remarks>
-               public static TargetAddress Null = new TargetAddress (null, 0);
+               public static TargetAddress Null = new TargetAddress 
(AddressDomain.Global, 0);
 
                // <summary>
                //   This is not what it looks like.
@@ -69,7 +69,7 @@
                // </summary>
                public bool IsNull {
                        get {
-                               return (address == 0) && (domain == null);
+                               return (address == 0) && (domain.IsGlobal);
                        }
                }
 
@@ -89,7 +89,7 @@
 
                static void check_domains (TargetAddress a, TargetAddress b)
                {
-                       if (a.domain == b.domain)
+                       if (a.domain.Equals (b.domain))
                                return;
 
                        throw new ArgumentException (String.Format (

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to