Author: martin
Date: 2007-10-09 12:12:44 -0400 (Tue, 09 Oct 2007)
New Revision: 87185
Modified:
branches/martin/debugger-terrania/frontend/ObjectFormatter.cs
branches/martin/debugger-terrania/languages/TargetGenericInstanceObject.cs
branches/martin/debugger-terrania/languages/mono/MonoClassInfo.cs
branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
Log:
Modified: branches/martin/debugger-terrania/frontend/ObjectFormatter.cs
===================================================================
--- branches/martin/debugger-terrania/frontend/ObjectFormatter.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++ branches/martin/debugger-terrania/frontend/ObjectFormatter.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -364,7 +364,16 @@
}
first = false;
Append (fields [i].Name + " = ");
- Append ("<not-yet-implemented>");
+ try {
+ TargetObject fobj = obj.GetField
(target, fields [i]);
+ if (fobj == null)
+ Append ("null");
+ else
+ FormatObjectRecursed (target,
fobj, true);
+ } catch (Exception ex) {
+ Console.WriteLine ("EX: {0}", ex);
+ Append ("<cannot display object>");
+ }
}
Append (first ? "}" : " }");
Modified:
branches/martin/debugger-terrania/languages/TargetGenericInstanceObject.cs
===================================================================
--- branches/martin/debugger-terrania/languages/TargetGenericInstanceObject.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++ branches/martin/debugger-terrania/languages/TargetGenericInstanceObject.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -10,5 +10,7 @@
{
this.Type = type;
}
+
+ public abstract TargetObject GetField (TargetMemoryAccess
target, TargetFieldInfo field);
}
}
Modified: branches/martin/debugger-terrania/languages/mono/MonoClassInfo.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoClassInfo.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++ branches/martin/debugger-terrania/languages/mono/MonoClassInfo.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -17,6 +17,7 @@
MonoClassInfo parent_info;
TargetAddress parent_klass = TargetAddress.Null;
+ TargetType[] field_types;
int[] field_offsets;
Hashtable methods;
@@ -107,13 +108,19 @@
int field_count = target.ReadInteger (
KlassAddress + metadata.KlassFieldCountOffset);
- TargetBinaryReader field_blob = target.ReadMemory (
- field_info, field_count *
metadata.FieldInfoSize).GetReader ();
+ TargetReader field_blob = new TargetReader
(target.ReadMemory (
+ field_info, field_count *
metadata.FieldInfoSize));
field_offsets = new int [field_count];
+ field_types = new TargetType [field_count];
+
for (int i = 0; i < field_count; i++) {
- field_blob.Position = i *
metadata.FieldInfoSize + 2 * address_size;
- field_offsets [i] = field_blob.ReadInt32 ();
+ int offset = i * metadata.FieldInfoSize;
+
+ TargetAddress type_addr =
field_blob.PeekAddress (offset);
+ field_types [i] = MonoRuntime.ReadType (
+ SymbolFile.MonoLanguage, target,
type_addr);
+ field_offsets [i] = field_blob.PeekInteger
(offset + 2 * address_size);
}
}
@@ -123,6 +130,12 @@
return field_offsets;
}
+ public TargetType[] GetFieldTypes (TargetMemoryAccess target)
+ {
+ get_field_offsets (target);
+ return field_types;
+ }
+
void get_methods (TargetMemoryAccess target)
{
if (methods != null)
Modified: branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++ branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -456,9 +456,8 @@
internal TargetObject GetField (TargetMemoryAccess target,
TargetLocation location,
TargetFieldInfo finfo)
{
- Console.WriteLine ("GET FIELD: {0} {1} {2}", this,
finfo, finfo.Type);
-
int offset = GetFieldOffset (target, finfo);
+ Console.WriteLine ("GET FIELD: {0} {1} {2} {3}", this,
finfo, finfo.Type, offset);
if (!IsByRef)
offset -= 2 *
target.TargetInfo.TargetAddressSize;
TargetLocation field_loc = location.GetLocationAtOffset
(offset);
Modified:
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
===================================================================
---
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -7,14 +7,38 @@
internal class MonoGenericInstanceObject : TargetGenericInstanceObject
{
new public MonoGenericInstanceType Type;
+ MonoClassInfo class_info;
public MonoGenericInstanceObject (MonoGenericInstanceType type,
+ MonoClassInfo class_info,
TargetLocation location)
: base (type, location)
{
this.Type = type;
+ this.class_info = class_info;
}
+ public override TargetObject GetField (TargetMemoryAccess
target, TargetFieldInfo field)
+ {
+ Console.WriteLine ("GENERIC INST GET FIELD: {0} {1}",
this, field);
+
+ int offset = class_info.GetFieldOffsets (target)
[field.Position];
+ TargetType type = class_info.GetFieldTypes (target)
[field.Position];
+
+ Console.WriteLine ("GET FIELD: {0} {1} {2} {3}", this,
field, type, offset);
+ if (!Type.IsByRef)
+ offset -= 2 *
target.TargetInfo.TargetAddressSize;
+ TargetLocation field_loc = Location.GetLocationAtOffset
(offset);
+
+ if (type.IsByRef)
+ field_loc = field_loc.GetDereferencedLocation
();
+
+ if (field_loc.HasAddress && field_loc.GetAddress
(target).IsNull)
+ return null;
+
+ return type.GetObject (target, field_loc);
+ }
+
internal override long GetDynamicSize (TargetMemoryAccess
target, TargetBlob blob,
TargetLocation location,
out TargetLocation
dynamic_location)
Modified:
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
2007-10-09 16:04:39 UTC (rev 87184)
+++ branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
2007-10-09 16:12:44 UTC (rev 87185)
@@ -7,12 +7,16 @@
internal class MonoGenericInstanceType : TargetGenericInstanceType
{
MonoClassType container;
+ TargetAddress cached_ptr;
+ MonoClassInfo class_info;
+
public MonoGenericInstanceType (MonoClassType container,
MonoGenericContext context,
TargetAddress cached_ptr)
: base (container.Language)
{
this.container = container;
+ this.cached_ptr = cached_ptr;
}
public override TargetClassType ContainerType {
@@ -43,10 +47,33 @@
get { return 0; }
}
+ protected MonoClassInfo ResolveClass (TargetMemoryAccess target)
+ {
+ if (class_info != null)
+ return class_info;
+
+ class_info = DoResolveClass (target);
+ if (class_info != null)
+ return class_info;
+
+ throw new TargetException
(TargetError.ClassNotInitialized,
+ "Class `{0}' not initialized
yet.", Name);
+ }
+
+ MonoClassInfo DoResolveClass (TargetMemoryAccess target)
+ {
+ TargetAddress klass = target.ReadAddress (cached_ptr);
+ if (klass.IsNull)
+ return null;
+
+ return container.File.MonoLanguage.ReadClassInfo
(target, klass);
+ }
+
protected override TargetObject DoGetObject (TargetMemoryAccess
target,
TargetLocation
location)
{
- return new MonoGenericInstanceObject (this, location);
+ ResolveClass (target);
+ return new MonoGenericInstanceObject (this, class_info,
location);
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches