Author: martin
Date: 2007-10-09 11:45:45 -0400 (Tue, 09 Oct 2007)
New Revision: 87173
Added:
branches/martin/debugger-terrania/languages/mono/MonoGenericContext.cs
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
branches/martin/debugger-terrania/languages/mono/MonoGenericParameterType.cs
Modified:
branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
branches/martin/debugger-terrania/languages/mono/MonoLanguageBackend.cs
branches/martin/debugger-terrania/languages/mono/MonoRuntime.cs
Log:
Modified: branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++ branches/martin/debugger-terrania/languages/mono/MonoClassType.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -121,9 +121,17 @@
fields = new MonoFieldInfo [num_fields];
static_fields = new MonoFieldInfo [num_sfields];
+ Console.WriteLine ("GET FIELDS: {0}", this);
+
int pos = 0, spos = 0, i = 0;
foreach (Cecil.FieldDefinition field in type.Fields) {
TargetType ftype =
File.MonoLanguage.LookupMonoType (field.FieldType);
+ Console.WriteLine ("GET FIELDS #1: {0} {1} {2}
{3}",
+ this, field, ftype, ftype !=
null);
+
+ if (ftype == null)
+ ftype = File.MonoLanguage.VoidType;
+
if (field.IsStatic) {
static_fields [spos] = new
MonoFieldInfo (
this, ftype, spos, i, field);
@@ -375,7 +383,7 @@
return null;
}
- class_info = file.LookupClassInfo (target, (int)
type.MetadataToken.ToUInt ());
+ class_info = DoResolveClass (target);
if (class_info != null)
return class_info;
@@ -386,6 +394,11 @@
return null;
}
+ protected virtual MonoClassInfo DoResolveClass
(TargetMemoryAccess target)
+ {
+ return file.LookupClassInfo (target, (int)
type.MetadataToken.ToUInt ());
+ }
+
internal MonoClassInfo ClassResolved (TargetMemoryAccess
target, TargetAddress klass)
{
class_info = File.MonoLanguage.ReadClassInfo (target,
klass);
@@ -443,6 +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);
if (!IsByRef)
offset -= 2 *
target.TargetInfo.TargetAddressSize;
Added: branches/martin/debugger-terrania/languages/mono/MonoGenericContext.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoGenericContext.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++ branches/martin/debugger-terrania/languages/mono/MonoGenericContext.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -0,0 +1,90 @@
+using System;
+using System.Text;
+using Cecil = Mono.Cecil;
+
+using Mono.Debugger;
+using Mono.Debugger.Backends;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ public class MonoGenericContext : DebuggerMarshalByRefObject
+ {
+ public readonly MonoGenericInst MethodInst;
+ public readonly MonoGenericInst ClassInst;
+
+ internal static MonoGenericContext ReadGenericContext
(MonoLanguageBackend mono,
+
TargetMemoryAccess memory,
+
TargetAddress address)
+ {
+ MonoGenericInst class_inst = null;
+ TargetAddress class_inst_addr = memory.ReadAddress
(address);
+ if (!class_inst_addr.IsNull)
+ class_inst = MonoGenericInst.ReadGenericInst (
+ mono, memory, class_inst_addr);
+
+ MonoGenericInst method_inst = null;
+ TargetAddress method_inst_addr = memory.ReadAddress (
+ address + memory.TargetInfo.TargetAddressSize);
+ if (!method_inst_addr.IsNull)
+ method_inst = MonoGenericInst.ReadGenericInst (
+ mono, memory, method_inst_addr);
+
+ return new MonoGenericContext (method_inst, class_inst);
+ }
+
+ protected MonoGenericContext (MonoGenericInst method_inst,
MonoGenericInst class_inst)
+ {
+ this.MethodInst = method_inst;
+ this.ClassInst = class_inst;
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("MonoGenericContext ({0}:{1})",
+ MethodInst, ClassInst);
+ }
+ }
+
+ public class MonoGenericInst : DebuggerMarshalByRefObject
+ {
+ public readonly TargetType[] Types;
+
+ public MonoGenericInst (TargetType[] types)
+ {
+ this.Types = types;
+ }
+
+ internal static MonoGenericInst ReadGenericInst
(MonoLanguageBackend mono,
+
TargetMemoryAccess memory,
+ TargetAddress
address)
+ {
+ int addr_size = memory.TargetInfo.TargetAddressSize;
+
+ TargetReader blob = new TargetReader (memory.ReadMemory
(address, 16));
+ int header = memory.ReadInteger (address + 4);
+ TargetAddress type_argv_ptr = memory.ReadAddress
(address + addr_size);
+
+ int type_argc = header & 0x3fffff;
+
+ TargetType[] types = new TargetType [type_argc];
+ for (int i = 0; i < type_argc; i++) {
+ TargetAddress ptr = memory.ReadAddress
(type_argv_ptr + i * addr_size);
+ types [i] = MonoRuntime.ReadType (mono, memory,
ptr);
+ }
+
+ return new MonoGenericInst (types);
+ }
+
+ public override string ToString ()
+ {
+ StringBuilder sb = new StringBuilder ("MonoGenericInst
(");
+ for (int i = 0; i < Types.Length; i++) {
+ if (i > 0)
+ sb.Append (",");
+ sb.Append (Types [i]);
+ }
+ sb.Append (")");
+ return sb.ToString ();
+ }
+ }
+}
Added:
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
===================================================================
---
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceObject.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using Cecil = Mono.Cecil;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal class MonoGenericInstanceObject : TargetObject
+ {
+ new public MonoGenericInstanceType Type;
+
+ public MonoGenericInstanceObject (MonoGenericInstanceType type,
+ TargetLocation location)
+ : base (type, location)
+ {
+ this.Type = type;
+ }
+
+ internal override long GetDynamicSize (TargetMemoryAccess
target, TargetBlob blob,
+ TargetLocation location,
+ out TargetLocation
dynamic_location)
+ {
+ throw new InvalidOperationException ();
+ }
+ }
+}
Modified:
branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++ branches/martin/debugger-terrania/languages/mono/MonoGenericInstanceType.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -4,30 +4,45 @@
namespace Mono.Debugger.Languages.Mono
{
- internal class MonoGenericInstanceType : MonoClassType
+ internal class MonoGenericInstanceType : TargetType
{
- public readonly TargetType UnderlyingType;
- string full_name;
+ MonoClassType container;
- public MonoGenericInstanceType (MonoSymbolFile file,
- MonoClassType underlying_type,
TargetType[] type_args)
- : base (file, underlying_type.Type)
+ public MonoGenericInstanceType (MonoClassType container,
MonoGenericContext context,
+ TargetAddress cached_ptr)
+ : base (container.Language, TargetObjectKind.Unknown)
{
- this.UnderlyingType = underlying_type;
-
- StringBuilder sb = new StringBuilder
(underlying_type.Name);
- sb.Append ('<');
- for (int i = 0; i < type_args.Length; i++) {
- if (i > 0)
- sb.Append (',');
- sb.Append (type_args [i].Name);
- }
- sb.Append ('>');
- full_name = sb.ToString ();
+ this.container = container;
}
public override string Name {
- get { return full_name; }
+ get { return container.Name; }
}
+
+ public override bool IsByRef {
+ get { return container.IsByRef; }
+ }
+
+ public override bool HasFixedSize {
+ get { return true; }
+ }
+
+ public override bool HasClassType {
+ get { return false; }
+ }
+
+ public override TargetClassType ClassType {
+ get { throw new InvalidOperationException (); }
+ }
+
+ public override int Size {
+ get { return 0; }
+ }
+
+ protected override TargetObject DoGetObject (TargetMemoryAccess
target,
+ TargetLocation
location)
+ {
+ return new MonoGenericInstanceObject (this, location);
+ }
}
}
Added:
branches/martin/debugger-terrania/languages/mono/MonoGenericParameterType.cs
===================================================================
---
branches/martin/debugger-terrania/languages/mono/MonoGenericParameterType.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++
branches/martin/debugger-terrania/languages/mono/MonoGenericParameterType.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -0,0 +1,64 @@
+using System;
+using Cecil = Mono.Cecil;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal class MonoGenericParameterType : TargetType
+ {
+ int pos;
+ bool is_mvar;
+ string name;
+
+ public MonoGenericParameterType (MonoLanguageBackend mono, int
pos, bool is_mvar)
+ : base (mono, TargetObjectKind.Alias)
+ {
+ this.pos = pos;
+ this.is_mvar = is_mvar;
+ this.name = String.Format ("{0}{1}", is_mvar ? "??" :
"?", pos);
+ }
+
+ public MonoGenericParameterType (MonoLanguageBackend mono,
+ Cecil.GenericParameter
gen_param)
+ : base (mono, TargetObjectKind.Alias)
+ {
+ this.pos = gen_param.Position;
+ this.is_mvar = gen_param.Owner is
Cecil.MethodDefinition;
+ this.name = gen_param.Name;
+ }
+
+ public override string Name {
+ get { return name; }
+ }
+
+ public override bool IsByRef {
+ get { return false; }
+ }
+
+ public override bool HasFixedSize {
+ get { return false; }
+ }
+
+ public override int Size {
+ get { throw new InvalidOperationException (); }
+ }
+
+ public int Position {
+ get { return pos; }
+ }
+
+ public override bool HasClassType {
+ get { return false; }
+ }
+
+ public override TargetClassType ClassType {
+ get { throw new InvalidOperationException (); }
+ }
+
+ protected override TargetObject DoGetObject (TargetMemoryAccess
target,
+ TargetLocation
location)
+ {
+ Console.WriteLine ("GENERIC PARAM GET OBJECT: {0}",
this);
+ return null;
+ }
+ }
+}
Modified:
branches/martin/debugger-terrania/languages/mono/MonoLanguageBackend.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoLanguageBackend.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++ branches/martin/debugger-terrania/languages/mono/MonoLanguageBackend.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -302,6 +302,10 @@
return new MonoPointerType (element_type);
}
+ Cecil.GenericParameter gen_param = type as
Cecil.GenericParameter;
+ if (gen_param != null)
+ return new MonoGenericParameterType (this,
gen_param);
+
int rank = 0;
string full_name = type.FullName;
Modified: branches/martin/debugger-terrania/languages/mono/MonoRuntime.cs
===================================================================
--- branches/martin/debugger-terrania/languages/mono/MonoRuntime.cs
2007-10-09 15:15:46 UTC (rev 87172)
+++ branches/martin/debugger-terrania/languages/mono/MonoRuntime.cs
2007-10-09 15:45:45 UTC (rev 87173)
@@ -145,6 +145,21 @@
return new MonoArrayType (etype, rank);
}
+ case MonoTypeEnum.MONO_TYPE_GENERICINST: {
+ TargetAddress ptr = data;
+
+ TargetAddress container_addr =
memory.ReadAddress (ptr);
+ ptr += memory.TargetInfo.TargetAddressSize;
+
+ MonoClassType container = (MonoClassType)
mono.ReadMonoClass (memory, container_addr);
+
+ MonoGenericContext context =
MonoGenericContext.ReadGenericContext (
+ mono, memory, ptr);
+
+ ptr += 3 * memory.TargetInfo.TargetAddressSize;
+ return new MonoGenericInstanceType (container,
context, ptr);
+ }
+
default:
Report.Error ("UNKNOWN TYPE: {0}", type);
return null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches