[sdb] Add a Domain property to AssemblyMirror. (#4309)
authorZoltan Varga <vargaz@gmail.com>
Wed, 1 Feb 2017 17:45:38 +0000 (12:45 -0500)
committerGitHub <noreply@github.com>
Wed, 1 Feb 2017 17:45:38 +0000 (12:45 -0500)
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/AssemblyMirror.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mono/mini/debugger-agent.c

index 9b0af4c77d2d6aa0f09a12aaa2d7dacfa2ef586c..a83daab43cbfee31f48ab8f5654f196a791b03ca 100644 (file)
@@ -14,6 +14,7 @@ namespace Mono.Debugger.Soft
                ModuleMirror main_module;
                AssemblyName aname;
                AssemblyDefinition meta;
+               AppDomainMirror domain;
                Dictionary<string, long> typeCacheIgnoreCase = new Dictionary<string, long> (StringComparer.InvariantCultureIgnoreCase);
                Dictionary<string, long> typeCache = new Dictionary<string, long> ();
 
@@ -50,6 +51,17 @@ namespace Mono.Debugger.Soft
                        }
                }
 
+               // Since Protocol version 2.45
+               public AppDomainMirror Domain {
+                       get {
+                               if (domain == null) {
+                                       vm.CheckProtocolVersion (2, 45);
+                                       domain = vm.GetDomain (vm.conn.Assembly_GetIdDomain (id));
+                               }
+                               return domain;
+                       }
+               }
+
                public virtual AssemblyName GetName () {
                        if (aname == null) {
                                string name = vm.conn.Assembly_GetName (id);
index 3a1af2dc08861aba4cce94d7e7fafc0146460749..e09132e27985b8c67eb2f725f4bdb5f120c1b7b9 100644 (file)
@@ -420,7 +420,7 @@ namespace Mono.Debugger.Soft
                 * with newer runtimes, and vice versa.
                 */
                internal const int MAJOR_VERSION = 2;
-               internal const int MINOR_VERSION = 44;
+               internal const int MINOR_VERSION = 45;
 
                enum WPSuspendPolicy {
                        NONE = 0,
@@ -532,7 +532,8 @@ namespace Mono.Debugger.Soft
                        GET_MANIFEST_MODULE = 3,
                        GET_OBJECT = 4,
                        GET_TYPE = 5,
-                       GET_NAME = 6
+                       GET_NAME = 6,
+                       GET_DOMAIN = 7
                }
 
                enum CmdModule {
@@ -2114,6 +2115,10 @@ namespace Mono.Debugger.Soft
                        return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
                }
 
+               internal long Assembly_GetIdDomain (long id) {
+                       return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_DOMAIN, new PacketWriter ().WriteId (id)).ReadId ();
+               }
+
                /*
                 * TYPE
                 */
index ce74b4fd5fb3f5852c1c1aa2679e72c8af45b364..61b3e31088102e4ffffb6bdae168636c1356d2de 100644 (file)
@@ -3490,6 +3490,7 @@ public class DebuggerTests
                // d_method is from another domain
                MethodMirror d_method = (e as BreakpointEvent).Method;
                Assert.IsTrue (m != d_method);
+               Assert.AreEqual (domain, d_method.DeclaringType.Assembly.Domain);
 
                var frames = e.Thread.GetFrames ();
                Assert.AreEqual ("invoke_in_domain", frames [0].Method.Name);
index 7b0b052f4503743808c91874901a3e239398ae27..518216b41d2835c60dd4fd173a7a6eba12e40728 100644 (file)
@@ -273,7 +273,7 @@ typedef struct {
 #define HEADER_LENGTH 11
 
 #define MAJOR_VERSION 2
-#define MINOR_VERSION 44
+#define MINOR_VERSION 45
 
 typedef enum {
        CMD_SET_VM = 1,
@@ -450,7 +450,8 @@ typedef enum {
        CMD_ASSEMBLY_GET_MANIFEST_MODULE = 3,
        CMD_ASSEMBLY_GET_OBJECT = 4,
        CMD_ASSEMBLY_GET_TYPE = 5,
-       CMD_ASSEMBLY_GET_NAME = 6
+       CMD_ASSEMBLY_GET_NAME = 6,
+       CMD_ASSEMBLY_GET_DOMAIN = 7
 } CmdAssembly;
 
 typedef enum {
@@ -8041,6 +8042,10 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                mono_error_cleanup (&error);
                return err;
        }
+       case CMD_ASSEMBLY_GET_DOMAIN: {
+               buffer_add_domainid (buf, domain);
+               break;
+       }
        case CMD_ASSEMBLY_GET_TYPE: {
                MonoError error;
                char *s = decode_string (p, &p, end);
@@ -9901,7 +9906,8 @@ static const char* assembly_cmds_str[] = {
        "GET_MANIFEST_MODULE",
        "GET_OBJECT",
        "GET_TYPE",
-       "GET_NAME"
+       "GET_NAME",
+       "GET_DOMAIN"
 };
 
 static const char* module_cmds_str[] = {