Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java4
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Expression.java19
2 files changed, 19 insertions, 4 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
index 14e135519ef..df0f2fa8cc1 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
@@ -249,8 +249,8 @@ public class ExpressionManager extends Manager {
} catch (MIException e) {
//throw new MI2CDIException(e);
}
- //List varList = getVariableList(target);
- //varList.remove(variable);
+ List varList = getVariableList(target);
+ varList.remove(variable);
// remove any children
ICDIVariable[] children = variable.children;
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 e8eab22252d..8a0df26e4b8 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
@@ -30,6 +30,8 @@ public class Expression extends CObject implements ICDIExpression {
private int id;
String fExpression;
Type fType;
+ Variable fVariable;
+ ICDIStackFrame fContext;
public Expression(Target target, String ex) {
super(target);
@@ -96,8 +98,19 @@ public class Expression extends CObject implements ICDIExpression {
public ICDIValue getValue(ICDIStackFrame context) throws CDIException {
Session session = (Session)getTarget().getSession();
ExpressionManager mgr = session.getExpressionManager();
- Variable var = mgr.createVariable((StackFrame)context, getExpressionText());
- return var.getValue();
+ if (fVariable != null && fContext != null && !context.equals(fContext))
+ { // Get rid of the underlying variable if the context has changed.
+ // This is defensive, in practice each stack frame has it's own
+ // list of expressions.
+ 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;
+ return fVariable.getValue();
}
/* (non-Javadoc)
@@ -107,6 +120,8 @@ public class Expression extends CObject implements ICDIExpression {
Session session = (Session)getTarget().getSession();
ExpressionManager mgr = session.getExpressionManager();
mgr.destroyExpressions((Target)getTarget(), new Expression[] {this});
+ if (fVariable != null)
+ mgr.deleteVariable(fVariable);
}
}

Back to the top