diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDITargetConfiguration2.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDITargetConfiguration2.java index 5ae1cb042b1..09a50345f41 100644 --- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDITargetConfiguration2.java +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDITargetConfiguration2.java @@ -30,9 +30,15 @@ public interface ICDITargetConfiguration2 extends ICDITargetConfiguration { * maintaining its own variable cache and having to keep it in sync with * CDT's. Targets that support this feature will need to be able to detect * when a variable value has changed and fire a changedEvent in its - * implementation of ICDIValue.getValueString(). + * implementation of ICDIValue.getValueString(). * - * @return whether this target supports passive variable updating. + * Also, targets that support this feature will not have their variables + * disposed when the user disables them in the GUI. Such a dispose only + * serves to reduce step-time overhead in the debugger engine. As such + * overhead is negligible for engines with passive variables, the dispose + * is unnecessary. + * + * @return whether this target supports passive variable updating. */ boolean supportsPassiveVariableUpdate(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index 5a2ad5a2b17..4c1ab6f4fd0 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -21,6 +21,8 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIMemoryChangedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration; +import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration2; import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration3; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor; @@ -142,12 +144,25 @@ public abstract class CVariable extends AbstractCVariable implements ICDIEventLi * @see org.eclipse.cdt.debug.core.model.ICVariable#setEnabled(boolean) */ public void setEnabled( boolean enabled ) throws DebugException { - IInternalVariable iv = getOriginal(); - if ( iv != null ) - iv.dispose( true ); - iv = getShadow(); - if ( iv != null ) - iv.dispose( true ); + // Debugger engines that use active variable objects will benefit + // performance-wise if we dispose the internal variable when it's + // disabled by the user (it will automatically get lazily recreated if + // it's ever needed again). Engines using passive variables probably + // won't, so we can defer the dispose until we have no use for the + // variable altogether. + boolean disposeVariable = true; + ICDITargetConfiguration configuration = getParent().getCDITarget().getConfiguration(); + if (configuration instanceof ICDITargetConfiguration2) { + disposeVariable = !((ICDITargetConfiguration2)configuration).supportsPassiveVariableUpdate(); + } + if (disposeVariable) { + IInternalVariable iv = getOriginal(); + if ( iv != null ) + iv.dispose( true ); + iv = getShadow(); + if ( iv != null ) + iv.dispose( true ); + } fIsEnabled = enabled; fireChangeEvent( DebugEvent.STATE ); }