diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 35887993214..4775a97997f 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2004-11-18 Mikhail Khodjaiants + Worker threads can try to evaluate expressions on the stack frames that + have already been disposed. A flag is added to identify that the stack + frame is disposed. + * CStackFrame.java + 2004-11-19 Alain Magloire Clear the confusion about sublist of stackframes. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java index 8d6690edd4d..2e06c1315a9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java @@ -79,6 +79,11 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart */ private List fExpressions; + /** + * Need this flag to prevent evaluations on disposed frames. + */ + private boolean fIsDisposed = false; + /** * Constructor for CStackFrame. */ @@ -477,6 +482,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart } protected void dispose() { + setDisposed( true ); getCDISession().getEventManager().removeEventListener( this ); disposeAllVariables(); disposeExpressions(); @@ -661,9 +667,11 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart * @see org.eclipse.cdt.debug.core.model.ICStackFrame#evaluateExpression(java.lang.String) */ public IValue evaluateExpression( String expressionText ) throws DebugException { - CExpression expression = getExpression( expressionText ); - if ( expression != null ) { - return expression.getValue( this ); + if ( !isDisposed() ) { + CExpression expression = getExpression( expressionText ); + if ( expression != null ) { + return expression.getValue( this ); + } } return null; } @@ -718,7 +726,10 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart } } - private CExpression getExpression( String expressionText ) throws DebugException { + private synchronized CExpression getExpression( String expressionText ) throws DebugException { + if ( isDisposed() ) { + return null; + } if ( fExpressions == null ) { fExpressions = new ArrayList( 5 ); } @@ -740,4 +751,12 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart } return expression; } + + protected boolean isDisposed() { + return fIsDisposed; + } + + private synchronized void setDisposed( boolean isDisposed ) { + fIsDisposed = isDisposed; + } } \ No newline at end of file