Author: toshok
Date: 2005-04-02 21:42:01 -0500 (Sat, 02 Apr 2005)
New Revision: 42496

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backends/mono/MonoFundamentalType.cs
   trunk/debugger/backends/mono/MonoLanguageBackend.cs
   trunk/debugger/backends/mono/MonoStringType.cs
   trunk/debugger/backends/mono/MonoStringTypeInfo.cs
Log:
2005-04-02  Chris Toshok  <[EMAIL PROTECTED]>

        * backends/mono/MonoLanguageBackend.cs
        (MonoLanguageBackend.CanCreateInstance): we can create an instance
        of any type we can lookup (really only fundamental types at the
        moment).
        (MonoLanguageBackend.CreateInstance): flesh out this method.

        * backends/mono/MonoFundamentalType.cs (.CreateInstance):
        reimplement this to create instances of fundamental types in the
        inferior from within the debugger.

        * backends/mono/MonoStringTypeInfo.cs: remove the CreateString
        stuff from here, and move it to MonoStringType.cs

        * backends/mono/MonoStringType.cs (.CreateObject,
        .CreateInstance): reimplement these, so that we can create string
        objects in the inferior process from inside the debugger.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2005-04-02 21:06:55 UTC (rev 42495)
+++ trunk/debugger/ChangeLog    2005-04-03 02:42:01 UTC (rev 42496)
@@ -1,3 +1,22 @@
+2005-04-02  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * backends/mono/MonoLanguageBackend.cs
+       (MonoLanguageBackend.CanCreateInstance): we can create an instance
+       of any type we can lookup (really only fundamental types at the
+       moment).
+       (MonoLanguageBackend.CreateInstance): flesh out this method.
+
+       * backends/mono/MonoFundamentalType.cs (.CreateInstance):
+       reimplement this to create instances of fundamental types in the
+       inferior from within the debugger.
+
+       * backends/mono/MonoStringTypeInfo.cs: remove the CreateString
+       stuff from here, and move it to MonoStringType.cs
+
+       * backends/mono/MonoStringType.cs (.CreateObject,
+       .CreateInstance): reimplement these, so that we can create string
+       objects in the inferior process from inside the debugger.
+
 2005-03-31  Chris Toshok  <[EMAIL PROTECTED]>
 
        * backends/mono/MonoSymbolFile.cs (MonoMethod.get_variables): we

Modified: trunk/debugger/backends/mono/MonoFundamentalType.cs
===================================================================
--- trunk/debugger/backends/mono/MonoFundamentalType.cs 2005-04-02 21:06:55 UTC 
(rev 42495)
+++ trunk/debugger/backends/mono/MonoFundamentalType.cs 2005-04-03 02:42:01 UTC 
(rev 42496)
@@ -117,5 +117,13 @@
                                throw new ArgumentException ();
                        }
                }
+
+               internal virtual MonoFundamentalObjectBase CreateInstance 
(StackFrame frame, object obj)
+               {
+                       TargetLocation location = Heap.Allocate (frame, size);
+                       frame.TargetAccess.WriteBuffer (location.Address, 
CreateObject (obj));
+
+                       return new MonoFundamentalObject 
((MonoFundamentalTypeInfo)CreateTypeInfo(), location);
+               }
        }
 }

Modified: trunk/debugger/backends/mono/MonoLanguageBackend.cs
===================================================================
--- trunk/debugger/backends/mono/MonoLanguageBackend.cs 2005-04-02 21:06:55 UTC 
(rev 42495)
+++ trunk/debugger/backends/mono/MonoLanguageBackend.cs 2005-04-03 02:42:01 UTC 
(rev 42496)
@@ -579,12 +579,16 @@
 
                public bool CanCreateInstance (Type type)
                {
-                       return false;
+                       return LookupMonoType (type) != null;
                }
 
                public ITargetObject CreateInstance (StackFrame frame, object 
obj)
                {
-                       return null;
+                       MonoFundamentalType type = LookupMonoType (obj.GetType 
()) as MonoFundamentalType;
+                       if (type == null)
+                               return null;
+
+                       return type.CreateInstance (frame, obj);
                }
 
                public ITargetPointerObject CreatePointer (StackFrame frame, 
TargetAddress address)

Modified: trunk/debugger/backends/mono/MonoStringType.cs
===================================================================
--- trunk/debugger/backends/mono/MonoStringType.cs      2005-04-02 21:06:55 UTC 
(rev 42495)
+++ trunk/debugger/backends/mono/MonoStringType.cs      2005-04-03 02:42:01 UTC 
(rev 42496)
@@ -6,11 +6,14 @@
        {
                int object_size;
 
+               protected readonly TargetAddress CreateString;
+
                public MonoStringType (MonoSymbolFile file, Type type, int 
object_size,
                                       int size, TargetAddress klass)
                        : base (file, type, size, klass)
                {
                        this.object_size = object_size;
+                       this.CreateString = 
file.MonoLanguage.MonoDebuggerInfo.CreateString;
                }
 
                protected override MonoTypeInfo CreateTypeInfo ()
@@ -31,5 +34,33 @@
                {
                        throw new InvalidOperationException ();
                }
+
+               public override byte[] CreateObject (object obj)
+               {
+                        string str = obj as string;
+                        if (str == null) 
+                                throw new ArgumentException ();
+
+                        char[] carray = ((string) obj).ToCharArray ();
+                        byte[] retval = new byte [carray.Length * 2];
+
+                        for (int i = 0; i < carray.Length; i++) {
+                                retval [2*i] = (byte) (carray [i] & 0x00ff);
+                                retval [2*i+1] = (byte) (carray [i] >> 8);
+                        }
+
+                        return retval;
+               }
+
+                internal override MonoFundamentalObjectBase CreateInstance 
(StackFrame frame, object obj)
+                {
+                        string str = obj as string;
+                        if (str == null)
+                                throw new ArgumentException ();
+
+                        TargetAddress retval = frame.Process.CallMethod 
(CreateString, str);
+                        TargetLocation location = new AbsoluteTargetLocation 
(frame, retval);
+                        return new MonoStringObject 
((MonoStringTypeInfo)type_info, location);
+                }
        }
 }

Modified: trunk/debugger/backends/mono/MonoStringTypeInfo.cs
===================================================================
--- trunk/debugger/backends/mono/MonoStringTypeInfo.cs  2005-04-02 21:06:55 UTC 
(rev 42495)
+++ trunk/debugger/backends/mono/MonoStringTypeInfo.cs  2005-04-03 02:42:01 UTC 
(rev 42496)
@@ -10,15 +10,12 @@
                internal readonly int LengthSize;
                internal readonly int DataOffset;
 
-               protected readonly TargetAddress CreateString;
-
                public MonoStringTypeInfo (MonoStringType type, int 
object_size, int size, TargetAddress klass)
                        : base (type, size, klass)
                {
                        this.LengthOffset = object_size;
                        this.LengthSize = 4;
                        this.DataOffset = object_size + 4;
-                       CreateString = 
type.File.MonoLanguage.MonoDebuggerInfo.CreateString;
                }
 
                public override bool HasFixedSize {

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

Reply via email to