Author: toshok
Date: 2005-07-05 18:53:57 -0400 (Tue, 05 Jul 2005)
New Revision: 46978
Added:
trunk/debugger/backends/mono/MonoEnumObject.cs
trunk/debugger/backends/mono/MonoEnumType.cs
trunk/debugger/backends/mono/MonoEnumTypeInfo.cs
trunk/debugger/backends/mono/MonoMember.cs
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backends/mono/Makefile.am
trunk/debugger/backends/mono/MonoArrayTypeInfo.cs
trunk/debugger/backends/mono/MonoClassInfo.cs
trunk/debugger/backends/mono/MonoClassType.cs
trunk/debugger/backends/mono/MonoSymbolFile.cs
Log:
2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
* backends/mono/MonoArrayTypeInfo.cs: remove unused using.
* backends/mono/MonoClassInfo.cs: remove the MonoClassType. prefix
from MonoFieldInfo, MonoMethodInfo, and MonoPropertyInfo.
* backends/mono/MonoClassType.cs: split out all the
Member/Field/Property/Event classes from here.
* backends/mono/MonoMember.cs: and put them here. Also,
MonoStructMember -> MonoMember, and make MonoMember not depend on
a MonoStructType, since it's also used for enums.
* backends/mono/MonoSymbolFile.cs: return a MonoEnumType if
type.IsEnum == true.
* backends/mono/Makefile.am (EXTRA_DIST): add the new Enum files
and MonoMember.cs.
* backends/mono/MonoEnumTypeInfo.cs,
backends/mono/MonoEnumType.cs, backends/mono/MonoEnumObject.cs:
add new enum support.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-07-05 22:44:47 UTC (rev 46977)
+++ trunk/debugger/ChangeLog 2005-07-05 22:53:57 UTC (rev 46978)
@@ -1,5 +1,29 @@
2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
+ * backends/mono/MonoArrayTypeInfo.cs: remove unused using.
+
+ * backends/mono/MonoClassInfo.cs: remove the MonoClassType. prefix
+ from MonoFieldInfo, MonoMethodInfo, and MonoPropertyInfo.
+
+ * backends/mono/MonoClassType.cs: split out all the
+ Member/Field/Property/Event classes from here.
+
+ * backends/mono/MonoMember.cs: and put them here. Also,
+ MonoStructMember -> MonoMember, and make MonoMember not depend on
+ a MonoStructType, since it's also used for enums.
+
+ * backends/mono/MonoSymbolFile.cs: return a MonoEnumType if
+ type.IsEnum == true.
+
+ * backends/mono/Makefile.am (EXTRA_DIST): add the new Enum files
+ and MonoMember.cs.
+
+ * backends/mono/MonoEnumTypeInfo.cs,
+ backends/mono/MonoEnumType.cs, backends/mono/MonoEnumObject.cs:
+ add new enum support.
+
+2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
+
* frontend/Style.cs (StyleNative.FormatObject): add (obj is
ITargetEnumType) block, which calls FormatEnumType.
(StyleNative.FormatEnumMember): new function, give both the
Modified: trunk/debugger/backends/mono/Makefile.am
===================================================================
--- trunk/debugger/backends/mono/Makefile.am 2005-07-05 22:44:47 UTC (rev
46977)
+++ trunk/debugger/backends/mono/Makefile.am 2005-07-05 22:53:57 UTC (rev
46978)
@@ -1,8 +1,9 @@
EXTRA_DIST = \
- Heap.cs MonoFunctionObject.cs MonoLanguageBackend.cs MonoStringType.cs \
- MonoArrayObject.cs MonoFunctionType.cs MonoObject.cs
MonoStringTypeInfo.cs \
- MonoArrayType.cs MonoFunctionTypeInfo.cs MonoObjectObject.cs
MonoSymbolFile.cs \
- MonoArrayTypeInfo.cs MonoFundamentalObjectBase.cs MonoObjectType.cs
MonoType.cs \
- MonoClassInfo.cs MonoFundamentalObject.cs MonoObjectTypeInfo.cs
MonoTypeInfo.cs \
- MonoClassObject.cs MonoFundamentalType.cs MonoOpaqueType.cs
MonoVariable.cs \
- MonoClassType.cs MonoFundamentalTypeInfo.cs MonoStringObject.cs
+ Heap.cs MonoArrayObject.cs MonoArrayType.cs MonoArrayTypeInfo.cs
MonoClassInfo.cs \
+ MonoClassObject.cs MonoClassType.cs MonoEnumObject.cs MonoEnumType.cs \
+ MonoEnumTypeInfo.cs MonoFunctionObject.cs MonoFunctionType.cs
MonoFunctionTypeInfo.cs \
+ MonoFundamentalObjectBase.cs MonoFundamentalObject.cs
MonoFundamentalType.cs \
+ MonoFundamentalTypeInfo.cs MonoLanguageBackend.cs MonoMember.cs
MonoObject.cs \
+ MonoObjectObject.cs MonoObjectType.cs MonoObjectTypeInfo.cs
MonoOpaqueType.cs \
+ MonoStringObject.cs MonoStringType.cs MonoStringTypeInfo.cs
MonoSymbolFile.cs \
+ MonoType.cs MonoTypeInfo.cs MonoVariable.cs
Modified: trunk/debugger/backends/mono/MonoArrayTypeInfo.cs
===================================================================
--- trunk/debugger/backends/mono/MonoArrayTypeInfo.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoArrayTypeInfo.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -1,5 +1,4 @@
using System;
-using System.Text;
namespace Mono.Debugger.Languages.Mono
{
Modified: trunk/debugger/backends/mono/MonoClassInfo.cs
===================================================================
--- trunk/debugger/backends/mono/MonoClassInfo.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoClassInfo.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -52,7 +52,7 @@
try {
initialize (location.TargetAccess);
- MonoClassType.MonoFieldInfo finfo = Type.Fields
[index];
+ MonoFieldInfo finfo = Type.Fields [index];
MonoTypeInfo ftype = finfo.Type.GetTypeInfo ();
if (ftype == null)
return null;
@@ -80,7 +80,7 @@
debugger_info.ClassGetStaticFieldData,
KlassAddress,
TargetAddress.Null);
- MonoClassType.MonoFieldInfo finfo =
Type.StaticFields [index];
+ MonoFieldInfo finfo = Type.StaticFields [index];
MonoTypeInfo ftype = finfo.Type.GetTypeInfo ();
if (ftype == null)
return null;
@@ -101,7 +101,7 @@
try {
initialize (location.TargetAccess);
- MonoClassType.MonoMethodInfo minfo =
Type.Methods [index];
+ MonoMethodInfo minfo = Type.Methods [index];
MonoTypeInfo mtype = minfo.Type.GetTypeInfo ();
if (mtype == null)
return null;
@@ -127,7 +127,7 @@
try {
initialize (location.TargetAccess);
- MonoClassType.MonoPropertyInfo pinfo =
Type.Properties [index];
+ MonoPropertyInfo pinfo = Type.Properties
[index];
return pinfo.Get (location);
} catch (TargetException ex) {
throw new LocationInvalidException (ex);
Modified: trunk/debugger/backends/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/backends/mono/MonoClassType.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoClassType.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -63,10 +63,10 @@
int pos = 0, spos = 0;
for (int i = 0; i < finfo.Length; i++) {
if (finfo [i].IsStatic) {
- static_fields [spos] = new
MonoFieldInfo (this, spos, i, finfo [i]);
+ static_fields [spos] = new
MonoFieldInfo (File, spos, i, finfo [i]);
spos++;
} else {
- fields [pos] = new MonoFieldInfo (this,
pos, i, finfo [i]);
+ fields [pos] = new MonoFieldInfo (File,
pos, i, finfo [i]);
pos++;
}
}
@@ -338,276 +338,5 @@
return new MonoClassInfo (this, info);
}
-
- internal abstract class MonoStructMember : ITargetMemberInfo
- {
- public readonly MonoClassType Klass;
- public readonly R.MemberInfo MemberInfo;
- public readonly int Index;
- public readonly int Position;
- public readonly bool IsStatic;
-
- public MonoStructMember (MonoClassType klass,
R.MemberInfo minfo, int index, int pos,
- bool is_static)
- {
- this.Klass = klass;
- this.MemberInfo = minfo;
- this.Index = index;
- this.Position = pos;
- this.IsStatic = is_static;
- }
-
- public abstract MonoType Type {
- get;
- }
-
- ITargetType ITargetMemberInfo.Type {
- get { return Type; }
- }
-
- string ITargetMemberInfo.Name {
- get { return MemberInfo.Name; }
- }
-
- int ITargetMemberInfo.Index {
- get { return Index; }
- }
-
- bool ITargetMemberInfo.IsStatic {
- get { return IsStatic; }
- }
-
- object ITargetMemberInfo.Handle {
- get { return MemberInfo; }
- }
-
- protected abstract string MyToString ();
-
- public override string ToString ()
- {
- return String.Format ("{0}
({1}:{2}:{3}:{4}:{5})",
- GetType (), Klass, Type,
Index, IsStatic, MyToString ());
- }
- }
-
- internal class MonoFieldInfo : MonoStructMember,
ITargetFieldInfo
- {
- MonoType type;
-
- public readonly R.FieldInfo FieldInfo;
-
- internal MonoFieldInfo (MonoClassType klass, int index,
int pos, R.FieldInfo finfo)
- : base (klass, finfo, index, pos,
finfo.IsStatic)
- {
- FieldInfo = finfo;
- type = klass.File.MonoLanguage.LookupMonoType
(finfo.FieldType);
- }
-
- public override MonoType Type {
- get { return type; }
- }
-
- int ITargetFieldInfo.Offset {
- get { return 0; }
- }
-
- protected override string MyToString ()
- {
- return String.Format ("{0}", type);
- }
- }
-
- internal class MonoMethodInfo : MonoStructMember,
ITargetMethodInfo
- {
- public readonly R.MethodBase MethodInfo;
- public readonly MonoFunctionType FunctionType;
-
- internal MonoMethodInfo (MonoClassType klass, int
index, R.MethodBase minfo)
- : base (klass, minfo, index,
C.MonoDebuggerSupport.GetMethodIndex (minfo),
- minfo.IsStatic)
- {
- MethodInfo = minfo;
- FunctionType = new MonoFunctionType
(klass.File, Klass, minfo, Position - 1);
- }
-
- public override MonoType Type {
- get { return FunctionType; }
- }
-
- ITargetFunctionType ITargetMethodInfo.Type {
- get {
- return FunctionType;
- }
- }
-
- string ITargetMethodInfo.FullName {
- get {
- StringBuilder sb = new StringBuilder ();
- bool first = true;
- foreach (R.ParameterInfo pinfo in
MethodInfo.GetParameters ()) {
- if (first)
- first = false;
- else
- sb.Append (",");
- sb.Append (pinfo.ParameterType);
- }
-
- return String.Format ("{0}({1})",
MethodInfo.Name, sb.ToString ());
- }
- }
-
- internal ITargetFunctionObject Get (StackFrame frame)
- {
- MonoFunctionTypeInfo func =
FunctionType.GetTypeInfo () as MonoFunctionTypeInfo;
- if (func == null)
- return null;
-
- return func.GetStaticObject (frame);
- }
-
- protected override string MyToString ()
- {
- return String.Format ("{0}", FunctionType);
- }
- }
-
- internal class MonoEventInfo : MonoStructMember,
ITargetEventInfo
- {
- MonoType type;
- public readonly R.EventInfo EventInfo;
- public readonly MonoFunctionType AddType, RemoveType;
-
- internal MonoEventInfo (MonoClassType klass, int index,
R.EventInfo einfo,
- bool is_static)
- : base (klass, einfo, index, index, is_static)
- {
- int pos;
-
- EventInfo = einfo;
- type = klass.File.MonoLanguage.LookupMonoType
(einfo.EventHandlerType);
-
- R.MethodInfo add = EventInfo.GetAddMethod ();
- pos = C.MonoDebuggerSupport.GetMethodIndex
(add);
- AddType = new MonoFunctionType (klass.File,
Klass, add, pos - 1);
-
- R.MethodInfo remove = EventInfo.GetRemoveMethod
();
- pos = C.MonoDebuggerSupport.GetMethodIndex
(remove);
- RemoveType = new MonoFunctionType (klass.File,
Klass, remove, pos - 1);
- }
-
- public override MonoType Type {
- get { return type; }
- }
-
- ITargetFunctionType ITargetEventInfo.Add {
- get {
- return AddType;
- }
- }
-
- ITargetFunctionType ITargetEventInfo.Remove {
- get {
- return RemoveType;
- }
- }
-
- protected override string MyToString ()
- {
- return String.Format ("{0}:{1}", AddType,
RemoveType);
- }
- }
-
- internal class MonoPropertyInfo : MonoStructMember,
ITargetPropertyInfo
- {
- MonoType type;
- public readonly R.PropertyInfo PropertyInfo;
- public readonly MonoFunctionType GetterType, SetterType;
-
- internal MonoPropertyInfo (MonoClassType klass, int
index, R.PropertyInfo pinfo,
- bool is_static)
- : base (klass, pinfo, index, index, is_static)
- {
- PropertyInfo = pinfo;
- type = klass.File.MonoLanguage.LookupMonoType
(pinfo.PropertyType);
-
- if (PropertyInfo.CanRead) {
- R.MethodInfo getter =
PropertyInfo.GetGetMethod (true);
- int pos =
C.MonoDebuggerSupport.GetMethodIndex (getter);
- GetterType = new MonoFunctionType
(klass.File, Klass, getter, pos - 1);
- }
-
- if (PropertyInfo.CanWrite) {
- R.MethodInfo setter =
PropertyInfo.GetSetMethod (true);
- int pos =
C.MonoDebuggerSupport.GetMethodIndex (setter);
- SetterType = new MonoFunctionType
(klass.File, Klass, setter, pos - 1);
- }
- }
-
- public override MonoType Type {
- get { return type; }
- }
-
- public bool CanRead {
- get { return PropertyInfo.CanRead; }
- }
-
- ITargetFunctionType ITargetPropertyInfo.Getter {
- get {
- if (!CanRead)
- throw new
InvalidOperationException ();
-
- return GetterType;
- }
- }
-
- public bool CanWrite {
- get {
- return PropertyInfo.CanWrite;
- }
- }
-
- ITargetFunctionType ITargetPropertyInfo.Setter {
- get {
- if (!CanWrite)
- throw new
InvalidOperationException ();
-
- return SetterType;
- }
- }
-
- internal ITargetObject Get (TargetLocation location)
- {
- if (!PropertyInfo.CanRead)
- throw new InvalidOperationException ();
-
- MonoFunctionTypeInfo getter =
GetterType.GetTypeInfo () as MonoFunctionTypeInfo;
- if (getter == null)
- return null;
-
- ITargetFunctionObject func = getter.GetObject
(location) as ITargetFunctionObject;
- if (func == null)
- return null;
-
- ITargetObject retval = func.Invoke (new
MonoObject [0], false);
- return retval;
- }
-
- internal ITargetObject Get (StackFrame frame)
- {
- if (!PropertyInfo.CanRead)
- throw new InvalidOperationException ();
-
- MonoFunctionTypeInfo getter =
GetterType.GetTypeInfo () as MonoFunctionTypeInfo;
- if (getter == null)
- return null;
-
- return getter.InvokeStatic (frame, new
MonoObject [0], false);
- }
-
- protected override string MyToString ()
- {
- return String.Format ("{0}:{1}", CanRead,
CanWrite);
- }
- }
}
}
Added: trunk/debugger/backends/mono/MonoEnumObject.cs
===================================================================
--- trunk/debugger/backends/mono/MonoEnumObject.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoEnumObject.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -0,0 +1,38 @@
+using System;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal class MonoEnumObject : MonoObject, ITargetEnumObject
+ {
+ new MonoEnumTypeInfo type;
+
+ public MonoEnumObject (MonoEnumTypeInfo type, TargetLocation
location)
+ : base (type, location)
+ {
+ this.type = type;
+ }
+
+ public ITargetEnumType Type {
+ get {
+ return type.Type;
+ }
+ }
+ public ITargetObject Value {
+ get {
+ return type.GetValue (location);
+ }
+ }
+
+ protected override long GetDynamicSize (ITargetMemoryReader
reader,
+ TargetLocation location,
+ out TargetLocation
dynamic_location)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("{0}", GetType());
+ }
+ }
+}
Added: trunk/debugger/backends/mono/MonoEnumType.cs
===================================================================
--- trunk/debugger/backends/mono/MonoEnumType.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoEnumType.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -0,0 +1,95 @@
+using System;
+using System.Text;
+using R = System.Reflection;
+using C = Mono.CompilerServices.SymbolWriter;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal class MonoEnumType : MonoType, ITargetEnumType
+ {
+ MonoFieldInfo[] fields;
+ MonoFieldInfo[] static_fields;
+
+ public MonoEnumType (MonoSymbolFile file, Type type)
+ : base (file, TargetObjectKind.Enum, type)
+ { }
+
+ public override bool IsByRef {
+ get { return !type.IsValueType; }
+ }
+
+ void get_fields ()
+ {
+ if (fields != null)
+ return;
+
+ int num_fields = 0, num_sfields = 0;
+
+ R.FieldInfo[] finfo = type.GetFields (
+ R.BindingFlags.DeclaredOnly |
R.BindingFlags.Static | R.BindingFlags.Instance |
+ R.BindingFlags.Public |
R.BindingFlags.NonPublic);
+
+ foreach (R.FieldInfo field in finfo) {
+ if (field.IsStatic)
+ num_sfields++;
+ else
+ num_fields++;
+ }
+
+ fields = new MonoFieldInfo [num_fields];
+ static_fields = new MonoFieldInfo [num_sfields];
+
+ int pos = 0, spos = 0;
+ for (int i = 0; i < finfo.Length; i++) {
+ if (finfo [i].IsStatic) {
+ static_fields [spos] = new
MonoFieldInfo (File, spos, i, finfo [i]);
+ spos++;
+ } else {
+ if (finfo[i].Name != "value__")
+ throw new InternalError ("Mono
enum type has instance field with name other than 'value__'.");
+ fields [pos] = new MonoFieldInfo (File,
pos, i, finfo [i]);
+ pos++;
+ }
+ }
+ if (pos > 1)
+ throw new InternalError ("Mono enum type has
more than one instance field.");
+ }
+
+ internal MonoFieldInfo Value {
+ get {
+ get_fields ();
+ return fields[0];
+ }
+ }
+
+ internal MonoFieldInfo[] Members {
+ get {
+ get_fields ();
+ return static_fields;
+ }
+ }
+
+ ITargetFieldInfo ITargetEnumType.Value {
+ get { return Value; }
+ }
+
+ ITargetFieldInfo[] ITargetEnumType.Members {
+ get { return Members; }
+ }
+
+ public ITargetObject GetMember (StackFrame frame, int index)
+ {
+ MonoEnumTypeInfo info = GetTypeInfo () as
MonoEnumTypeInfo;
+ if (info == null)
+ return null;
+
+ return info.GetMember (frame, index);
+ }
+
+ protected override MonoTypeInfo DoGetTypeInfo
(TargetBinaryReader info)
+ {
+ return new MonoEnumTypeInfo (this, info);
+ }
+ }
+
+}
Added: trunk/debugger/backends/mono/MonoEnumTypeInfo.cs
===================================================================
--- trunk/debugger/backends/mono/MonoEnumTypeInfo.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoEnumTypeInfo.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -0,0 +1,96 @@
+using System;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal class MonoEnumTypeInfo : MonoTypeInfo
+ {
+ new public readonly MonoEnumType Type;
+
+ int[] member_offsets;
+ MonoDebuggerInfo debugger_info;
+ bool initialized;
+
+ public MonoEnumTypeInfo (MonoEnumType type, TargetBinaryReader
info)
+ : base (type, info)
+ {
+ this.Type = type;
+
+ debugger_info = type.File.MonoLanguage.MonoDebuggerInfo;
+ }
+
+ void initialize (ITargetAccess target)
+ {
+ if (initialized)
+ return;
+
+ MonoBuiltinTypeInfo builtin =
Type.File.MonoLanguage.BuiltinTypes;
+
+ TargetAddress member_info = target.ReadAddress
(KlassAddress + builtin.KlassFieldOffset);
+ int member_count = 1 + Type.Members.Length;
+ ITargetMemoryReader info = target.ReadMemory
(member_info, member_count * builtin.FieldInfoSize);
+
+ member_offsets = new int [member_count];
+ for (int i = 0; i < member_count; i++) {
+ info.Offset = i * builtin.FieldInfoSize + 2 *
target.TargetAddressSize;
+ member_offsets [i] = info.ReadInteger ();
+ }
+
+ initialized = true;
+ }
+
+ public ITargetObject GetValue (TargetLocation location)
+ {
+ try {
+ initialize (location.TargetAccess);
+
+ MonoFieldInfo finfo = Type.Value;
+ MonoTypeInfo ftype = finfo.Type.GetTypeInfo ();
+ if (ftype == null)
+ return null;
+
+ int offset = member_offsets [finfo.Position];
+ if (!Type.IsByRef)
+ offset -= 2 *
location.TargetAccess.TargetAddressSize;
+ TargetLocation member_loc =
location.GetLocationAtOffset (
+ offset, ftype.Type.IsByRef);
+
+ return ftype.GetObject (member_loc);
+ } catch (TargetException ex) {
+ throw new LocationInvalidException (ex);
+ }
+ }
+
+ public ITargetObject GetMember (StackFrame frame, int index)
+ {
+ try {
+ initialize (frame.TargetAccess);
+ TargetAddress data_address =
frame.Process.CallMethod (
+ debugger_info.ClassGetStaticFieldData,
KlassAddress,
+ TargetAddress.Null);
+
+ MonoFieldInfo finfo = Type.Members [index];
+ MonoTypeInfo ftype = finfo.Type.GetTypeInfo ();
+ if (ftype == null)
+ return null;
+
+ TargetLocation location = new
AbsoluteTargetLocation (
+ frame, data_address);
+ TargetLocation member_loc =
location.GetLocationAtOffset (
+ member_offsets [finfo.Position],
ftype.Type.IsByRef);
+
+ return ftype.GetObject (member_loc);
+ } catch (TargetException ex) {
+ throw new LocationInvalidException (ex);
+ }
+ }
+
+ public override bool HasFixedSize {
+ get { return true; }
+ }
+
+ public override MonoObject GetObject (TargetLocation location)
+ {
+ return new MonoEnumObject (this, location);
+ }
+ }
+}
Added: trunk/debugger/backends/mono/MonoMember.cs
===================================================================
--- trunk/debugger/backends/mono/MonoMember.cs 2005-07-05 22:44:47 UTC (rev
46977)
+++ trunk/debugger/backends/mono/MonoMember.cs 2005-07-05 22:53:57 UTC (rev
46978)
@@ -0,0 +1,285 @@
+using System;
+using System.Text;
+using R = System.Reflection;
+using C = Mono.CompilerServices.SymbolWriter;
+
+namespace Mono.Debugger.Languages.Mono
+{
+ internal abstract class MonoMember : ITargetMemberInfo
+ {
+ public readonly MonoSymbolFile File;
+ public readonly R.MemberInfo MemberInfo;
+ public readonly int Index;
+ public readonly int Position;
+ public readonly bool IsStatic;
+
+ public MonoMember (MonoSymbolFile file, R.MemberInfo minfo, int
index, int pos,
+ bool is_static)
+ {
+ this.File = file;
+ this.MemberInfo = minfo;
+ this.Index = index;
+ this.Position = pos;
+ this.IsStatic = is_static;
+ }
+
+ public abstract MonoType Type {
+ get;
+ }
+
+ ITargetType ITargetMemberInfo.Type {
+ get { return Type; }
+ }
+
+ string ITargetMemberInfo.Name {
+ get { return MemberInfo.Name; }
+ }
+
+ int ITargetMemberInfo.Index {
+ get { return Index; }
+ }
+
+ bool ITargetMemberInfo.IsStatic {
+ get { return IsStatic; }
+ }
+
+ object ITargetMemberInfo.Handle {
+ get { return MemberInfo; }
+ }
+
+ protected abstract string MyToString ();
+
+ public override string ToString ()
+ {
+ return String.Format ("{0} ({1}:{2}:{3}:{4})",
+ GetType (), Type, Index,
IsStatic, MyToString ());
+ }
+ }
+
+ internal class MonoFieldInfo : MonoMember, ITargetFieldInfo
+ {
+ MonoType type;
+
+ public readonly R.FieldInfo FieldInfo;
+
+ public MonoFieldInfo (MonoSymbolFile file, int index, int pos,
R.FieldInfo finfo)
+ : base (file, finfo, index, pos, finfo.IsStatic)
+ {
+ FieldInfo = finfo;
+ type = File.MonoLanguage.LookupMonoType
(finfo.FieldType);
+ }
+
+ public override MonoType Type {
+ get { return type; }
+ }
+
+ int ITargetFieldInfo.Offset {
+ get { return 0; }
+ }
+
+ protected override string MyToString ()
+ {
+ return String.Format ("{0}", type);
+ }
+ }
+
+ internal class MonoMethodInfo : MonoMember, ITargetMethodInfo
+ {
+ public readonly R.MethodBase MethodInfo;
+ public readonly MonoFunctionType FunctionType;
+ public readonly MonoClassType Klass;
+
+ internal MonoMethodInfo (MonoClassType klass, int index,
R.MethodBase minfo)
+ : base (klass.File, minfo, index,
C.MonoDebuggerSupport.GetMethodIndex (minfo),
+ minfo.IsStatic)
+ {
+ Klass = klass;
+ MethodInfo = minfo;
+ FunctionType = new MonoFunctionType (File, Klass,
minfo, Position - 1);
+ }
+
+ public override MonoType Type {
+ get { return FunctionType; }
+ }
+
+ ITargetFunctionType ITargetMethodInfo.Type {
+ get {
+ return FunctionType;
+ }
+ }
+
+ string ITargetMethodInfo.FullName {
+ get {
+ StringBuilder sb = new StringBuilder ();
+ bool first = true;
+ foreach (R.ParameterInfo pinfo in
MethodInfo.GetParameters ()) {
+ if (first)
+ first = false;
+ else
+ sb.Append (",");
+ sb.Append (pinfo.ParameterType);
+ }
+
+ return String.Format ("{0}({1})",
MethodInfo.Name, sb.ToString ());
+ }
+ }
+
+ internal ITargetFunctionObject Get (StackFrame frame)
+ {
+ MonoFunctionTypeInfo func = FunctionType.GetTypeInfo ()
as MonoFunctionTypeInfo;
+ if (func == null)
+ return null;
+
+ return func.GetStaticObject (frame);
+ }
+
+ protected override string MyToString ()
+ {
+ return String.Format ("{0}", FunctionType);
+ }
+ }
+
+ internal class MonoEventInfo : MonoMember, ITargetEventInfo
+ {
+ MonoType type;
+ public readonly MonoClassType Klass;
+ public readonly R.EventInfo EventInfo;
+ public readonly MonoFunctionType AddType, RemoveType;
+
+ internal MonoEventInfo (MonoClassType klass, int index,
R.EventInfo einfo,
+ bool is_static)
+ : base (klass.File, einfo, index, index, is_static)
+ {
+ int pos;
+
+ Klass = klass;
+
+ EventInfo = einfo;
+ type = File.MonoLanguage.LookupMonoType
(einfo.EventHandlerType);
+
+ R.MethodInfo add = EventInfo.GetAddMethod ();
+ pos = C.MonoDebuggerSupport.GetMethodIndex (add);
+ AddType = new MonoFunctionType (File, Klass, add, pos -
1);
+
+ R.MethodInfo remove = EventInfo.GetRemoveMethod ();
+ pos = C.MonoDebuggerSupport.GetMethodIndex (remove);
+ RemoveType = new MonoFunctionType (File, Klass, remove,
pos - 1);
+ }
+
+ public override MonoType Type {
+ get { return type; }
+ }
+
+ ITargetFunctionType ITargetEventInfo.Add {
+ get {
+ return AddType;
+ }
+ }
+
+ ITargetFunctionType ITargetEventInfo.Remove {
+ get {
+ return RemoveType;
+ }
+ }
+
+ protected override string MyToString ()
+ {
+ return String.Format ("{0}:{1}", AddType, RemoveType);
+ }
+ }
+
+ internal class MonoPropertyInfo : MonoMember, ITargetPropertyInfo
+ {
+ MonoType type;
+ public readonly MonoClassType Klass;
+ public readonly R.PropertyInfo PropertyInfo;
+ public readonly MonoFunctionType GetterType, SetterType;
+
+ internal MonoPropertyInfo (MonoClassType klass, int index,
R.PropertyInfo pinfo,
+ bool is_static)
+ : base (klass.File, pinfo, index, index, is_static)
+ {
+ Klass = klass;
+ PropertyInfo = pinfo;
+ type = File.MonoLanguage.LookupMonoType
(pinfo.PropertyType);
+
+ if (PropertyInfo.CanRead) {
+ R.MethodInfo getter = PropertyInfo.GetGetMethod
(true);
+ int pos = C.MonoDebuggerSupport.GetMethodIndex
(getter);
+ GetterType = new MonoFunctionType (File, Klass,
getter, pos - 1);
+ }
+
+ if (PropertyInfo.CanWrite) {
+ R.MethodInfo setter = PropertyInfo.GetSetMethod
(true);
+ int pos = C.MonoDebuggerSupport.GetMethodIndex
(setter);
+ SetterType = new MonoFunctionType (File, Klass,
setter, pos - 1);
+ }
+ }
+
+ public override MonoType Type {
+ get { return type; }
+ }
+
+ public bool CanRead {
+ get { return PropertyInfo.CanRead; }
+ }
+
+ ITargetFunctionType ITargetPropertyInfo.Getter {
+ get {
+ if (!CanRead)
+ throw new InvalidOperationException ();
+
+ return GetterType;
+ }
+ }
+
+ public bool CanWrite {
+ get {
+ return PropertyInfo.CanWrite;
+ }
+ }
+
+ ITargetFunctionType ITargetPropertyInfo.Setter {
+ get {
+ if (!CanWrite)
+ throw new InvalidOperationException ();
+
+ return SetterType;
+ }
+ }
+
+ internal ITargetObject Get (TargetLocation location)
+ {
+ if (!PropertyInfo.CanRead)
+ throw new InvalidOperationException ();
+
+ MonoFunctionTypeInfo getter = GetterType.GetTypeInfo ()
as MonoFunctionTypeInfo;
+ if (getter == null)
+ return null;
+
+ ITargetFunctionObject func = getter.GetObject
(location) as ITargetFunctionObject;
+ if (func == null)
+ return null;
+
+ ITargetObject retval = func.Invoke (new MonoObject [0],
false);
+ return retval;
+ }
+
+ internal ITargetObject Get (StackFrame frame)
+ {
+ if (!PropertyInfo.CanRead)
+ throw new InvalidOperationException ();
+
+ MonoFunctionTypeInfo getter = GetterType.GetTypeInfo ()
as MonoFunctionTypeInfo;
+ if (getter == null)
+ return null;
+
+ return getter.InvokeStatic (frame, new MonoObject [0],
false);
+ }
+
+ protected override string MyToString ()
+ {
+ return String.Format ("{0}:{1}", CanRead, CanWrite);
+ }
+ }
+}
Modified: trunk/debugger/backends/mono/MonoSymbolFile.cs
===================================================================
--- trunk/debugger/backends/mono/MonoSymbolFile.cs 2005-07-05 22:44:47 UTC
(rev 46977)
+++ trunk/debugger/backends/mono/MonoSymbolFile.cs 2005-07-05 22:53:57 UTC
(rev 46978)
@@ -354,6 +354,8 @@
int rank = type.GetArrayRank ();
if (rank > 0)
result = new MonoArrayType (this, type);
+ else if (type.IsEnum)
+ result = new MonoEnumType (this, type);
else
result = new MonoClassType (this, type);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches