Author: martin
Date: 2007-10-09 10:05:52 -0400 (Tue, 09 Oct 2007)
New Revision: 87164
Modified:
trunk/debugger/ChangeLog
trunk/debugger/languages/mono/MonoClassInfo.cs
trunk/debugger/languages/mono/MonoClassObject.cs
trunk/debugger/languages/mono/MonoClassType.cs
trunk/debugger/languages/mono/MonoLanguageBackend.cs
trunk/debugger/languages/mono/MonoSymbolFile.cs
Log:
2007-10-09 Martin Baulig <[EMAIL PROTECTED]>
* languages/mono/MonoClassInfo.cs
(MonoClassInfo.ClassType): New public property.
(MonoClassInfo.GetParent): New public method; compute the parent
on-the-fly when it's needed.
* languages/mono/MonoClassObject.cs
(MonoClassObject): The .ctor now takes a `MonoClassInfo' argument.
(MonoClassObject.GetParentObject): Implement this here.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-10-09 14:05:01 UTC (rev 87163)
+++ trunk/debugger/ChangeLog 2007-10-09 14:05:52 UTC (rev 87164)
@@ -1,3 +1,14 @@
+2007-10-09 Martin Baulig <[EMAIL PROTECTED]>
+
+ * languages/mono/MonoClassInfo.cs
+ (MonoClassInfo.ClassType): New public property.
+ (MonoClassInfo.GetParent): New public method; compute the parent
+ on-the-fly when it's needed.
+
+ * languages/mono/MonoClassObject.cs
+ (MonoClassObject): The .ctor now takes a `MonoClassInfo' argument.
+ (MonoClassObject.GetParentObject): Implement this here.
+
2007-10-05 Martin Baulig <[EMAIL PROTECTED]>
* languages/mono/MonoSymbolFile.cs
Modified: trunk/debugger/languages/mono/MonoClassInfo.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassInfo.cs 2007-10-09 14:05:01 UTC
(rev 87163)
+++ trunk/debugger/languages/mono/MonoClassInfo.cs 2007-10-09 14:05:52 UTC
(rev 87164)
@@ -8,13 +8,15 @@
{
public readonly MonoSymbolFile SymbolFile;
public readonly TargetAddress KlassAddress;
- public readonly TargetAddress ParentClass;
public readonly TargetAddress GenericContainer;
public readonly TargetAddress GenericClass;
public readonly Cecil.TypeDefinition CecilType;
- public readonly TargetType Type;
+ MonoClassType type;
+
+ MonoClassInfo parent_info;
+ TargetAddress parent_klass = TargetAddress.Null;
int[] field_offsets;
Hashtable methods;
@@ -40,20 +42,28 @@
if (typedef == null)
throw new InternalError ();
- return new MonoClassInfo (file, typedef, target,
reader, klass_address);
+ MonoClassInfo info = new MonoClassInfo (
+ file, typedef, target, reader, klass_address);
+ info.type = file.LookupMonoClass (typedef);
+ return info;
}
public static MonoClassInfo ReadClassInfo (MonoSymbolFile file,
Cecil.TypeDefinition
typedef,
TargetMemoryAccess
target,
- TargetAddress
klass_address)
+ TargetAddress
klass_address,
+ out MonoClassType
type)
{
- MonoMetadataInfo info =
file.MonoLanguage.MonoMetadataInfo;
-
+ MonoMetadataInfo metadata =
file.MonoLanguage.MonoMetadataInfo;
TargetReader reader = new TargetReader (
- target.ReadMemory (klass_address,
info.KlassSize));
+ target.ReadMemory (klass_address,
metadata.KlassSize));
- return new MonoClassInfo (file, typedef, target,
reader, klass_address);
+ MonoClassInfo info = new MonoClassInfo (
+ file, typedef, target, reader, klass_address);
+
+ type = new MonoClassType (file, typedef, info);
+ info.type = type;
+ return info;
}
protected MonoClassInfo (MonoSymbolFile file,
Cecil.TypeDefinition typedef,
@@ -74,9 +84,12 @@
GenericClass = reader.PeekAddress
(info.KlassGenericClassOffset);
GenericContainer = reader.PeekAddress
(info.KlassGenericContainerOffset);
- ParentClass = reader.PeekAddress
(info.KlassParentOffset);
}
+ public MonoClassType ClassType {
+ get { return type; }
+ }
+
public bool IsGenericClass {
get { return !GenericClass.IsNull; }
}
@@ -145,5 +158,23 @@
throw new InternalError ();
return (TargetAddress) methods [token];
}
+
+ void get_parent (TargetMemoryAccess target)
+ {
+ if (!parent_klass.IsNull)
+ return;
+
+ MonoMetadataInfo metadata =
SymbolFile.MonoLanguage.MonoMetadataInfo;
+ parent_klass = target.ReadAddress (
+ KlassAddress + metadata.KlassParentOffset);
+
+ parent_info = ReadClassInfo (SymbolFile.MonoLanguage,
target, parent_klass);
+ }
+
+ public MonoClassInfo GetParent (TargetMemoryAccess target)
+ {
+ get_parent (target);
+ return parent_info;
+ }
}
}
Modified: trunk/debugger/languages/mono/MonoClassObject.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassObject.cs 2007-10-09 14:05:01 UTC
(rev 87163)
+++ trunk/debugger/languages/mono/MonoClassObject.cs 2007-10-09 14:05:52 UTC
(rev 87164)
@@ -6,11 +6,14 @@
internal class MonoClassObject : TargetClassObject
{
new MonoClassType type;
+ MonoClassInfo info;
- public MonoClassObject (MonoClassType type, TargetLocation
location)
+ public MonoClassObject (MonoClassType type, MonoClassInfo info,
+ TargetLocation location)
: base (type, location)
{
this.type = type;
+ this.info = info;
}
public override TargetClassObject GetParentObject (Thread
target)
@@ -18,7 +21,21 @@
if (!type.HasParent || !type.IsByRef)
return null;
- return type.GetParentObject (target, Location);
+ MonoClassInfo parent_info = info.GetParent (target);
+ if (parent_info == null)
+ return null;
+
+ MonoClassType parent_type = parent_info.ClassType;
+
+ if (!type.IsByRef && parent_type.IsByRef) {
+ TargetAddress boxed = target.CallMethod (
+
type.File.MonoLanguage.MonoDebuggerInfo.GetBoxedObjectMethod,
+ info.KlassAddress, Location.GetAddress
(target).Address);
+ TargetLocation new_loc = new
AbsoluteTargetLocation (boxed);
+ return new MonoClassObject (parent_type,
parent_info, new_loc);
+ }
+
+ return new MonoClassObject (parent_type, parent_info,
Location);
}
public override TargetClassObject GetCurrentObject
(TargetMemoryAccess target)
Modified: trunk/debugger/languages/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassType.cs 2007-10-09 14:05:01 UTC
(rev 87163)
+++ trunk/debugger/languages/mono/MonoClassType.cs 2007-10-09 14:05:52 UTC
(rev 87164)
@@ -409,9 +409,11 @@
return class_info;
}
- protected override TargetObject DoGetObject (TargetMemoryAccess
target, TargetLocation location)
+ protected override TargetObject DoGetObject (TargetMemoryAccess
target,
+ TargetLocation
location)
{
- return new MonoClassObject (this, location);
+ ResolveClass (target, true);
+ return new MonoClassObject (this, class_info, location);
}
public override TargetMemberInfo FindMember (string name, bool
search_static,
@@ -524,22 +526,6 @@
finfo.Type.SetObject (target, field_loc, obj);
}
- internal MonoClassObject GetParentObject (Thread target,
TargetLocation location)
- {
- if (parent_type == null)
- throw new InvalidOperationException ();
-
- if (!IsByRef && parent_type.IsByRef) {
- TargetAddress boxed = target.CallMethod (
-
File.MonoLanguage.MonoDebuggerInfo.GetBoxedObjectMethod,
- class_info.KlassAddress,
location.GetAddress (target).Address);
- TargetLocation new_loc = new
AbsoluteTargetLocation (boxed);
- return new MonoClassObject (parent_type,
new_loc);
- }
-
- return new MonoClassObject (parent_type, location);
- }
-
internal MonoClassObject GetCurrentObject (TargetMemoryAccess
target, TargetLocation location)
{
// location.Address resolves to the address of the
MonoObject,
Modified: trunk/debugger/languages/mono/MonoLanguageBackend.cs
===================================================================
--- trunk/debugger/languages/mono/MonoLanguageBackend.cs 2007-10-09
14:05:01 UTC (rev 87163)
+++ trunk/debugger/languages/mono/MonoLanguageBackend.cs 2007-10-09
14:05:52 UTC (rev 87164)
@@ -651,11 +651,12 @@
internal MonoClassType CreateCoreType (MonoSymbolFile file,
Cecil.TypeDefinition typedef,
TargetMemoryAccess
memory, TargetAddress klass)
{
- MonoClassInfo info = MonoClassInfo.ReadClassInfo (file,
typedef, memory, klass);
+ MonoClassType type;
+ MonoClassInfo info = MonoClassInfo.ReadClassInfo (
+ file, typedef, memory, klass, out type);
class_info_by_addr.Add (klass, info);
class_info_by_type.Add (typedef, info);
- MonoClassType type = new MonoClassType (file, typedef,
info);
return type;
}
#endregion
Modified: trunk/debugger/languages/mono/MonoSymbolFile.cs
===================================================================
--- trunk/debugger/languages/mono/MonoSymbolFile.cs 2007-10-09 14:05:01 UTC
(rev 87163)
+++ trunk/debugger/languages/mono/MonoSymbolFile.cs 2007-10-09 14:05:52 UTC
(rev 87164)
@@ -382,9 +382,8 @@
if (class_type != null)
return class_type;
- MonoFundamentalType fundamental = type as
MonoFundamentalType;
- if (fundamental != null)
- return fundamental.MonoClassType;
+ if (type.HasClassType)
+ return (MonoClassType) type.ClassType;
throw new InternalError ("UNKNOWN TYPE: {0}", type);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches