Author: martin
Date: 2007-12-10 08:37:01 -0500 (Mon, 10 Dec 2007)
New Revision: 91043
Added:
trunk/debugger/languages/TargetStructObject.cs
trunk/debugger/languages/TargetStructType.cs
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backend/SingleSteppingEngine.cs
trunk/debugger/classes/ExceptionCatchPoint.cs
trunk/debugger/frontend/Command.cs
trunk/debugger/frontend/Expression.cs
trunk/debugger/frontend/Style.cs
trunk/debugger/languages/TargetClassObject.cs
trunk/debugger/languages/TargetClassType.cs
trunk/debugger/languages/mono/MonoClassType.cs
trunk/debugger/languages/native/NativeStructType.cs
Log:
2007-12-10 Martin Baulig <[EMAIL PROTECTED]>
* languages/TargetStructType.cs: New file.
(TargetStructType): New public abstract type.
* languages/TargetStructObject.cs: New file.
(TargetStructObject): New public abstract type.
* languages/TargetClassType.cs
(TargetClassType): Derive from `TargetStructType'; removed
`HasParent', `GetClass', `Module' and `ParentType' which are now
provided by `TargetStructType'.
* languages/TargetClassObject.cs
(TargetClassObject): Derive from `TargetClassObject'.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-12-10 13:14:38 UTC (rev 91042)
+++ trunk/debugger/ChangeLog 2007-12-10 13:37:01 UTC (rev 91043)
@@ -1,5 +1,21 @@
2007-12-10 Martin Baulig <[EMAIL PROTECTED]>
+ * languages/TargetStructType.cs: New file.
+ (TargetStructType): New public abstract type.
+
+ * languages/TargetStructObject.cs: New file.
+ (TargetStructObject): New public abstract type.
+
+ * languages/TargetClassType.cs
+ (TargetClassType): Derive from `TargetStructType'; removed
+ `HasParent', `GetClass', `Module' and `ParentType' which are now
+ provided by `TargetStructType'.
+
+ * languages/TargetClassObject.cs
+ (TargetClassObject): Derive from `TargetClassObject'.
+
+2007-12-10 Martin Baulig <[EMAIL PROTECTED]>
+
* classes/DebuggerOptions.cs: Added new `-start' command line
argument to stop in Main(); made `-run' run the target without
stopping. This makes the command line arguments consistent with
Modified: trunk/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- trunk/debugger/backend/SingleSteppingEngine.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/backend/SingleSteppingEngine.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -986,7 +986,7 @@
"{0} invoking exception handler
{1} for {0}",
this, handle.Name, exc);
- if (!handle.CheckException (thread, exc))
+ if (!handle.CheckException
(process.MonoLanguage, inferior, exc))
continue;
Report.Debug (DebugFlags.SSE,
@@ -3079,7 +3079,7 @@
MonoLanguageBackend language;
TargetAddress method = TargetAddress.Null;
TargetAddress invoke = TargetAddress.Null;
- TargetClassObject instance;
+ TargetStructObject instance;
MonoClassInfo class_info;
Stage stage;
@@ -3191,7 +3191,9 @@
if ((decl.Name != "System.ValueType") && (decl.Name !=
"System.Object"))
return true;
- if (!instance.Type.IsByRef &&
instance.Type.ParentType.IsByRef) {
+ TargetStructType parent_type =
instance.Type.GetParentType (inferior);
+
+ if (!instance.Type.IsByRef && parent_type.IsByRef) {
TargetAddress klass = ((MonoClassObject)
instance).GetKlassAddress (inferior);
stage = Stage.BoxingInstance;
inferior.CallMethod (
@@ -3239,8 +3241,8 @@
"{0} rti boxed object: {1}", sse,
boxed);
TargetLocation new_loc = new
AbsoluteTargetLocation (boxed);
- instance = (MonoClassObject)
instance.Type.ParentType.GetObject (
- inferior, new_loc);
+ TargetStructType parent_type =
instance.Type.GetParentType (inferior);
+ instance = (TargetStructObject)
parent_type.GetObject (inferior, new_loc);
stage = Stage.HasMethodAddress;
do_execute ();
return EventResult.Running;
Modified: trunk/debugger/classes/ExceptionCatchPoint.cs
===================================================================
--- trunk/debugger/classes/ExceptionCatchPoint.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/classes/ExceptionCatchPoint.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -4,6 +4,7 @@
using System.Runtime.Serialization;
using Mono.Debugger.Languages;
+using Mono.Debugger.Languages.Mono;
namespace Mono.Debugger
{
@@ -77,7 +78,8 @@
}
}
- bool IsSubclassOf (TargetClassType type, TargetType parent)
+ bool IsSubclassOf (TargetMemoryAccess target, TargetStructType
type,
+ TargetType parent)
{
while (type != null) {
if (type == parent)
@@ -86,15 +88,15 @@
if (!type.HasParent)
return false;
- type = type.ParentType;
+ type = type.GetParentType (target);
}
return false;
}
- internal bool CheckException (Thread target, TargetAddress
address)
+ internal bool CheckException (MonoLanguageBackend mono,
TargetMemoryAccess target,
+ TargetAddress address)
{
- Language mono = target.Process.Servant.MonoLanguage;
TargetClassObject exc = mono.CreateObject (target,
address) as TargetClassObject;
if (exc == null)
return false; // OOOPS
@@ -104,7 +106,7 @@
if (exception == null)
return false;
- return IsSubclassOf (exc.Type, exception);
+ return IsSubclassOf (target, exc.Type, exception);
}
protected override void GetSessionData (XmlElement root,
XmlElement element)
Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs 2007-12-10 13:14:38 UTC (rev 91042)
+++ trunk/debugger/frontend/Command.cs 2007-12-10 13:37:01 UTC (rev 91043)
@@ -3115,7 +3115,8 @@
set { group = value; }
}
- bool IsSubclassOf (TargetClassType type, TargetType parent)
+ bool IsSubclassOf (Thread target, TargetStructType type,
+ TargetType parent)
{
while (type != null) {
if (type == parent)
@@ -3124,7 +3125,7 @@
if (!type.HasParent)
return false;
- type = type.ParentType;
+ type = type.GetParentType (target);
}
return false;
@@ -3149,7 +3150,7 @@
return false;
type = expr.EvaluateType (context) as TargetClassType;
- if (!IsSubclassOf (type, exception_type))
+ if (!IsSubclassOf (context.CurrentThread, type,
exception_type))
throw new ScriptingException ("Type `{0}' is
not an exception type.", expr.Name);
if (tgroup == null)
Modified: trunk/debugger/frontend/Expression.cs
===================================================================
--- trunk/debugger/frontend/Expression.cs 2007-12-10 13:14:38 UTC (rev
91042)
+++ trunk/debugger/frontend/Expression.cs 2007-12-10 13:37:01 UTC (rev
91043)
@@ -1776,37 +1776,41 @@
Name,
member.GetType ());
}
- public static MemberExpression FindMember (Thread target,
TargetClassType stype,
+ public static MemberExpression FindMember (Thread target,
TargetStructType stype,
TargetClassObject
instance, string name,
bool search_static,
bool search_instance)
{
again:
- TargetMemberInfo member = stype.FindMember (
+ TargetClassType ctype = stype as TargetClassType;
+ if (ctype == null)
+ return null;
+
+ TargetMemberInfo member = ctype.FindMember (
name, search_static, search_instance);
if (member != null)
- return new StructAccessExpression (stype,
instance, member);
+ return new StructAccessExpression (ctype,
instance, member);
ArrayList methods = new ArrayList ();
bool is_instance = false;
bool is_static = false;
if (name == ".ctor") {
- foreach (TargetMethodInfo method in
stype.Constructors) {
+ foreach (TargetMethodInfo method in
ctype.Constructors) {
if (method.IsStatic)
continue;
methods.Add (method.Type);
is_instance = true;
}
} else if (name == ".cctor") {
- foreach (TargetMethodInfo method in
stype.Constructors) {
+ foreach (TargetMethodInfo method in
ctype.Constructors) {
if (!method.IsStatic)
continue;
methods.Add (method.Type);
is_static = true;
}
} else {
- foreach (TargetMethodInfo method in
stype.Methods) {
+ foreach (TargetMethodInfo method in
ctype.Methods) {
if (method.IsStatic && !search_static)
continue;
if (!method.IsStatic &&
!search_instance)
@@ -1826,12 +1830,11 @@
TargetFunctionType[] funcs = new
TargetFunctionType [methods.Count];
methods.CopyTo (funcs, 0);
return new MethodGroupExpression (
- stype, instance, name, funcs,
is_instance, is_static);
+ ctype, instance, name, funcs,
is_instance, is_static);
}
- TargetClassType ctype = stype as TargetClassType;
- if ((ctype != null) && ctype.HasParent) {
- stype = ctype.ParentType;
+ if (ctype.HasParent) {
+ stype = ctype.GetParentType (target);
if (instance != null) {
instance = instance.GetParentObject
(target);
if (instance == null)
@@ -2350,10 +2353,10 @@
return this;
}
- static TargetClassObject TryParentCast (ScriptingContext
context, Thread target,
+ static TargetClassObject TryParentCast (ScriptingContext
context,
TargetClassObject
source,
- TargetClassType
source_type,
- TargetClassType
target_type)
+ TargetStructType
source_type,
+ TargetStructType
target_type)
{
if (source_type == target_type)
return source;
@@ -2361,23 +2364,23 @@
if (!source_type.HasParent)
return null;
- source = TryParentCast (
- context, target, source,
source_type.ParentType, target_type);
+ TargetStructType parent_type =
source_type.GetParentType (context.CurrentThread);
+ source = TryParentCast (context, source, parent_type,
target_type);
if (source == null)
return null;
- return source.GetParentObject (target);
+ return source.GetParentObject (context.CurrentThread);
}
- static TargetClassObject TryCurrentCast (ScriptingContext
context, Thread target,
+ static TargetClassObject TryCurrentCast (ScriptingContext
context,
TargetClassObject
source,
TargetClassType
target_type)
{
- TargetClassObject current = source.GetCurrentObject
(target);
+ TargetClassObject current = source.GetCurrentObject
(context.CurrentThread);
if (current == null)
return null;
- return TryParentCast (context, target, current,
current.Type, target_type);
+ return TryParentCast (context, current, current.Type,
target_type);
}
public static TargetObject TryCast (ScriptingContext context,
TargetObject source,
@@ -2386,23 +2389,21 @@
if (source.Type == target_type)
return source;
- Thread target = context.CurrentThread;
-
- TargetClassObject sobj = Convert.ToClassObject (target,
source);
+ TargetClassObject sobj = Convert.ToClassObject
(context.CurrentThread, source);
if (sobj == null)
return null;
TargetClassObject result;
- result = TryParentCast (context, target, sobj,
sobj.Type, target_type);
+ result = TryParentCast (context, sobj, sobj.Type,
target_type);
if (result != null)
return result;
- return TryCurrentCast (context, target, sobj,
target_type);
+ return TryCurrentCast (context, sobj, target_type);
}
static bool TryParentCast (ScriptingContext context,
- TargetClassType source_type,
- TargetClassType target_type)
+ TargetStructType source_type,
+ TargetStructType target_type)
{
if (source_type == target_type)
return true;
@@ -2410,7 +2411,8 @@
if (!source_type.HasParent)
return false;
- return TryParentCast (context, source_type.ParentType,
target_type);
+ TargetStructType parent_type =
source_type.GetParentType (context.CurrentThread);
+ return TryParentCast (context, parent_type,
target_type);
}
public static bool TryCast (ScriptingContext context,
TargetType source,
@@ -2481,6 +2483,7 @@
}
}
+
public static class Convert
{
static bool ImplicitFundamentalConversionExists
(FundamentalKind skind,
@@ -2632,8 +2635,8 @@
}
static bool ImplicitReferenceConversionExists (ScriptingContext
context,
- TargetClassType
source,
- TargetClassType
target)
+ TargetStructType
source,
+ TargetStructType
target)
{
if (source == target)
return true;
@@ -2641,8 +2644,8 @@
if (!source.HasParent)
return false;
- return ImplicitReferenceConversionExists (
- context, source.ParentType, target);
+ TargetStructType parent_type = source.GetParentType
(context.CurrentThread);
+ return ImplicitReferenceConversionExists (context,
parent_type, target);
}
static TargetObject ImplicitReferenceConversion
(ScriptingContext context,
Modified: trunk/debugger/frontend/Style.cs
===================================================================
--- trunk/debugger/frontend/Style.cs 2007-12-10 13:14:38 UTC (rev 91042)
+++ trunk/debugger/frontend/Style.cs 2007-12-10 13:37:01 UTC (rev 91043)
@@ -234,7 +234,7 @@
protected string FormatMember (string prefix, TargetMemberInfo
member,
bool is_static, Hashtable hash)
{
- string tname = member.Type.Name;
+ string tname = member.Type != null ? member.Type.Name :
"<unknown type>";
TargetFieldInfo fi = member as TargetFieldInfo;
if ((fi != null) && fi.HasConstValue)
return String.Format (
@@ -291,7 +291,8 @@
TargetFunctionType ftype = method.Type;
if (!is_ctor) {
if (ftype.HasReturnValue)
- sb.Append (ftype.ReturnType.Name);
+ sb.Append (ftype.ReturnType != null ?
+ ftype.ReturnType.Name :
"<unknown type>");
else
sb.Append ("void");
sb.Append (" ");
@@ -375,8 +376,9 @@
sb.Append (" ");
}
if (ctype.HasParent) {
+ TargetStructType parent =
ctype.GetParentType (target);
sb.Append (": ");
- sb.Append
(ctype.ParentType.Name);
+ sb.Append (parent.Name);
}
} else {
if (stype.Name != null) {
@@ -388,52 +390,62 @@
foreach (TargetFieldInfo field in stype.Fields)
{
if (field.IsStatic)
continue;
- sb.Append (FormatMember (prefix, field,
false, hash) + ";\n");
+ sb.Append (FormatMember (
+ prefix, field,
false, hash) + ";\n");
}
foreach (TargetFieldInfo field in stype.Fields)
{
if (!field.IsStatic)
continue;
- sb.Append (FormatMember (prefix, field,
true, hash) + ";\n");
+ sb.Append (FormatMember (
+ prefix, field, true,
hash) + ";\n");
}
foreach (TargetPropertyInfo property in
stype.Properties) {
if (property.IsStatic)
continue;
- sb.Append (FormatProperty (prefix,
property, false, hash));
+ sb.Append (FormatProperty (
+ prefix, property,
false, hash));
}
foreach (TargetPropertyInfo property in
stype.Properties) {
if (!property.IsStatic)
continue;
- sb.Append (FormatProperty (prefix,
property, true, hash));
+ sb.Append (FormatProperty (
+ prefix, property,
true, hash));
}
foreach (TargetEventInfo ev in stype.Events) {
if (ev.IsStatic)
continue;
- sb.Append (FormatEvent (prefix, ev,
false, hash));
+ sb.Append (FormatEvent (
+ prefix, ev, false,
hash));
}
foreach (TargetEventInfo ev in stype.Events) {
if (!ev.IsStatic)
continue;
- sb.Append (FormatEvent (prefix, ev,
true, hash));
+ sb.Append (FormatEvent (
+ prefix, ev, true,
hash));
}
foreach (TargetMethodInfo method in
stype.Methods) {
if (method.IsStatic)
continue;
- sb.Append (FormatMethod (prefix,
method, false, false, hash));
+ sb.Append (FormatMethod (
+ prefix, method,
false, false, hash));
}
foreach (TargetMethodInfo method in
stype.Methods) {
if (!method.IsStatic)
continue;
- sb.Append (FormatMethod (prefix,
method, true, false, hash));
+ sb.Append (FormatMethod (
+ prefix, method,
true, false, hash));
}
foreach (TargetMethodInfo method in
stype.Constructors) {
if (method.IsStatic)
continue;
- sb.Append (FormatMethod (prefix,
method, false, true, hash));
+ sb.Append (FormatMethod (
+ prefix, method,
false, true, hash));
}
foreach (TargetMethodInfo method in
stype.Constructors) {
if (!method.IsStatic)
continue;
- sb.Append (FormatMethod (prefix,
method, true, true, hash));
+ sb.Append (FormatMethod (
+ prefix, method,
true, true, hash));
}
sb.Append (prefix);
Modified: trunk/debugger/languages/TargetClassObject.cs
===================================================================
--- trunk/debugger/languages/TargetClassObject.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/languages/TargetClassObject.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -1,6 +1,6 @@
namespace Mono.Debugger.Languages
{
- public abstract class TargetClassObject : TargetObject
+ public abstract class TargetClassObject : TargetStructObject
{
public readonly new TargetClassType Type;
Modified: trunk/debugger/languages/TargetClassType.cs
===================================================================
--- trunk/debugger/languages/TargetClassType.cs 2007-12-10 13:14:38 UTC (rev
91042)
+++ trunk/debugger/languages/TargetClassType.cs 2007-12-10 13:37:01 UTC (rev
91043)
@@ -1,25 +1,11 @@
namespace Mono.Debugger.Languages
{
- public abstract class TargetClassType : TargetType
+ public abstract class TargetClassType : TargetStructType
{
protected TargetClassType (Language language, TargetObjectKind
kind)
: base (language, kind)
{ }
- public abstract bool HasParent {
- get;
- }
-
- public abstract TargetClass GetClass (Thread target);
-
- public abstract Module Module {
- get;
- }
-
- public abstract TargetClassType ParentType {
- get;
- }
-
public abstract TargetFieldInfo[] Fields {
get;
}
Added: trunk/debugger/languages/TargetStructObject.cs
===================================================================
--- trunk/debugger/languages/TargetStructObject.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/languages/TargetStructObject.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -0,0 +1,13 @@
+namespace Mono.Debugger.Languages
+{
+ public abstract class TargetStructObject : TargetObject
+ {
+ public readonly new TargetStructType Type;
+
+ internal TargetStructObject (TargetStructType type,
TargetLocation location)
+ : base (type, location)
+ {
+ this.Type = type;
+ }
+ }
+}
Added: trunk/debugger/languages/TargetStructType.cs
===================================================================
--- trunk/debugger/languages/TargetStructType.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/languages/TargetStructType.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -0,0 +1,37 @@
+namespace Mono.Debugger.Languages
+{
+ public abstract class TargetStructType : TargetType
+ {
+ protected TargetStructType (Language language, TargetObjectKind
kind)
+ : base (language, kind)
+ { }
+
+ public abstract Module Module {
+ get;
+ }
+
+ public abstract bool HasParent {
+ get;
+ }
+
+ internal abstract TargetStructType GetParentType
(TargetMemoryAccess target);
+
+ public TargetStructType GetParentType (Thread thread)
+ {
+ return (TargetStructType)
thread.ThreadServant.DoTargetAccess (
+ delegate (TargetMemoryAccess target) {
+ return GetParentType (target);
+ });
+ }
+
+ internal abstract TargetClass GetClass (TargetMemoryAccess
target);
+
+ public TargetClass GetClass (Thread thread)
+ {
+ return (TargetClass)
thread.ThreadServant.DoTargetAccess (
+ delegate (TargetMemoryAccess target) {
+ return GetClass (target);
+ });
+ }
+ }
+}
Modified: trunk/debugger/languages/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassType.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/languages/mono/MonoClassType.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -74,8 +74,9 @@
get { return parent_type != null; }
}
- public override TargetClassType ParentType {
- get { return parent_type; }
+ internal override TargetStructType GetParentType
(TargetMemoryAccess target)
+ {
+ return parent_type;
}
internal MonoClassType MonoParentType {
@@ -218,12 +219,9 @@
}
}
- public override TargetClass GetClass (Thread thread)
+ internal override TargetClass GetClass (TargetMemoryAccess
target)
{
- return (TargetClass)
thread.ThreadServant.DoTargetAccess (
- delegate (TargetMemoryAccess target) {
- return ResolveClass (target, false);
- });
+ return ResolveClass (target, false);
}
internal MonoClassInfo ResolveClass (TargetMemoryAccess target,
bool fail)
Modified: trunk/debugger/languages/native/NativeStructType.cs
===================================================================
--- trunk/debugger/languages/native/NativeStructType.cs 2007-12-10 13:14:38 UTC
(rev 91042)
+++ trunk/debugger/languages/native/NativeStructType.cs 2007-12-10 13:37:01 UTC
(rev 91043)
@@ -101,8 +101,9 @@
get { return false; }
}
- public override TargetClassType ParentType {
- get { throw new InvalidOperationException (); }
+ internal override TargetStructType GetParentType
(TargetMemoryAccess target)
+ {
+ throw new InvalidOperationException ();
}
public override Module Module {
@@ -167,7 +168,7 @@
}
}
- public override TargetClass GetClass (Thread thread)
+ internal override TargetClass GetClass (TargetMemoryAccess
target)
{
if (class_info == null)
class_info = new NativeClass (this, fields);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches