From e159cf083bd327933166819d94245298898d6e3d Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 26 Jul 2012 11:28:39 -0400 Subject: [Debugger] Backported fixes to properly evaluate 'base.' in debugger evaluations Fixes bugs #5895, #6251, and #6986 --- .../LiteralValueReference.cs | 41 ++++++++++++++++++++-- .../NRefactoryEvaluator.cs | 13 +++---- .../Mono.Debugging.Evaluation/ValueReference.cs | 10 +++--- 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 +// Authors: Lluis Sanchez Gual +// Jeffrey Stedfast // // 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; } } -- cgit v1.2.3