diff options
author | Jeffrey Stedfast <jeff@xamarin.com> | 2012-07-26 19:28:39 +0400 |
---|---|---|
committer | Jeffrey Stedfast <jeff@xamarin.com> | 2012-10-24 20:09:48 +0400 |
commit | e159cf083bd327933166819d94245298898d6e3d (patch) | |
tree | 94e77b531d0f7b818871c9049d882cd21e6ec62f | |
parent | ca00cb689d5c1d2a13a4d96a9ce35efb5cc23ce5 (diff) |
[Debugger] Backported fixes to properly evaluate 'base.' in debugger evaluationsmonodevelop-3.0.5
Fixes bugs #5895, #6251, and #6986
3 files changed, 48 insertions, 16 deletions
diff --git a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/LiteralValueReference.cs b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/LiteralValueReference.cs index c410cbe801..d2c57664fb 100644 --- a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/LiteralValueReference.cs +++ b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/LiteralValueReference.cs @@ -44,6 +44,17 @@ namespace Mono.Debugging.Evaluation { } + public static LiteralValueReference CreateTargetBaseObjectLiteral (EvaluationContext ctx, string name, object value) + { + LiteralValueReference val = new LiteralValueReference (ctx); + var type = ctx.Adapter.GetValueType (ctx, value); + val.name = name; + val.value = value; + val.type = ctx.Adapter.GetBaseType (ctx, type); + val.objCreated = true; + return val; + } + public static LiteralValueReference CreateTargetObjectLiteral (EvaluationContext ctx, string name, object value) { LiteralValueReference val = new LiteralValueReference (ctx); @@ -126,9 +137,35 @@ namespace Mono.Debugging.Evaluation if (ObjectValue is EvaluationResult) { EvaluationResult exp = (EvaluationResult) ObjectValue; return Mono.Debugging.Client.ObjectValue.CreateObject (this, new ObjectPath (Name), "", exp, Flags, null); - } - else + } else return base.OnCreateObjectValue (options); } + + public override ValueReference GetChild (string name, EvaluationOptions options) + { + object obj = Value; + + if (obj == null) + return null; + + if (name [0] == '[' && Context.Adapter.IsArray (Context, obj)) { + // Parse the array indices + string[] sinds = name.Substring (1, name.Length - 2).Split (','); + int[] indices = new int [sinds.Length]; + for (int n=0; n<sinds.Length; n++) + indices [n] = int.Parse (sinds [n]); + + return new ArrayValueReference (Context, obj, indices); + } + + if (Context.Adapter.IsClassInstance (Context, obj)) { + // Note: This is the only difference with the default ValueReference implementation. + // We need this because the user may be requesting a base class's implementation, in + // which case 'Type' will be the BaseType instead of the actual type of the variable. + return Context.Adapter.GetMember (GetChildrenContext (options), this, Type, obj, name); + } + + return null; + } } } diff --git a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs index c94b552b59..3470c367e4 100644 --- a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs +++ b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs @@ -1,9 +1,10 @@ // NRefactoryEvaluator.cs // -// Author: -// Lluis Sanchez Gual <lluis@novell.com> +// Authors: Lluis Sanchez Gual <lluis@novell.com> +// Jeffrey Stedfast <jeff@xamarin.com> // // Copyright (c) 2008 Novell, Inc (http://www.novell.com) +// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -863,12 +864,8 @@ namespace Mono.Debugging.Evaluation public override object VisitBaseReferenceExpression (ICSharpCode.OldNRefactory.Ast.BaseReferenceExpression baseReferenceExpression, object data) { ValueReference thisobj = ctx.Adapter.GetThisReference (ctx); - if (thisobj != null) { - object baseob = ctx.Adapter.GetBaseValue (ctx, thisobj.Value); - if (baseob == null) - throw CreateParseError ("'base' reference not available."); - return LiteralValueReference.CreateTargetObjectLiteral (ctx, name, baseob); - } + if (thisobj != null) + return LiteralValueReference.CreateTargetBaseObjectLiteral (ctx, name, thisobj.Value); else throw CreateParseError ("'base' reference not available in static methods."); } diff --git a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs index fa9eccd27e..e9a2fa98f2 100644 --- a/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs +++ b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs @@ -218,7 +218,7 @@ namespace Mono.Debugging.Evaluation public IObjectSource ParentSource { get; internal set; } - EvaluationContext GetChildrenContext (EvaluationOptions options) + protected EvaluationContext GetChildrenContext (EvaluationOptions options) { EvaluationContext newCtx = ctx.Clone (); if (options != null) @@ -256,11 +256,9 @@ namespace Mono.Debugging.Evaluation return new ArrayValueReference (ctx, obj, indices); } - if (ctx.Adapter.IsClassInstance (Context, obj)) { - ValueReference val = ctx.Adapter.GetMember (GetChildrenContext (options), this, obj, name); - return val; - } - + if (ctx.Adapter.IsClassInstance (Context, obj)) + return ctx.Adapter.GetMember (GetChildrenContext (options), this, obj, name); + return null; } } |