Author: martin
Date: 2007-05-02 11:43:14 -0400 (Wed, 02 May 2007)
New Revision: 76574
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backend/MonoThreadManager.cs
trunk/debugger/languages/mono/MonoClassInfo.cs
trunk/debugger/languages/mono/MonoClassObject.cs
trunk/debugger/languages/mono/MonoClassType.cs
trunk/debugger/languages/mono/MonoFunctionType.cs
trunk/debugger/languages/mono/MonoLanguageBackend.cs
trunk/debugger/languages/mono/MonoSymbolFile.cs
Log:
2007-05-02 Martin Baulig <[EMAIL PROTECTED]>
* languages/mono/MonoClassInfo.cs
(MonoClassInfo): Completely redesigned this; we now construct the
`MonoClassInfo' when reading the symbol tables and it replaces the
`ClassEntry' in the symbol table. This means that we don't have
to do any target access when actually using the class.
* languages/mono/MonoLanguageBackend.cs
(MonoLanguageBackend.read_class_entry): Read all the data from the
target and construct the `MonoClassInfo' here, so we don't have to
make any target access when actually using the class.
* languages/mono/MonoClassObject.cs
(MonoClassObject): We now keep a reference to our `MonoClassType',
not our `MonoClassInfo'.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-05-02 15:17:50 UTC (rev 76573)
+++ trunk/debugger/ChangeLog 2007-05-02 15:43:14 UTC (rev 76574)
@@ -1,3 +1,20 @@
+2007-05-02 Martin Baulig <[EMAIL PROTECTED]>
+
+ * languages/mono/MonoClassInfo.cs
+ (MonoClassInfo): Completely redesigned this; we now construct the
+ `MonoClassInfo' when reading the symbol tables and it replaces the
+ `ClassEntry' in the symbol table. This means that we don't have
+ to do any target access when actually using the class.
+
+ * languages/mono/MonoLanguageBackend.cs
+ (MonoLanguageBackend.read_class_entry): Read all the data from the
+ target and construct the `MonoClassInfo' here, so we don't have to
+ make any target access when actually using the class.
+
+ * languages/mono/MonoClassObject.cs
+ (MonoClassObject): We now keep a reference to our `MonoClassType',
+ not our `MonoClassInfo'.
+
2007-04-18 Martin Baulig <[EMAIL PROTECTED]>
Reimplement displays; integrate them with the session code and use
Modified: trunk/debugger/backend/MonoThreadManager.cs
===================================================================
--- trunk/debugger/backend/MonoThreadManager.cs 2007-05-02 15:17:50 UTC (rev
76573)
+++ trunk/debugger/backend/MonoThreadManager.cs 2007-05-02 15:43:14 UTC (rev
76574)
@@ -344,6 +344,7 @@
public readonly int KlassParentOffset;
public readonly int KlassTokenOffset;
public readonly int KlassFieldOffset;
+ public readonly int KlassFieldCountOffset;
public readonly int KlassMethodsOffset;
public readonly int KlassMethodCountOffset;
public readonly int KlassThisArgOffset;
@@ -406,6 +407,8 @@
KlassGenericContainerOffset = reader.ReadInt32 ();
FieldInfoSize = reader.ReadInt32 ();
+ KlassFieldCountOffset = KlassMethodCountOffset - 8;
+
MonoDefaultsCorlibOffset = reader.ReadInt32 ();
MonoDefaultsObjectOffset = reader.ReadInt32 ();
MonoDefaultsByteOffset = reader.ReadInt32 ();
Modified: trunk/debugger/languages/mono/MonoClassInfo.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassInfo.cs 2007-05-02 15:17:50 UTC
(rev 76573)
+++ trunk/debugger/languages/mono/MonoClassInfo.cs 2007-05-02 15:43:14 UTC
(rev 76574)
@@ -6,245 +6,69 @@
{
internal class MonoClassInfo : DebuggerMarshalByRefObject
{
- protected readonly MonoClassType type;
- protected readonly int size;
- internal readonly TargetAddress KlassAddress;
+ public readonly int Token;
+ public readonly TargetAddress KlassAddress;
- int[] field_offsets;
- Hashtable methods;
- MonoDebuggerInfo debugger_info;
- MonoClassInfo parent;
- bool initialized;
+ protected readonly int[] field_offsets;
+ protected readonly Hashtable methods;
+ protected readonly MonoClassInfo parent;
- public MonoClassInfo (MonoClassType type, TargetBinaryReader
info)
+ internal MonoClassInfo (TargetMemoryAccess target,
MonoLanguageBackend mono,
+ int token, TargetAddress klass_address)
{
- this.type = type;
-
- size = info.ReadLeb128 ();
- KlassAddress = new TargetAddress (
- info.TargetInfo.AddressDomain, info.ReadAddress
());
-
- type.File.MonoLanguage.AddClass (KlassAddress, type);
-
- debugger_info = type.File.MonoLanguage.MonoDebuggerInfo;
- }
-
- public MonoClassInfo (MonoClassType type, Thread target,
- TargetAddress klass_address)
- {
- this.type = type;
this.KlassAddress = klass_address;
+ this.Token = token;
- MonoLanguageBackend mono = type.File.MonoLanguage;
+ TargetAddress parent_klass = target.ReadAddress (
+ KlassAddress +
mono.MonoMetadataInfo.KlassParentOffset);
+ if (!parent_klass.IsNull)
+ parent = mono.GetClassInfo (target,
parent_klass);
- int offset =
mono.MonoMetadataInfo.KlassInstanceSizeOffset;
- size = target.ReadInteger (klass_address + offset);
-
- type.File.MonoLanguage.AddClass (KlassAddress, type);
-
- debugger_info = mono.MonoDebuggerInfo;
-
- if (type.ParentType != null) {
- TargetAddress parent_klass = target.ReadAddress
(
- klass_address +
mono.MonoMetadataInfo.KlassParentOffset);
- type.MonoParentType.ClassResolved (target,
parent_klass);
- }
-
- do_initialize (target, null);
- }
-
- void initialize (Thread target)
- {
- if (initialized)
- return;
-
- target.ThreadServant.Invoke (do_initialize, null);
- }
-
- object do_initialize (Thread target, object data)
- {
- if (type.ParentType != null) {
- parent = type.MonoParentType.GetTypeInfo ();
- parent.do_initialize (target, data);
- }
-
- MonoMetadataInfo metadata_info =
Type.File.MonoLanguage.MonoMetadataInfo;
-
TargetAddress field_info = target.ReadAddress (
- KlassAddress + metadata_info.KlassFieldOffset);
- int field_count = type.Fields.Length +
type.StaticFields.Length;
- TargetBinaryReader info = target.ReadMemory (
- field_info, field_count *
metadata_info.FieldInfoSize).GetReader ();
+ KlassAddress +
mono.MonoMetadataInfo.KlassFieldOffset);
+ int field_count = target.ReadInteger (
+ KlassAddress +
mono.MonoMetadataInfo.KlassFieldCountOffset);
+ TargetBinaryReader field_blob = target.ReadMemory (
+ field_info, field_count *
mono.MonoMetadataInfo.FieldInfoSize).GetReader ();
+
field_offsets = new int [field_count];
for (int i = 0; i < field_count; i++) {
- info.Position = i * metadata_info.FieldInfoSize
+
+ field_blob.Position = i *
mono.MonoMetadataInfo.FieldInfoSize +
2 * target.TargetInfo.TargetAddressSize;
- field_offsets [i] = info.ReadInt32 ();
+ field_offsets [i] = field_blob.ReadInt32 ();
}
TargetAddress method_info = target.ReadAddress (
- KlassAddress +
metadata_info.KlassMethodsOffset);
+ KlassAddress +
mono.MonoMetadataInfo.KlassMethodsOffset);
int method_count = target.ReadInteger (
- KlassAddress +
metadata_info.KlassMethodCountOffset);
+ KlassAddress +
mono.MonoMetadataInfo.KlassMethodCountOffset);
+
TargetBlob blob = target.ReadMemory (
method_info, method_count *
target.TargetInfo.TargetAddressSize);
methods = new Hashtable ();
- TargetReader reader = new TargetReader (blob.Contents,
target.TargetInfo);
+ TargetReader method_reader = new TargetReader
(blob.Contents, target.TargetInfo);
for (int i = 0; i < method_count; i++) {
- TargetAddress address = reader.ReadAddress ();
+ TargetAddress address =
method_reader.ReadAddress ();
- TargetBlob method_blob = target.ReadMemory (
- address + 4, 4);
- int token = method_blob.GetReader ().ReadInt32
();
- if (token == 0)
+ int mtoken = target.ReadInteger (address + 4);
+ if (mtoken == 0)
continue;
- methods.Add (token, address);
+ methods.Add (mtoken, address);
}
-
- initialized = true;
- return null;
}
- int GetFieldOffset (TargetFieldInfo field)
- {
- if (field.Position < type.FirstField)
- return parent.GetFieldOffset (field);
-
- return field_offsets [field.Position - type.FirstField];
+ public int[] FieldOffsets {
+ get { return field_offsets; }
}
- internal TargetObject GetField (Thread target, TargetLocation
location,
- TargetFieldInfo finfo)
- {
- initialize (target);
-
- int offset = GetFieldOffset (finfo);
- if (!type.IsByRef)
- offset -= 2 *
target.TargetInfo.TargetAddressSize;
- TargetLocation field_loc = location.GetLocationAtOffset
(offset);
-
- if (finfo.Type.IsByRef)
- field_loc = field_loc.GetDereferencedLocation
(target);
-
- if (field_loc.Address.IsNull)
- return null;
-
- return finfo.Type.GetObject (field_loc);
- }
-
- internal void SetField (Thread target, TargetLocation location,
- TargetFieldInfo finfo, TargetObject obj)
- {
- initialize (target);
-
- int offset = GetFieldOffset (finfo);
- if (!type.IsByRef)
- offset -= 2 *
target.TargetInfo.TargetAddressSize;
- TargetLocation field_loc = location.GetLocationAtOffset
(offset);
-
- if (finfo.Type.IsByRef)
- field_loc = field_loc.GetDereferencedLocation
(target);
-
- finfo.Type.SetObject (target, field_loc, obj);
- }
-
- internal TargetObject GetStaticField (Thread target,
TargetFieldInfo finfo)
- {
- initialize (target);
-
- TargetAddress data_address = target.CallMethod (
- debugger_info.ClassGetStaticFieldData,
KlassAddress,
- TargetAddress.Null);
-
- int offset = GetFieldOffset (finfo);
-
- TargetLocation location = new AbsoluteTargetLocation
(data_address);
- TargetLocation field_loc = location.GetLocationAtOffset
(offset);
-
- if (finfo.Type.IsByRef)
- field_loc = field_loc.GetDereferencedLocation
(target);
-
- return finfo.Type.GetObject (field_loc);
- }
-
- internal void SetStaticField (Thread target, TargetFieldInfo
finfo,
- TargetObject obj)
- {
- initialize (target);
-
- int offset = GetFieldOffset (finfo);
-
- TargetAddress data_address = target.CallMethod (
- debugger_info.ClassGetStaticFieldData,
KlassAddress,
- TargetAddress.Null);
-
- TargetLocation location = new AbsoluteTargetLocation
(data_address);
- TargetLocation field_loc = location.GetLocationAtOffset
(offset);
-
- if (finfo.Type.IsByRef)
- field_loc = field_loc.GetDereferencedLocation
(target);
-
- finfo.Type.SetObject (target, field_loc, obj);
- }
-
internal TargetAddress GetMethodAddress (Thread target, int
token)
{
- initialize (target);
if (!methods.Contains (token))
throw new InternalError ();
return (TargetAddress) methods [token];
}
-
- public MonoClassType Type {
- get { return type; }
- }
-
- public int Size {
- get { return size; }
- }
-
- public TargetObject GetObject (TargetLocation location)
- {
- return new MonoClassObject (this, location);
- }
-
- internal MonoClassObject GetParentObject (Thread target,
TargetLocation location)
- {
- initialize (target);
-
- if (parent == null)
- throw new InvalidOperationException ();
-
- if (!type.IsByRef && parent.Type.IsByRef) {
- TargetAddress boxed = target.CallMethod (
- debugger_info.GetBoxedObjectMethod,
- KlassAddress, location.Address);
- TargetLocation new_loc = new
AbsoluteTargetLocation (boxed);
- return new MonoClassObject (parent, new_loc);
- }
-
- return new MonoClassObject (parent, location);
- }
-
- internal MonoClassObject GetCurrentObject (Thread target,
TargetLocation location)
- {
- initialize (target);
-
- // location.Address resolves to the address of the
MonoObject,
- // dereferencing it once gives us the vtable,
dereferencing it
- // twice the class.
- TargetAddress address;
- address = target.ReadAddress (location.Address);
- address = target.ReadAddress (address);
-
- TargetType current = type.File.MonoLanguage.GetClass
(target, address);
- if (current == null)
- return null;
-
- return (MonoClassObject) current.GetObject (location);
- }
}
}
Modified: trunk/debugger/languages/mono/MonoClassObject.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassObject.cs 2007-05-02 15:17:50 UTC
(rev 76573)
+++ trunk/debugger/languages/mono/MonoClassObject.cs 2007-05-02 15:43:14 UTC
(rev 76574)
@@ -5,17 +5,17 @@
{
internal class MonoClassObject : TargetClassObject
{
- new MonoClassInfo type;
+ new MonoClassType type;
- public MonoClassObject (MonoClassInfo type, TargetLocation
location)
- : base (type.Type, location)
+ public MonoClassObject (MonoClassType type, TargetLocation
location)
+ : base (type, location)
{
this.type = type;
}
public override TargetClassObject GetParentObject (Thread
target)
{
- if (!type.Type.HasParent)
+ if (!type.HasParent)
return null;
return type.GetParentObject (target, Location);
@@ -23,7 +23,7 @@
public override TargetClassObject GetCurrentObject (Thread
target)
{
- if (!type.Type.IsByRef)
+ if (!type.IsByRef)
return null;
return type.GetCurrentObject (target, Location);
@@ -41,7 +41,7 @@
}
internal TargetAddress KlassAddress {
- get { return type.KlassAddress; }
+ get { return type.MonoClassInfo.KlassAddress; }
}
internal override long GetDynamicSize (Thread target,
TargetBlob blob,
Modified: trunk/debugger/languages/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassType.cs 2007-05-02 15:17:50 UTC
(rev 76573)
+++ trunk/debugger/languages/mono/MonoClassType.cs 2007-05-02 15:43:14 UTC
(rev 76574)
@@ -40,6 +40,13 @@
parent_type = file.MonoLanguage.LookupMonoType
(type.BaseType) as MonoClassType;
}
+ public MonoClassType (TargetMemoryAccess target, MonoSymbolFile
file,
+ Cecil.TypeDefinition type, TargetAddress
klass)
+ : this (file, type)
+ {
+ type_info = file.MonoLanguage.GetClassInfo (target,
klass);
+ }
+
public Cecil.TypeDefinition Type {
get { return type; }
}
@@ -140,19 +147,6 @@
}
}
- public override TargetObject GetStaticField (Thread target,
TargetFieldInfo field)
- {
- MonoClassInfo info = GetTypeInfo ();
- return info.GetStaticField (target, field);
- }
-
- public override void SetStaticField (Thread target,
TargetFieldInfo field,
- TargetObject obj)
- {
- MonoClassInfo info = GetTypeInfo ();
- info.SetStaticField (target, field, obj);
- }
-
public int CountMethods {
get {
if (parent_type != null)
@@ -372,17 +366,18 @@
}
}
- public MonoClassInfo GetTypeInfo ()
- {
- if (type_info != null)
- return type_info;
- type_info = DoGetTypeInfo ();
+ internal MonoClassInfo MonoClassInfo {
+ get {
+ if (type_info != null)
+ return type_info;
+ type_info = file.MonoLanguage.GetClassInfo
(type);
- if (type_info != null)
- return type_info;
+ if (type_info != null)
+ return type_info;
- throw new TargetException (
- TargetError.LocationInvalid, "Can't find class
`{0}'", Name);
+ throw new TargetException (
+ TargetError.LocationInvalid, "Can't
find class `{0}'", Name);
+ }
}
internal bool ResolveClass ()
@@ -395,32 +390,19 @@
return false;
}
- type_info = DoGetTypeInfo ();
+ type_info = file.MonoLanguage.GetClassInfo (type);
return type_info != null;
}
internal MonoClassInfo ClassResolved (Thread target,
TargetAddress klass)
{
- type_info = new MonoClassInfo (this, target, klass);
+ type_info = File.MonoLanguage.GetClassInfo (target,
klass);
return type_info;
}
- protected MonoClassInfo DoGetTypeInfo ()
- {
- TargetBinaryReader info = file.GetTypeInfo (type);
- if (info == null)
- return null;
-
- info.Position = 8;
- info.ReadLeb128 ();
-
- return new MonoClassInfo (this, info);
- }
-
internal override TargetObject GetObject (TargetLocation
location)
{
- MonoClassInfo info = GetTypeInfo ();
- return info.GetObject (location);
+ return new MonoClassObject (this, location);
}
public override TargetMemberInfo FindMember (string name, bool
search_static,
@@ -458,7 +440,7 @@
}
internal static TargetType ReadMonoClass (MonoLanguageBackend
language,
- Thread target,
TargetAddress address)
+ TargetMemoryAccess
target, TargetAddress address)
{
TargetReader reader = new TargetReader (
target.ReadMemory (address,
language.MonoMetadataInfo.KlassSize));
@@ -524,5 +506,111 @@
return null;
}
+
+ internal int GetFieldOffset (TargetFieldInfo field)
+ {
+ if (field.Position < FirstField)
+ return parent_type.GetFieldOffset (field);
+
+ return MonoClassInfo.FieldOffsets [field.Position -
FirstField];
+ }
+
+ internal TargetObject GetField (Thread target, TargetLocation
location,
+ TargetFieldInfo finfo)
+ {
+ int offset = GetFieldOffset (finfo);
+ if (!IsByRef)
+ offset -= 2 *
target.TargetInfo.TargetAddressSize;
+ TargetLocation field_loc = location.GetLocationAtOffset
(offset);
+
+ if (finfo.Type.IsByRef)
+ field_loc = field_loc.GetDereferencedLocation
(target);
+
+ if (field_loc.Address.IsNull)
+ return null;
+
+ return finfo.Type.GetObject (field_loc);
+ }
+
+ internal void SetField (Thread target, TargetLocation location,
+ TargetFieldInfo finfo, TargetObject obj)
+ {
+ int offset = GetFieldOffset (finfo);
+ if (!IsByRef)
+ offset -= 2 *
target.TargetInfo.TargetAddressSize;
+ TargetLocation field_loc = location.GetLocationAtOffset
(offset);
+
+ if (finfo.Type.IsByRef)
+ field_loc = field_loc.GetDereferencedLocation
(target);
+
+ finfo.Type.SetObject (target, field_loc, obj);
+ }
+
+ public override TargetObject GetStaticField (Thread target,
TargetFieldInfo finfo)
+ {
+ TargetAddress data_address = target.CallMethod (
+
File.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
+ MonoClassInfo.KlassAddress, TargetAddress.Null);
+
+ int offset = GetFieldOffset (finfo);
+
+ TargetLocation location = new AbsoluteTargetLocation
(data_address);
+ TargetLocation field_loc = location.GetLocationAtOffset
(offset);
+
+ if (finfo.Type.IsByRef)
+ field_loc = field_loc.GetDereferencedLocation
(target);
+
+ return finfo.Type.GetObject (field_loc);
+ }
+
+ public override void SetStaticField (Thread target,
TargetFieldInfo finfo,
+ TargetObject obj)
+ {
+ int offset = GetFieldOffset (finfo);
+
+ TargetAddress data_address = target.CallMethod (
+
File.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
+ MonoClassInfo.KlassAddress, TargetAddress.Null);
+
+ TargetLocation location = new AbsoluteTargetLocation
(data_address);
+ TargetLocation field_loc = location.GetLocationAtOffset
(offset);
+
+ if (finfo.Type.IsByRef)
+ field_loc = field_loc.GetDereferencedLocation
(target);
+
+ 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,
+ MonoClassInfo.KlassAddress,
location.Address);
+ TargetLocation new_loc = new
AbsoluteTargetLocation (boxed);
+ return new MonoClassObject (parent_type,
new_loc);
+ }
+
+ return new MonoClassObject (parent_type, location);
+ }
+
+ internal MonoClassObject GetCurrentObject (Thread target,
TargetLocation location)
+ {
+ // location.Address resolves to the address of the
MonoObject,
+ // dereferencing it once gives us the vtable,
dereferencing it
+ // twice the class.
+ TargetAddress address;
+ address = target.ReadAddress (location.Address);
+ address = target.ReadAddress (address);
+
+ TargetType current = File.MonoLanguage.GetClass
(target, address);
+ if (current == null)
+ return null;
+
+ return (MonoClassObject) current.GetObject (location);
+ }
}
}
Modified: trunk/debugger/languages/mono/MonoFunctionType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoFunctionType.cs 2007-05-02 15:17:50 UTC
(rev 76573)
+++ trunk/debugger/languages/mono/MonoFunctionType.cs 2007-05-02 15:43:14 UTC
(rev 76574)
@@ -110,11 +110,7 @@
public override TargetAddress GetMethodAddress (Thread target)
{
- MonoClassInfo info = klass.GetTypeInfo ();
- if (info == null)
- throw new LocationInvalidException ();
-
- return info.GetMethodAddress (target, Token);
+ return klass.MonoClassInfo.GetMethodAddress (target,
Token);
}
internal override TargetObject GetObject (TargetLocation
location)
Modified: trunk/debugger/languages/mono/MonoLanguageBackend.cs
===================================================================
--- trunk/debugger/languages/mono/MonoLanguageBackend.cs 2007-05-02
15:17:50 UTC (rev 76573)
+++ trunk/debugger/languages/mono/MonoLanguageBackend.cs 2007-05-02
15:43:14 UTC (rev 76574)
@@ -57,7 +57,7 @@
int object_size = 2 *
corlib.TargetInfo.TargetAddressSize;
Cecil.TypeDefinition object_type =
corlib.ModuleDefinition.Types ["System.Object"];
ObjectType = new MonoObjectType (corlib, object_type,
object_size);
- ObjectClass = new MonoClassType (corlib, object_type);
+ ObjectClass = new MonoClassType (memory, corlib,
object_type, klass);
language.AddCoreType (ObjectClass, object_type, klass);
mono_defaults.Offset = info.MonoDefaultsByteOffset;
@@ -160,7 +160,7 @@
mono_defaults.Offset = info.MonoDefaultsArrayOffset;
klass = mono_defaults.ReadAddress ();
Cecil.TypeDefinition array_type =
corlib.ModuleDefinition.Types ["System.Array"];
- ArrayType = new MonoClassType (corlib, array_type);
+ ArrayType = new MonoClassType (memory, corlib,
array_type, klass);
language.AddCoreType (ArrayType, array_type, klass);
mono_defaults.Offset = info.MonoDefaultsDelegateOffset;
@@ -172,7 +172,7 @@
mono_defaults.Offset = info.MonoDefaultsExceptionOffset;
klass = mono_defaults.ReadAddress ();
Cecil.TypeDefinition exception_type =
corlib.ModuleDefinition.Types ["System.Exception"];
- ExceptionType = new MonoClassType (corlib,
exception_type);
+ ExceptionType = new MonoClassType (memory, corlib,
exception_type, klass);
language.AddCoreType (ExceptionType, exception_type,
klass);
}
}
@@ -185,6 +185,8 @@
Hashtable assembly_hash;
Hashtable assembly_by_name;
Hashtable class_hash;
+ Hashtable class_info_by_addr;
+ Hashtable class_info_by_type;
MonoSymbolFile corlib;
MonoBuiltinTypeInfo builtin_types;
@@ -314,30 +316,31 @@
return mono_type;
}
- public void AddClass (TargetAddress klass_address, TargetType
type)
- {
- if (!class_hash.Contains (klass_address))
- class_hash.Add (klass_address, type);
- }
-
internal void AddCoreType (TargetType type,
Cecil.TypeDefinition typedef,
TargetAddress klass)
{
corlib.AddType (type, typedef);
- AddClass (klass, type);
+ if (!class_hash.Contains (klass))
+ class_hash.Add (klass, type);
}
- public TargetType GetClass (Thread target, TargetAddress
klass_address)
+ public TargetType GetClass (TargetMemoryAccess target,
TargetAddress klass_address)
{
TargetType type = (TargetType) class_hash
[klass_address];
if (type != null)
return type;
try {
- return MonoClassType.ReadMonoClass (this,
target, klass_address);
+ type = MonoClassType.ReadMonoClass (this,
target, klass_address);
} catch {
return null;
}
+
+ if (type == null)
+ return null;
+
+ class_hash.Add (klass_address, type);
+ return type;
}
public MonoSymbolFile GetImage (TargetAddress address)
@@ -362,6 +365,8 @@
assembly_hash = new Hashtable ();
assembly_by_name = new Hashtable ();
class_hash = new Hashtable ();
+ class_info_by_addr = new Hashtable ();
+ class_info_by_type = new Hashtable ();
initialized = true;
}
@@ -546,7 +551,7 @@
break;
case DataItemType.Class:
- read_class_entry (reader);
+ read_class_entry (memory, reader);
break;
case DataItemType.Wrapper:
@@ -571,10 +576,8 @@
file.AddRangeEntry (reader, contents);
}
- void read_class_entry (TargetReader reader)
+ void read_class_entry (TargetMemoryAccess memory, TargetReader
reader)
{
- int size = reader.BinaryReader.PeekInt32 ();
- byte[] contents = reader.BinaryReader.PeekBuffer (size);
reader.BinaryReader.ReadInt32 ();
int file_idx = reader.BinaryReader.ReadInt32 ();
@@ -585,7 +588,11 @@
if (file == null)
return;
- file.AddClassEntry (reader, contents);
+ reader.BinaryReader.ReadLeb128 ();
+ reader.BinaryReader.ReadLeb128 ();
+ TargetAddress klass_address = reader.ReadAddress ();
+
+ GetClassInfo (memory, klass_address);
}
void read_wrapper_entry (TargetMemoryAccess memory,
TargetReader reader)
@@ -595,6 +602,40 @@
reader.BinaryReader.ReadInt32 ();
corlib.AddWrapperEntry (memory, reader, contents);
}
+
+ internal MonoClassInfo GetClassInfo (TargetMemoryAccess memory,
TargetAddress klass_address)
+ {
+ MonoClassInfo info = (MonoClassInfo) class_info_by_addr
[klass_address];
+ if (info != null)
+ return info;
+
+ int token = memory.ReadInteger (
+ klass_address +
MonoMetadataInfo.KlassTokenOffset);
+
+ TargetAddress image = memory.ReadAddress
(klass_address);
+ MonoSymbolFile file = GetImage (image);
+ if (file == null)
+ return null;
+
+ if ((token & 0xff000000) != 0x02000000)
+ throw new InternalError ();
+ token &= 0x00ffffff;
+
+ Cecil.TypeDefinition tdef =
file.ModuleDefinition.LookupByToken (
+ Cecil.Metadata.TokenType.TypeDef, (int) token)
as Cecil.TypeDefinition;
+ if (tdef == null)
+ throw new InternalError ();
+
+ info = new MonoClassInfo (memory, this, token,
klass_address);
+ class_info_by_addr.Add (klass_address, info);
+ class_info_by_type.Add (tdef, info);
+ return info;
+ }
+
+ internal MonoClassInfo GetClassInfo (Cecil.TypeDefinition type)
+ {
+ return (MonoClassInfo) class_info_by_type [type];
+ }
#endregion
#region jit breakpoint handling
Modified: trunk/debugger/languages/mono/MonoSymbolFile.cs
===================================================================
--- trunk/debugger/languages/mono/MonoSymbolFile.cs 2007-05-02 15:17:50 UTC
(rev 76573)
+++ trunk/debugger/languages/mono/MonoSymbolFile.cs 2007-05-02 15:43:14 UTC
(rev 76574)
@@ -219,7 +219,6 @@
ArrayList ranges;
ArrayList wrappers;
Hashtable type_hash;
- Hashtable class_entry_hash;
ArrayList sources;
Hashtable source_hash;
Hashtable source_file_hash;
@@ -242,7 +241,6 @@
wrappers = new ArrayList ();
range_hash = new Hashtable ();
type_hash = new Hashtable ();
- class_entry_hash = new Hashtable ();
Index = memory.ReadInteger (address);
address += int_size;
@@ -363,12 +361,6 @@
wrappers.Add (wrapper);
}
- internal void AddClassEntry (TargetReader reader, byte[]
contents)
- {
- ClassEntry entry = new ClassEntry (this, reader,
contents);
- class_entry_hash.Add (new TypeHashEntry (entry), entry);
- }
-
public TargetType LookupMonoType (Cecil.TypeReference type)
{
TargetType result = (TargetType) type_hash [type];
@@ -390,23 +382,17 @@
return null;
}
- type_hash.Add (type, result);
+ if (!type_hash.Contains (type))
+ type_hash.Add (type, result);
return result;
}
public void AddType (TargetType type, Cecil.TypeDefinition
typedef)
{
- type_hash.Add (typedef, type);
+ if (!type_hash.Contains (typedef))
+ type_hash.Add (typedef, type);
}
- public TargetBinaryReader GetTypeInfo (Cecil.TypeDefinition
type)
- {
- ClassEntry entry = (ClassEntry) class_entry_hash [new
TypeHashEntry (type)];
- if (entry == null)
- return null;
- return entry.Contents;
- }
-
void ensure_sources ()
{
if (sources != null)
@@ -1365,11 +1351,6 @@
Token = (int) (type.MetadataToken.TokenType +
type.MetadataToken.RID);
}
- public TypeHashEntry (ClassEntry entry)
- {
- Token = entry.Token;
- }
-
public TypeHashEntry (int token)
{
Token = token;
@@ -1392,35 +1373,6 @@
}
}
- protected class ClassEntry
- {
- public readonly MonoSymbolFile File;
- public readonly int Token;
- public readonly int InstanceSize;
- public readonly TargetAddress KlassAddress;
- readonly byte[] contents;
-
- public ClassEntry (MonoSymbolFile file, TargetReader
reader, byte[] contents)
- {
- this.File = file;
- this.contents = contents;
-
- Token = reader.BinaryReader.ReadLeb128 ();
- InstanceSize = reader.BinaryReader.ReadLeb128
();
- KlassAddress = reader.ReadAddress ();
- }
-
- public TargetBinaryReader Contents {
- get { return new TargetBinaryReader (contents,
File.TargetInfo); }
- }
-
- public override string ToString ()
- {
- return String.Format ("ClassEntry
[{0}:{1:x}:{2}:{3}]",
- File, Token,
InstanceSize, KlassAddress);
- }
- }
-
private class MonoSymbolTable : SymbolTable
{
MonoSymbolFile file;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches