Author: martin
Date: 2007-09-10 19:43:57 -0400 (Mon, 10 Sep 2007)
New Revision: 85613

Added:
   branches/martin/debugger-generics/languages/mono/MonoMethodFrameInfo.cs
   branches/martin/debugger-generics/languages/mono/MonoType.cs
Modified:
   branches/martin/debugger-generics/classes/StackFrame.cs
   branches/martin/debugger-generics/languages/mono/MonoGenericInst.cs
   branches/martin/debugger-generics/languages/mono/MonoGenericParameterType.cs
   branches/martin/debugger-generics/languages/mono/MonoSymbolFile.cs
Log:


Modified: branches/martin/debugger-generics/classes/StackFrame.cs
===================================================================
--- branches/martin/debugger-generics/classes/StackFrame.cs     2007-09-10 
22:53:55 UTC (rev 85612)
+++ branches/martin/debugger-generics/classes/StackFrame.cs     2007-09-10 
23:43:57 UTC (rev 85613)
@@ -359,6 +359,10 @@
                        get { return exc_object; }
                }
 
+               internal TargetMethodFrameInfo MethodFrameInfo {
+                       get { return method_frame_info; }
+               }
+
                internal void SetExceptionObject (TargetAddress exc)
                {
                        try {

Modified: branches/martin/debugger-generics/languages/mono/MonoGenericInst.cs
===================================================================
--- branches/martin/debugger-generics/languages/mono/MonoGenericInst.cs 
2007-09-10 22:53:55 UTC (rev 85612)
+++ branches/martin/debugger-generics/languages/mono/MonoGenericInst.cs 
2007-09-10 23:43:57 UTC (rev 85613)
@@ -9,7 +9,10 @@
 {
        internal class MonoGenericInst : DebuggerMarshalByRefObject
        {
-               public MonoGenericInst (TargetMemoryAccess memory, 
TargetAddress address)
+               public readonly TargetType[] Types;
+
+               public MonoGenericInst (MonoLanguageBackend mono, 
TargetMemoryAccess memory,
+                                       TargetAddress address)
                {
                        Console.WriteLine ("NEW GENERIC INST: {0}", address);
 
@@ -23,23 +26,12 @@
                        Console.WriteLine ("NEW GENERIC INST #2: {0:x} {1} {2}",
                                           header, type_argc, type_argv_ptr);
 
-                       TargetType[] type_argv = new TargetType [type_argc];
+                       Types = new TargetType [type_argc];
                        for (int i = 0; i < type_argc; i++) {
-                               type_argv [i] = read_type (memory, 
type_argv_ptr + i * addr_size);
-                               // Console.WriteLine ("NEW GENERIC INST #3: {0} 
{1}", i, type_argv [i]);
+                               TargetAddress ptr = memory.ReadAddress 
(type_argv_ptr + i * addr_size);
+                               Types [i] = MonoType.Read (mono, memory, ptr);
+                               Console.WriteLine ("NEW GENERIC INST #3: {0} 
{1}", i, Types [i]);
                        }
                }
-
-               static TargetType read_type (TargetMemoryAccess memory, 
TargetAddress address)
-               {
-                       TargetAddress ptr = memory.ReadAddress (address);
-
-                       TargetReader reader = new TargetReader 
(memory.ReadMemory (
-                               ptr, 8 + memory.TargetInfo.TargetAddressSize));
-
-                       Console.WriteLine ("READ TYPE: {0} {1} {2}",
-                                          address, ptr, 
reader.BinaryReader.HexDump ());
-                       return null;
-               }
        }
 }

Modified: 
branches/martin/debugger-generics/languages/mono/MonoGenericParameterType.cs
===================================================================
--- 
branches/martin/debugger-generics/languages/mono/MonoGenericParameterType.cs    
    2007-09-10 22:53:55 UTC (rev 85612)
+++ 
branches/martin/debugger-generics/languages/mono/MonoGenericParameterType.cs    
    2007-09-10 23:43:57 UTC (rev 85613)
@@ -37,8 +37,20 @@
 
                internal TargetObject GetObject (StackFrame frame, 
TargetLocation location)
                {
-                       Console.WriteLine ("GET OBJECT: {0} {1} {2}", this, 
frame, location);
-                       return null;
+                       MonoMethodFrameInfo info = (MonoMethodFrameInfo) 
frame.MethodFrameInfo;
+                       if (info == null)
+                               return null;
+
+                       Console.WriteLine ("GET OBJECT: {0} {1}", info, 
gen_param.Owner.GetType ());
+
+                       MonoGenericInst inst;
+                       if (gen_param.Owner is Cecil.MethodDefinition)
+                               inst = info.MethodInst;
+                       else
+                               inst = info.ClassInst;
+
+                       TargetType type = inst.Types [gen_param.Position];
+                       return type.GetObject (location);
                }
        }
 }

Added: branches/martin/debugger-generics/languages/mono/MonoMethodFrameInfo.cs
===================================================================
--- branches/martin/debugger-generics/languages/mono/MonoMethodFrameInfo.cs     
2007-09-10 22:53:55 UTC (rev 85612)
+++ branches/martin/debugger-generics/languages/mono/MonoMethodFrameInfo.cs     
2007-09-10 23:43:57 UTC (rev 85613)
@@ -0,0 +1,28 @@
+using System;
+
+namespace Mono.Debugger.Languages.Mono
+{
+       internal class MonoMethodFrameInfo : TargetMethodFrameInfo
+       {
+               public readonly Method Method;
+               public readonly TargetAddress Declaring;
+               public readonly MonoGenericInst ClassInst;
+               public readonly MonoGenericInst MethodInst;
+
+               public MonoMethodFrameInfo (Method method, TargetAddress 
declaring,
+                                           MonoGenericInst class_inst,
+                                           MonoGenericInst method_inst)
+               {
+                       this.Method = method;
+                       this.Declaring = declaring;
+                       this.ClassInst = class_inst;
+                       this.MethodInst = method_inst;
+               }
+
+               public override string ToString ()
+               {
+                       return String.Format ("MonoMethodFrameInfo 
({0}:{1}:{2}:{3})",
+                                             Method, Declaring, ClassInst, 
MethodInst);
+               }
+       }
+}

Modified: branches/martin/debugger-generics/languages/mono/MonoSymbolFile.cs
===================================================================
--- branches/martin/debugger-generics/languages/mono/MonoSymbolFile.cs  
2007-09-10 22:53:55 UTC (rev 85612)
+++ branches/martin/debugger-generics/languages/mono/MonoSymbolFile.cs  
2007-09-10 23:43:57 UTC (rev 85613)
@@ -947,11 +947,13 @@
 
                                MonoGenericInst class_inst = null;
                                if (!class_inst_addr.IsNull)
-                                       class_inst = new MonoGenericInst 
(target, class_inst_addr);
+                                       class_inst = new MonoGenericInst (
+                                               file.MonoLanguage, target, 
class_inst_addr);
 
                                MonoGenericInst method_inst = null;
                                if (!method_inst_addr.IsNull)
-                                       method_inst = new MonoGenericInst 
(target, method_inst_addr);
+                                       method_inst = new MonoGenericInst (
+                                               file.MonoLanguage, target, 
method_inst_addr);
 
                                return new MonoMethodFrameInfo (this, 
declaring, class_inst, method_inst);
                        }
