Author: martin
Date: 2008-01-25 15:09:04 -0500 (Fri, 25 Jan 2008)
New Revision: 93954
Modified:
branches/martin/debugger-terrania/debugger/ChangeLog
branches/martin/debugger-terrania/debugger/backend/SingleSteppingEngine.cs
branches/martin/debugger-terrania/debugger/frontend/Command.cs
branches/martin/debugger-terrania/debugger/languages/Language.cs
branches/martin/debugger-terrania/debugger/languages/TargetClass.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoClassInfo.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoClassType.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoGenericInstanceType.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoLanguageBackend.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoMember.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
branches/martin/debugger-terrania/debugger/languages/native/NativeClass.cs
branches/martin/debugger-terrania/debugger/languages/native/NativeLanguage.cs
Log:
2008-01-25 Martin Baulig <[EMAIL PROTECTED]>
Fix the parent type madness.
* languages/TargetClass.cs
(TargetClass.Type): Changed type into `TargetStructType'.
(TargetClass.RealType): New public property.
* languages/Language.cs
(Language.IsExceptionType): New public method.
* languages/mono/MonoClassInfo.cs
(MonoClassInfo.ReadClassInfo): Create `info.type' here.
* languages/mono/MonoLanguageBackend.cs
(MonoLanguageBackend.LookupMonoClass): Fix the madness; just call
ReadClassInfo() here and return its `RealType'.
* languages/mono/MonoClassType.cs
(IMonoStructType.ClassInfo): New property.
(IMonoStructType.ResolveClass): Removed the `MonoClassInfo' argument.
(MonoClassType.ResolveClass): Maintain a `resolved' flag instead
of checking whether `class_info' is not null; the `class_info' may
now be set via `IMonoStructType.ClassInfo' without actually
resolving the class. This was necessary to support recursive
generic types like "class Test : Foo<Test>".
Modified: branches/martin/debugger-terrania/debugger/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/debugger/ChangeLog 2008-01-25
19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/ChangeLog 2008-01-25
20:09:04 UTC (rev 93954)
@@ -1,5 +1,32 @@
2008-01-25 Martin Baulig <[EMAIL PROTECTED]>
+ Fix the parent type madness.
+
+ * languages/TargetClass.cs
+ (TargetClass.Type): Changed type into `TargetStructType'.
+ (TargetClass.RealType): New public property.
+
+ * languages/Language.cs
+ (Language.IsExceptionType): New public method.
+
+ * languages/mono/MonoClassInfo.cs
+ (MonoClassInfo.ReadClassInfo): Create `info.type' here.
+
+ * languages/mono/MonoLanguageBackend.cs
+ (MonoLanguageBackend.LookupMonoClass): Fix the madness; just call
+ ReadClassInfo() here and return its `RealType'.
+
+ * languages/mono/MonoClassType.cs
+ (IMonoStructType.ClassInfo): New property.
+ (IMonoStructType.ResolveClass): Removed the `MonoClassInfo' argument.
+ (MonoClassType.ResolveClass): Maintain a `resolved' flag instead
+ of checking whether `class_info' is not null; the `class_info' may
+ now be set via `IMonoStructType.ClassInfo' without actually
+ resolving the class. This was necessary to support recursive
+ generic types like "class Test : Foo<Test>".
+
+2008-01-25 Martin Baulig <[EMAIL PROTECTED]>
+
* classes/Thread.cs
(Thread.RuntimeInvoke): Changed type of `object_argument' from
`TargetClassObject' -> `TargetStructObject'.
Modified:
branches/martin/debugger-terrania/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/backend/SingleSteppingEngine.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/backend/SingleSteppingEngine.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -3229,7 +3229,8 @@
"{0} rti resolved class: {1}",
sse, klass);
class_info = language.ReadClassInfo (inferior,
klass);
- Function.MonoClass.ResolveClass (inferior,
class_info, false);
+ ((IMonoStructType)
Function.MonoClass).ClassInfo = class_info;
+ Function.MonoClass.ResolveClass (inferior,
false);
stage = Stage.ResolvedClass;
do_execute ();
return EventResult.Running;
Modified: branches/martin/debugger-terrania/debugger/frontend/Command.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/frontend/Command.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/frontend/Command.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -3115,22 +3115,6 @@
set { group = value; }
}
- bool IsSubclassOf (Thread target, TargetStructType type,
- TargetType parent)
- {
- while (type != null) {
- if (type == parent)
- return true;
-
- if (!type.HasParent)
- return false;
-
- type = type.GetParentType (target);
- }
-
- return false;
- }
-
protected override bool DoResolve (ScriptingContext context)
{
Language language = CurrentFrame.Language;
@@ -3150,7 +3134,7 @@
return false;
type = expr.EvaluateType (context) as TargetClassType;
- if (!IsSubclassOf (context.CurrentThread, type,
exception_type))
+ if (!language.IsExceptionType (type))
throw new ScriptingException ("Type `{0}' is
not an exception type.", expr.Name);
if (tgroup == null)
Modified: branches/martin/debugger-terrania/debugger/languages/Language.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/Language.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/Language.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -73,6 +73,7 @@
public abstract TargetObject CreateNullObject (Thread target,
TargetType type);
public abstract TargetPointerType CreatePointerType (TargetType
type);
+
+ public abstract bool IsExceptionType (TargetClassType type);
}
}
-
Modified: branches/martin/debugger-terrania/debugger/languages/TargetClass.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/TargetClass.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/TargetClass.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -2,10 +2,14 @@
{
public abstract class TargetClass : DebuggerMarshalByRefObject
{
- public abstract TargetClassType Type {
+ public abstract TargetStructType Type {
get;
}
+ public abstract TargetType RealType {
+ get;
+ }
+
public abstract bool HasParent {
get;
}
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoClassInfo.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/mono/MonoClassInfo.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/mono/MonoClassInfo.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -13,7 +13,8 @@
public readonly Cecil.TypeDefinition CecilType;
- MonoClassType type;
+ TargetType type;
+ TargetStructType struct_type;
MonoClassInfo parent_info;
TargetAddress parent_klass = TargetAddress.Null;
@@ -42,18 +43,29 @@
throw new InternalError ();
MonoClassInfo info = new MonoClassInfo (file, typedef,
target, klass);
- info.type = file.LookupMonoClass (typedef);
+ if (info.IsGenericClass)
+ info.type = info.struct_type =
file.MonoLanguage.ReadGenericClass (
+ target, info.GenericClass);
+ else {
+ info.type = file.LookupMonoType (typedef);
+ if (info.type is TargetStructType)
+ info.struct_type = (TargetStructType)
info.type;
+ else
+ info.struct_type = info.type.ClassType;
+ }
+ ((IMonoStructType) info.struct_type).ClassInfo = info;
return info;
}
- public static MonoClassInfo ReadClassInfo (MonoSymbolFile file,
- Cecil.TypeDefinition
typedef,
- TargetMemoryAccess
target,
- TargetAddress klass,
- out MonoClassType
type)
+ public static MonoClassInfo ReadCoreType (MonoSymbolFile file,
+ Cecil.TypeDefinition
typedef,
+ TargetMemoryAccess
target,
+ TargetAddress klass,
+ out MonoClassType
type)
{
MonoClassInfo info = new MonoClassInfo (file, typedef,
target, klass);
type = new MonoClassType (file, typedef, info);
+ ((IMonoStructType) type).ClassInfo = info;
info.type = type;
return info;
}
@@ -74,12 +86,12 @@
get { return SymbolFile.MonoLanguage.MonoRuntime; }
}
- public override TargetClassType Type {
+ public override TargetType RealType {
get { return type; }
}
- public MonoClassType ClassType {
- get { return type; }
+ public override TargetStructType Type {
+ get { return struct_type; }
}
public bool IsGenericClass {
@@ -107,7 +119,7 @@
field_offsets [i] =
MonoRuntime.MonoClassGetFieldOffset (
target, KlassAddress, i);
- fields [i] = new MonoFieldInfo (type,
field_types [i], i, field);
+ fields [i] = new MonoFieldInfo (struct_type,
field_types [i], i, field);
}
}
@@ -154,7 +166,7 @@
int offset = field_offsets [field.Position];
TargetType type = field_types [field.Position];
- if (!ClassType.IsByRef)
+ if (!Type.IsByRef)
offset -= 2 *
target.TargetMemoryInfo.TargetAddressSize;
TargetLocation field_loc =
instance.Location.GetLocationAtOffset (offset);
@@ -225,7 +237,7 @@
int offset = field_offsets [field.Position];
TargetType type = field_types [field.Position];
- if (!ClassType.IsByRef)
+ if (!Type.IsByRef)
offset -= 2 *
target.TargetMemoryInfo.TargetAddressSize;
TargetLocation field_loc =
instance.Location.GetLocationAtOffset (offset);
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoClassType.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/mono/MonoClassType.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/mono/MonoClassType.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -16,7 +16,11 @@
get;
}
- void ResolveClass (TargetMemoryAccess target, MonoClassInfo
info, bool fail);
+ MonoClassInfo ClassInfo {
+ get; set;
+ }
+
+ MonoClassInfo ResolveClass (TargetMemoryAccess target, bool
fail);
}
internal class MonoClassType : TargetClassType, IMonoStructType
@@ -32,6 +36,7 @@
IMonoStructType parent_type;
MonoClassInfo class_info;
+ bool resolved;
Hashtable load_handlers;
int load_handler_id;
@@ -43,14 +48,6 @@
this.type = type;
this.file = file;
- if (type.BaseType != null) {
- TargetType parent =
file.MonoLanguage.LookupMonoType (type.BaseType);
- if (parent is MonoGenericInstanceType)
- parent_type = (IMonoStructType) parent;
- else if (parent != null)
- parent_type = (IMonoStructType)
parent.ClassType;
- }
-
if (type.GenericParameters.Count > 0) {
StringBuilder sb = new StringBuilder
(type.FullName);
sb.Append ('<');
@@ -101,7 +98,7 @@
}
public override bool HasParent {
- get { return parent_type != null; }
+ get { return type.BaseType != null; }
}
internal override TargetStructType GetParentType
(TargetMemoryAccess target)
@@ -110,21 +107,9 @@
return parent_type.Type;
ResolveClass (target, true);
-
- MonoClassInfo parent = class_info.GetParent (target);
- if (parent == null)
- return null;
-
- if (!parent.IsGenericClass)
- return parent.ClassType;
-
- return File.MonoLanguage.ReadGenericClass (target,
parent.GenericClass);
+ return parent_type.Type;
}
- internal MonoClassType MonoParentType {
- get { return parent_type as MonoClassType; }
- }
-
public override Module Module {
get { return file.Module; }
}
@@ -268,32 +253,39 @@
public MonoClassInfo ResolveClass (TargetMemoryAccess target,
bool fail)
{
- if (class_info != null)
+ if (resolved)
return class_info;
- class_info = file.LookupClassInfo (target, (int)
type.MetadataToken.ToUInt ());
- if (class_info != null) {
- ResolveClass (target, class_info, fail);
- return class_info;
+ if (class_info == null) {
+ int token = (int) type.MetadataToken.ToUInt ();
+ class_info = file.LookupClassInfo (target,
token);
}
- if (fail)
+ if (class_info == null) {
+ if (!fail)
+ return null;
+
throw new TargetException
(TargetError.ClassNotInitialized,
"Class `{0}' not
initialized yet.", Name);
+ }
- return null;
- }
-
- public void ResolveClass (TargetMemoryAccess target,
MonoClassInfo info, bool fail)
- {
- this.class_info = info;
-
- if (parent_type != null) {
+ if (class_info.HasParent) {
MonoClassInfo parent_info =
class_info.GetParent (target);
- parent_type.ResolveClass (target, parent_info,
fail);
+ parent_type = (IMonoStructType)
parent_info.Type;
+ parent_type.ClassInfo = parent_info;
+ if (parent_type.ResolveClass (target, fail) ==
null)
+ return null;
}
+
+ resolved = true;
+ return class_info;
}
+ MonoClassInfo IMonoStructType.ClassInfo {
+ get { return class_info; }
+ set { class_info = value; }
+ }
+
protected override TargetObject DoGetObject (TargetMemoryAccess
target,
TargetLocation
location)
{
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoGenericInstanceType.cs
===================================================================
---
branches/martin/debugger-terrania/debugger/languages/mono/MonoGenericInstanceType.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++
branches/martin/debugger-terrania/debugger/languages/mono/MonoGenericInstanceType.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -10,7 +10,9 @@
TargetType[] type_args;
TargetAddress class_ptr;
MonoClassInfo class_info;
+ IMonoStructType parent_type;
string full_name;
+ bool resolved;
public MonoGenericInstanceType (MonoClassType container,
TargetType[] type_args,
TargetAddress class_ptr)
@@ -87,10 +89,7 @@
if (parent == null)
return null;
- if (!parent.IsGenericClass)
- return parent.ClassType;
-
- return File.MonoLanguage.ReadGenericClass (target,
parent.GenericClass);
+ return parent.Type;
}
internal TargetStructObject GetCurrentObject
(TargetMemoryAccess target,
@@ -116,32 +115,43 @@
public MonoClassInfo ResolveClass (TargetMemoryAccess target,
bool fail)
{
- if (class_info != null)
+ if (resolved)
return class_info;
- if (class_ptr.IsNull)
- return null;
+ if (class_info == null) {
+ if (class_ptr.IsNull)
+ return null;
- TargetAddress klass = target.ReadAddress (class_ptr);
- if (klass.IsNull)
- return null;
+ TargetAddress klass = target.ReadAddress
(class_ptr);
+ if (klass.IsNull)
+ return null;
- class_info = File.MonoLanguage.ReadClassInfo (target,
klass);
- if (class_info != null) {
- ResolveClass (target, class_info, fail);
- return class_info;
+ class_info = File.MonoLanguage.ReadClassInfo
(target, klass);
}
- if (fail)
+ if (class_info == null) {
+ if (!fail)
+ return null;
+
throw new TargetException
(TargetError.ClassNotInitialized,
"Class `{0}' not
initialized yet.", Name);
+ }
- return null;
+ if (class_info.HasParent) {
+ MonoClassInfo parent_info =
class_info.GetParent (target);
+ parent_type = (IMonoStructType)
parent_info.Type;
+ parent_type.ClassInfo = parent_info;
+ if (parent_type.ResolveClass (target, fail) ==
null)
+ return null;
+ }
+
+ resolved = true;
+ return class_info;
}
- public void ResolveClass (TargetMemoryAccess target,
MonoClassInfo info, bool fail)
- {
- this.class_info = info;
+ MonoClassInfo IMonoStructType.ClassInfo {
+ get { return class_info; }
+ set { class_info = value; }
}
internal override TargetClass GetClass (TargetMemoryAccess
target)
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoLanguageBackend.cs
===================================================================
---
branches/martin/debugger-terrania/debugger/languages/mono/MonoLanguageBackend.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++
branches/martin/debugger-terrania/debugger/languages/mono/MonoLanguageBackend.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -3,6 +3,7 @@
using System.Text;
using System.Runtime.InteropServices;
using System.Collections;
+using System.Collections.Generic;
using System.Threading;
using C = Mono.CompilerServices.SymbolWriter;
@@ -203,7 +204,7 @@
Hashtable assembly_hash;
Hashtable assembly_by_name;
Hashtable class_hash;
- Hashtable class_info_by_addr;
+ Dictionary<TargetAddress,MonoClassInfo> class_info_by_addr;
MonoSymbolFile corlib;
MonoBuiltinTypeInfo builtin_types;
MonoFunctionType main_method;
@@ -382,27 +383,26 @@
public TargetType LookupMonoClass (TargetMemoryAccess target,
TargetAddress klass_address)
{
- TargetType type = (TargetType) class_hash
[klass_address];
- if (type != null)
- return type;
+ return ReadClassInfo (target, klass_address).RealType;
+ }
- MonoClassInfo info;
+ public override bool IsExceptionType (TargetClassType ctype)
+ {
+ MonoClassType mono_type = ctype as MonoClassType;
+ if (mono_type == null)
+ return false;
- try {
- info = MonoClassInfo.ReadClassInfo (this,
target, klass_address);
- if (info == null)
- return null;
+ Cecil.TypeDefinition exc_type =
builtin_types.ExceptionType.Type;
+ Cecil.TypeDefinition type = mono_type.Type;
- type = info.SymbolFile.LookupMonoType
(info.CecilType);
- } catch {
- return null;
+ while (type != null) {
+ if (type == exc_type)
+ return true;
+
+ type = type.BaseType as Cecil.TypeDefinition;
}
- if (type == null)
- return null;
-
- class_hash.Add (klass_address, type);
- return type;
+ return false;
}
public MonoSymbolFile GetImage (TargetAddress address)
@@ -433,7 +433,7 @@
assembly_hash = new Hashtable ();
assembly_by_name = new Hashtable ();
class_hash = new Hashtable ();
- class_info_by_addr = new Hashtable ();
+ class_info_by_addr = new
Dictionary<TargetAddress,MonoClassInfo> ();
}
void reached_main (TargetMemoryAccess target, TargetAddress
method)
@@ -870,13 +870,11 @@
internal MonoClassInfo ReadClassInfo (TargetMemoryAccess
memory, TargetAddress klass)
{
- MonoClassInfo info = (MonoClassInfo) class_info_by_addr
[klass];
- if (info == null) {
- info = MonoClassInfo.ReadClassInfo (this,
memory, klass);
+ if (class_info_by_addr.ContainsKey (klass))
+ return class_info_by_addr [klass];
- class_info_by_addr.Add (klass, info);
- }
-
+ MonoClassInfo info = MonoClassInfo.ReadClassInfo (this,
memory, klass);
+ class_info_by_addr.Add (klass, info);
return info;
}
@@ -884,7 +882,7 @@
TargetMemoryAccess
memory, TargetAddress klass)
{
MonoClassType type;
- MonoClassInfo info = MonoClassInfo.ReadClassInfo (
+ MonoClassInfo info = MonoClassInfo.ReadCoreType (
file, typedef, memory, klass, out type);
class_info_by_addr.Add (klass, info);
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoMember.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/mono/MonoMember.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/mono/MonoMember.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -9,9 +9,9 @@
{
[NonSerialized]
public readonly Cecil.FieldDefinition FieldInfo;
- public readonly MonoClassType DeclaringType;
+ public readonly TargetStructType DeclaringType;
- public MonoFieldInfo (MonoClassType type, TargetType
field_type, int pos,
+ public MonoFieldInfo (TargetStructType type, TargetType
field_type, int pos,
Cecil.FieldDefinition finfo)
: base (field_type, finfo.Name, pos, finfo.IsStatic,
pos, 0, finfo.HasConstant)
{
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -369,7 +369,7 @@
return range.GetMethod ();
}
- public MonoClassType LookupMonoClass (Cecil.TypeReference
typeref)
+ protected MonoClassType LookupMonoClass (Cecil.TypeReference
typeref)
{
TargetType type = LookupMonoType (typeref);
if (type == null)
Modified:
branches/martin/debugger-terrania/debugger/languages/native/NativeClass.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/native/NativeClass.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++ branches/martin/debugger-terrania/debugger/languages/native/NativeClass.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -13,10 +13,14 @@
this.fields = fields != null ? fields : new
NativeFieldInfo [0];
}
- public override TargetClassType Type {
+ public override TargetType RealType {
get { return type; }
}
+ public override TargetStructType Type {
+ get { return type; }
+ }
+
public override bool HasParent {
get { return false; }
}
Modified:
branches/martin/debugger-terrania/debugger/languages/native/NativeLanguage.cs
===================================================================
---
branches/martin/debugger-terrania/debugger/languages/native/NativeLanguage.cs
2008-01-25 19:38:31 UTC (rev 93953)
+++
branches/martin/debugger-terrania/debugger/languages/native/NativeLanguage.cs
2008-01-25 20:09:04 UTC (rev 93954)
@@ -122,6 +122,11 @@
return new NativePointerType (this, type.Name + "*",
type, type.Size);
}
+ public override bool IsExceptionType (TargetClassType type)
+ {
+ return false;
+ }
+
internal TargetAddress LookupSymbol (string name)
{
return bfd_container.LookupSymbol (name);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches