From 3d3b6c4b4c1f02e96bb84e43a1d914f3a8fb2810 Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Tue, 24 Nov 2009 15:12:35 +0000 Subject: [PATCH] Bug 296006 nullify cached underlying Expression Variable if it's unable to provide value string --- .../debug/mi/core/cdi/model/Expression.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Expression.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Expression.java index 8a0df26e4b8..828404ff641 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Expression.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Expression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 QNX Software Systems and others. + * Copyright (c) 2000, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -105,11 +105,18 @@ public class Expression extends CObject implements ICDIExpression { mgr.deleteVariable(fVariable); fVariable = null; } - if (fVariable == null) - { // Reuse the variable so we don't have to ask gdb to create another one. Bug 150565. - fVariable = mgr.createVariable((StackFrame)context, getExpressionText()); - } fContext = context; + if (fVariable != null) { + // Reuse the variable so we don't have to ask gdb to create another one. Bug 150565. + try { + // It's possible this variable is no longer valid... (Bug 296006) + fVariable.getValue().getValueString(); + } catch (CDIException e) { + fVariable = null; + } + } + if (fVariable == null) + fVariable = mgr.createVariable((StackFrame)context, getExpressionText()); return fVariable.getValue(); } @@ -122,6 +129,7 @@ public class Expression extends CObject implements ICDIExpression { mgr.destroyExpressions((Target)getTarget(), new Expression[] {this}); if (fVariable != null) mgr.deleteVariable(fVariable); + fVariable = null; } }