@@ -1103,30 +1105,6 @@
                        }
                }
 
-               protected class MonoMethodFrameInfo : TargetMethodFrameInfo
-               {
-                       public readonly MonoMethod Method;
-                       public readonly TargetAddress Declaring;
-                       public readonly MonoGenericInst ClassInst;
-                       public readonly MonoGenericInst MethodInst;
-
-                       public MonoMethodFrameInfo (MonoMethod method, 
TargetAddress declaring,
-                                                   MonoGenericInst class_inst,
-                                                   MonoGenericInst method_inst)
-                       {
-                               this.Method = method;
-                               this.Declaring = declaring;
-                               this.ClassInst = class_inst;
-                               this.MethodInst = method_inst;
-                       }
-
-                       public override string ToString ()
-                       {
-                               return String.Format ("MonoMethodFrameInfo 
({0}:{1}:{2}:{3})",
-                                                     Method, Declaring, 
ClassInst, MethodInst);
-                       }
-               }
-
                protected abstract class MonoLineNumberTable : LineNumberTable
                {
                        Method method;

Added: branches/martin/debugger-generics/languages/mono/MonoType.cs
===================================================================
--- branches/martin/debugger-generics/languages/mono/MonoType.cs        
2007-09-10 22:53:55 UTC (rev 85612)
+++ branches/martin/debugger-generics/languages/mono/MonoType.cs        
2007-09-10 23:43:57 UTC (rev 85613)
@@ -0,0 +1,104 @@
+using System;
+
+using Mono.Debugger.Backends;
+
+namespace Mono.Debugger.Languages.Mono
+{
+       internal enum MonoTypeEnum
+       {
+               MONO_TYPE_END        = 0x00,       /* End of List */
+               MONO_TYPE_VOID       = 0x01,
+               MONO_TYPE_BOOLEAN    = 0x02,
+               MONO_TYPE_CHAR       = 0x03,
+               MONO_TYPE_I1         = 0x04,
+               MONO_TYPE_U1         = 0x05,
+               MONO_TYPE_I2         = 0x06,
+               MONO_TYPE_U2         = 0x07,
+               MONO_TYPE_I4         = 0x08,
+               MONO_TYPE_U4         = 0x09,
+               MONO_TYPE_I8         = 0x0a,
+               MONO_TYPE_U8         = 0x0b,
+               MONO_TYPE_R4         = 0x0c,
+               MONO_TYPE_R8         = 0x0d,
+               MONO_TYPE_STRING     = 0x0e,
+               MONO_TYPE_PTR        = 0x0f,       /* arg: <type> token */
+               MONO_TYPE_BYREF      = 0x10,       /* arg: <type> token */
+               MONO_TYPE_VALUETYPE  = 0x11,       /* arg: <type> token */
+               MONO_TYPE_CLASS      = 0x12,       /* arg: <type> token */
+               MONO_TYPE_VAR        = 0x13,       /* number */
+               MONO_TYPE_ARRAY      = 0x14,       /* type, rank, boundsCount, 
bound1, loCount, lo1 */
+               MONO_TYPE_GENERICINST= 0x15,       /* <type> <type-arg-count> 
<type-1> \x{2026} <type-n> */
+               MONO_TYPE_TYPEDBYREF = 0x16,
+               MONO_TYPE_I          = 0x18,
+               MONO_TYPE_U          = 0x19,
+               MONO_TYPE_FNPTR      = 0x1b,          /* arg: full method 
signature */
+               MONO_TYPE_OBJECT     = 0x1c,
+               MONO_TYPE_SZARRAY    = 0x1d,       /* 0-based one-dim-array */
+               MONO_TYPE_MVAR       = 0x1e,       /* number */
+               MONO_TYPE_CMOD_REQD  = 0x1f,       /* arg: typedef or typeref 
token */
+               MONO_TYPE_CMOD_OPT   = 0x20,       /* optional arg: typedef or 
typref token */
+               MONO_TYPE_INTERNAL   = 0x21,       /* CLR internal type */
+
+               MONO_TYPE_MODIFIER   = 0x40,       /* Or with the following 
types */
+               MONO_TYPE_SENTINEL   = 0x41,       /* Sentinel for varargs 
method signature */
+               MONO_TYPE_PINNED     = 0x45,       /* Local var that points to 
pinned object */
+
+               MONO_TYPE_ENUM       = 0x55        /* an enumeration */
+       }
+
+       internal static class MonoType
+       {
+               public static TargetType Read (MonoLanguageBackend mono, 
TargetMemoryAccess memory,
+                                              TargetAddress address)
+               {
+                       TargetAddress data = memory.ReadAddress (address);
+                       uint flags = (uint) memory.ReadInteger (address + 
memory.TargetInfo.TargetAddressSize);
+
+                       Console.WriteLine ("READ TYPE: {0} {1} {2:x}", address, 
data, flags);
+
+                       int attrs = (int) (flags & 0x0000ffff);
+                       MonoTypeEnum type = (MonoTypeEnum) ((flags & 
0x00ff0000) >> 16);
+                       int num_mods = (int) ((flags & 0x3f000000) >> 24);
+                       int byref = (int) ((flags & 0x40000000) >> 30);
+                       int pinned = (int) ((flags & 0x80000000) >> 31);
+
+                       Console.WriteLine ("READ TYPE #1: {0} {1} {2} {3} {4}",
+                                          attrs, type, num_mods, byref, 
pinned);
+
+                       switch (type) {
+                       case MonoTypeEnum.MONO_TYPE_BOOLEAN:
+                               return mono.BuiltinTypes.BooleanType;
+                       case MonoTypeEnum.MONO_TYPE_CHAR:
+                               return mono.BuiltinTypes.CharType;
+                       case MonoTypeEnum.MONO_TYPE_I1:
+                               return mono.BuiltinTypes.SByteType;
+                       case MonoTypeEnum.MONO_TYPE_U1:
+                               return mono.BuiltinTypes.ByteType;
+                       case MonoTypeEnum.MONO_TYPE_I2:
+                               return mono.BuiltinTypes.Int16Type;
+                       case MonoTypeEnum.MONO_TYPE_U2:
+                               return mono.BuiltinTypes.UInt16Type;
+                       case MonoTypeEnum.MONO_TYPE_I4:
+                               return mono.BuiltinTypes.Int32Type;
+                       case MonoTypeEnum.MONO_TYPE_U4:
+                               return mono.BuiltinTypes.UInt32Type;
+                       case MonoTypeEnum.MONO_TYPE_I8:
+                               return mono.BuiltinTypes.Int64Type;
+                       case MonoTypeEnum.MONO_TYPE_U8:
+                               return mono.BuiltinTypes.UInt64Type;
+                       case MonoTypeEnum.MONO_TYPE_R4:
+                               return mono.BuiltinTypes.SingleType;
+                       case MonoTypeEnum.MONO_TYPE_R8:
+                               return mono.BuiltinTypes.DoubleType;
+                       case MonoTypeEnum.MONO_TYPE_STRING:
+                               return mono.BuiltinTypes.StringType;
+
+                       default:
+                               break;
+
+                       }
+
+                       return null;
+               }
+       }
+}

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

Reply via email to