mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 150565. Expressions cache their variable objects so they don't ask gdb to create a new one each time the expression value is determined.
This commit is contained in:
parent
6e4982352e
commit
a9605d9359
1 changed files with 17 additions and 2 deletions
|
@ -30,6 +30,8 @@ public class Expression extends CObject implements ICDIExpression {
|
||||||
private int id;
|
private int id;
|
||||||
String fExpression;
|
String fExpression;
|
||||||
Type fType;
|
Type fType;
|
||||||
|
Variable fVariable;
|
||||||
|
ICDIStackFrame fContext;
|
||||||
|
|
||||||
public Expression(Target target, String ex) {
|
public Expression(Target target, String ex) {
|
||||||
super(target);
|
super(target);
|
||||||
|
@ -96,8 +98,19 @@ public class Expression extends CObject implements ICDIExpression {
|
||||||
public ICDIValue getValue(ICDIStackFrame context) throws CDIException {
|
public ICDIValue getValue(ICDIStackFrame context) throws CDIException {
|
||||||
Session session = (Session)getTarget().getSession();
|
Session session = (Session)getTarget().getSession();
|
||||||
ExpressionManager mgr = session.getExpressionManager();
|
ExpressionManager mgr = session.getExpressionManager();
|
||||||
Variable var = mgr.createVariable((StackFrame)context, getExpressionText());
|
if (fVariable != null && fContext != null && !context.equals(fContext))
|
||||||
return var.getValue();
|
{ // 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)
|
/* (non-Javadoc)
|
||||||
|
@ -107,6 +120,8 @@ public class Expression extends CObject implements ICDIExpression {
|
||||||
Session session = (Session)getTarget().getSession();
|
Session session = (Session)getTarget().getSession();
|
||||||
ExpressionManager mgr = session.getExpressionManager();
|
ExpressionManager mgr = session.getExpressionManager();
|
||||||
mgr.destroyExpressions((Target)getTarget(), new Expression[] {this});
|
mgr.destroyExpressions((Target)getTarget(), new Expression[] {this});
|
||||||
|
if (fVariable != null)
|
||||||
|
mgr.deleteVariable(fVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue