Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v retrieving revision
1.207 diff -u -r1.207 ChangeLog --- ChangeLog 18 Jun 2003 20:59:15
-0000 1.207 +++ ChangeLog 20 Jun 2003 21:15:32 -0000 @@ -1,3
+1,14 @@ +2003-06-20 Mikhail Khodjaiants + Variable bookkeeping
(phase 0.1). + * ICDTLaunchConfigurationConstants.java: add a new
attribute - ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING. + *
ICVariable.java: added the 'canEnableDisable', 'isEnabled' and 'setEnabled'
methods + * CArrayPartition.java + *
CExpression.java + * CModificationVariable.java + *
CRegister.java + * CStackFrame.java + *
CVariable.java + 2003-06-18 Mikhail
Khodjaiants Incorrect casting in the 'setChanged' method of
CVariable. * CVariable.java Index:
src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java,v retrieving
revision 1.1 diff -u -r1.1 ICDTLaunchConfigurationConstants.java ---
src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java 7 Feb
2003 20:22:04 -0000 1.1 +++
src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java 20 Jun
2003 21:15:32 -0000 @@ -86,11 +86,15 @@
*/ public static final String ATTR_ATTACH_PROCESS_ID =
CDT_LAUNCH_ID + ".ATTACH_PROCESS_ID";
//$NON-NLS-1$ - /** * Launch
configuration attribute key. The value is the startup mode for the
debugger. */ public static final String
ATTR_DEBUGGER_START_MODE = CDT_LAUNCH_ID + ".DEBUGGER_START_MODE";
//$NON-NLS-1$ + + /** + * Launch configuration
attribute key. The value is a boolean specifying whether to enable variable
bookkeeping. + */ + public static final String
ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID +
".ENABLE_VARIABLE_BOOKKEEPING";
//$NON-NLS-1$ /** * Launch
configuration attribute value. The key is ATTR_DEBUGGER_START_MODE. Index:
src/org/eclipse/cdt/debug/core/model/ICVariable.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java,v retrieving
revision 1.8 diff -u -r1.8 ICVariable.java ---
src/org/eclipse/cdt/debug/core/model/ICVariable.java 10 Jun 2003 22:33:55
-0000 1.8 +++
src/org/eclipse/cdt/debug/core/model/ICVariable.java 20 Jun 2003 21:15:32
-0000 @@ -29,4 +29,10 @@ boolean
hasChildren(); String getQualifiedName() throws
DebugException; + + boolean isEnabled(); + + void
setEnabled( boolean enabled ) throws DebugException; + + boolean
canEnableDisable(); } Index:
src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java,v retrieving
revision 1.6 diff -u -r1.6 CArrayPartition.java ---
src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 6 Jun
2003 19:27:17 -0000 1.6 +++
src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 20 Jun
2003 21:15:32 -0000 @@ -136,4 +136,12
@@ { return
fEnd; } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable() +
*/ + public boolean
canEnableDisable() + { + return
false; + } } Index:
src/org/eclipse/cdt/debug/internal/core/model/CExpression.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java,v retrieving
revision 1.5 diff -u -r1.5 CExpression.java ---
src/org/eclipse/cdt/debug/internal/core/model/CExpression.java 9 Jun 2003
18:11:39 -0000 1.5 +++
src/org/eclipse/cdt/debug/internal/core/model/CExpression.java 20 Jun 2003
21:15:32 -0000 @@ -7,11 +7,12 @@ import
org.eclipse.cdt.debug.core.CDebugCorePlugin; import
org.eclipse.cdt.debug.core.ICDebugConstants; +import
org.eclipse.cdt.debug.core.cdi.CDIException; import
org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import
org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; import
org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import
org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import
org.eclipse.debug.core.DebugException; import
org.eclipse.debug.core.model.IExpression; import
org.eclipse.debug.core.model.IValue; @@ -41,9 +42,9 @@ *
@param target * @param cdiExpression
*/ - public CExpression( CDebugTarget target, ICDIVariable cdiVariable
) + public CExpression( CDebugTarget target, ICDIVariableObject
cdiVariableObject ) { - super( target, cdiVariable
); + super( target, cdiVariableObject
); fFormat =
CDebugCorePlugin.getDefault().getPluginPreferences().getInt(
ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT
); } @@ -82,7 +83,7
@@ super.dispose(); } - protected
ICDIExpression getCDIExpression() + protected ICDIExpression
getCDIExpression() throws
CDIException { return
(ICDIExpression)getCDIVariable(); } @@ -107,5 +108,21
@@ } } super.handleDebugEvent(event); + } + + /*
(non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#isEnabled() +
*/ + public boolean isEnabled() + { + return
true; + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable() +
*/ + public boolean
canEnableDisable() + { + return
false; } } Index:
src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java,v retrieving
revision 1.13 diff -u -r1.13 CModificationVariable.java ---
src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java 10
Jun 2003 16:47:24 -0000 1.13 +++
src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java 20
Jun 2003 21:15:32 -0000 @@ -9,6 +9,7 @@ import
org.eclipse.cdt.debug.core.cdi.CDIException; import
org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import
org.eclipse.debug.core.DebugException; import
org.eclipse.debug.core.model.IValue; @@ -25,9 +26,9
@@ * @param parent * @param
cdiVariable */ - public CModificationVariable(
CDebugElement parent, ICDIVariable cdiVariable ) + public
CModificationVariable( CDebugElement parent, ICDIVariableObject
cdiVariableObject ) { - super( parent, cdiVariable
); + super( parent, cdiVariableObject
); } /* (non-Javadoc) @@ -61,16
+62,15 @@ public final void setValue( String _expression_ ) throws
DebugException { String newExpression =
processExpression( _expression_ ); - ICDIVariable cdiVariable =
getCDIVariable(); - if ( cdiVariable == null
) - { - logError( "Error in
IValueModification#setValue: no cdi variable."
); - requestFailed( "Unable to set value.", null
); - return; - } + ICDIVariable
cdiVariable =
null; try { - cdiVariable.setValue(
newExpression ); + cdiVariable =
getCDIVariable(); + if ( cdiVariable != null
) + cdiVariable.setValue( newExpression
); + else + requestFailed( "Unable
to set value.", null
); + } catch(
CDIException e ) { @@ -86,16 +86,14 @@
*/ protected void setValue( ICDIValue value ) throws
DebugException { - ICDIVariable cdiVariable =
getCDIVariable(); - if ( cdiVariable == null
) - { - logError( "Error in
IValueModification#setValue: no cdi variable."
); - requestFailed( "Unable to set value.", null
); - return; - } + ICDIVariable
cdiVariable =
null; try { - cdiVariable.setValue(
value ); + cdiVariable =
getCDIVariable(); + if ( cdiVariable != null
) + cdiVariable.setValue( value
); + else + requestFailed( "Unable
to set value.", null ); } catch(
CDIException e ) { Index:
src/org/eclipse/cdt/debug/internal/core/model/CRegister.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegister.java,v retrieving
revision 1.4 diff -u -r1.4 CRegister.java ---
src/org/eclipse/cdt/debug/internal/core/model/CRegister.java 9 Jun 2003
18:11:39 -0000 1.4 +++
src/org/eclipse/cdt/debug/internal/core/model/CRegister.java 20 Jun 2003
21:15:32 -0000 @@ -52,4 +52,20
@@ } return
false; } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#isEnabled() +
*/ + public boolean isEnabled() + { + return
true; + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable() +
*/ + public boolean
canEnableDisable() + { + return
false; + } } Index:
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java,v retrieving
revision 1.20 diff -u -r1.20 CStackFrame.java ---
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 25 Apr 2003
19:36:20 -0000 1.20 +++
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 20 Jun 2003
21:15:32 -0000 @@ -16,9 +16,9 @@ import
org.eclipse.cdt.debug.core.cdi.ICDILocation; import
org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import
org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; -import
org.eclipse.cdt.debug.core.cdi.model.ICDIArgument; import
org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import
org.eclipse.cdt.debug.core.model.IRestart; import
org.eclipse.cdt.debug.core.model.IResumeWithoutSignal; import
org.eclipse.cdt.debug.core.model.IStackFrameInfo; @@ -102,12 +102,12
@@ { if ( fVariables == null
) { - List vars =
getAllCDIVariables(); + List vars =
getAllCDIVariableObjects(); fVariables = new
ArrayList( vars.size() ); Iterator it =
vars.iterator(); while( it.hasNext()
) { - fVariables.add( new
CModificationVariable( this, (ICDIVariable)it.next() )
); + fVariables.add( new CModificationVariable( this,
(ICDIVariableObject)it.next() )
); } } else
if ( refreshVariables() ) @@ -124,15 +124,14 @@
*/ protected void updateVariables() throws DebugException
{ - List locals =
getAllCDIVariables(); + List locals =
getAllCDIVariableObjects(); int index =
0; while( index < fVariables.size()
) { - CVariable local =
(CVariable)fVariables.get( index ); - ICDIVariable var =
findVariable( locals, local.getOriginalCDIVariable() ); - if
( var != null ) + ICDIVariableObject varObject =
findVariable( locals, (CVariable)fVariables.get( index )
); + if ( varObject != null
) { - locals.remove( var
); + locals.remove( varObject
); index++; } else @@
-570,12 +569,12 @@ * list if there are no local
variables. * */ - protected List
getCDILocalVariables() throws DebugException + protected List
getCDILocalVariableObjects() throws
DebugException { List list = new
ArrayList(); try { - list.addAll(
Arrays.asList( getCDIStackFrame().getLocalVariables() )
); + list.addAll( Arrays.asList(
getCDISession().getVariableManager().getLocalVariableObjects( getCDIStackFrame()
) ) ); } catch( CDIException e
) { @@ -589,12 +588,12 @@ * if there are
no arguments. * */ - protected List
getCDIArguments() throws DebugException + protected List
getCDIArgumentObjects() throws
DebugException { List list = new
ArrayList(); try { - list.addAll(
Arrays.asList( getCDIStackFrame().getArguments() )
); + list.addAll( Arrays.asList(
getCDISession().getVariableManager().getArgumentObjects( getCDIStackFrame() ) )
); } catch( CDIException e
) { @@ -602,7 +601,7
@@ } return
list; } - +/* protected List
getAllCDIVariables() throws
DebugException { List list = new
ArrayList(); @@ -610,6 +609,14 @@ list.addAll(
getCDILocalVariables() ); return list; }
+*/ + protected List getAllCDIVariableObjects() throws
DebugException + { + List list = new
ArrayList(); + list.addAll( getCDIArgumentObjects()
); + list.addAll( getCDILocalVariableObjects()
); + return list; + } protected
boolean isTopStackFrame() throws DebugException { @@ -684,8
+691,7 @@ } for ( int i = 0; i <
vars.length; ++i ) { - if ( vars[i]
instanceof CVariable && -
((CVariable)vars[i]).getOriginalCDIVariable() instanceof ICDIArgument
) + if ( vars[i] instanceof CVariable &&
((CVariable)vars[i]).isArgument()
) { list.add(
vars[i] ); } @@ -716,14 +722,14
@@ } } - protected
ICDIVariable findVariable( List list, ICDIVariable var ) + protected
ICDIVariableObject findVariable( List list, CVariable var
) { Iterator it =
list.iterator(); while( it.hasNext()
) { - ICDIVariable newVar =
(ICDIVariable)it.next(); - if ( newVar.equals( var )
) - return
newVar; + ICDIVariableObject newVarObject =
(ICDIVariableObject)it.next(); + if (
var.sameVariableObject( newVarObject ) ) + return
newVarObject; } return
null; } Index:
src/org/eclipse/cdt/debug/internal/core/model/CVariable.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v retrieving
revision 1.40 diff -u -r1.40 CVariable.java ---
src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 18 Jun 2003
20:59:15 -0000 1.40 +++
src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 20 Jun 2003
21:15:33 -0000 @@ -8,12 +8,14 @@ import
java.util.LinkedList; import
org.eclipse.cdt.debug.core.CDebugCorePlugin; +import
org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import
org.eclipse.cdt.debug.core.ICDebugConstants; import
org.eclipse.cdt.debug.core.cdi.CDIException; import
org.eclipse.cdt.debug.core.cdi.ICDIFormat; import
org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent; import
org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import
org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; +import
org.eclipse.cdt.debug.core.cdi.model.ICDIArgumentObject; import
org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import
org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import
org.eclipse.cdt.debug.core.cdi.model.ICDIValue; @@ -24,8 +26,10
@@ import org.eclipse.cdt.debug.core.model.ICVariable; import
org.eclipse.cdt.debug.core.model.ICastToArray; import
org.eclipse.cdt.debug.core.model.ICastToType; +import
org.eclipse.core.runtime.CoreException; import
org.eclipse.debug.core.DebugEvent; import
org.eclipse.debug.core.DebugException; +import
org.eclipse.debug.core.ILaunch; import
org.eclipse.debug.core.model.IDebugTarget; import
org.eclipse.debug.core.model.IValue; import
org.eclipse.debug.core.model.IVariable; @@ -42,20 +46,80
@@
ICastToType,
ICastToArray { + class
InternalVariable + { + private ICDIVariableObject
fCDIVariableObject; + + private ICDIVariable
fCDIVariable; + + public InternalVariable( ICDIVariableObject
varObject ) + { + setCDIVariableObject(
varObject ); + setCDIVariable( ( varObject instanceof
ICDIVariable ) ? (ICDIVariable)varObject : null
); + } + + protected synchronized ICDIVariable
getCDIVariable() throws CDIException + { + if
( fCDIVariable == null ) + { + if
( getCDIVariableObject() instanceof ICDIArgumentObject
) + fCDIVariable =
getCDISession().getVariableManager().createArgument(
(ICDIArgumentObject)getCDIVariableObject() ); + else
if ( getCDIVariableObject() instanceof ICDIVariableObject
) + fCDIVariable =
getCDISession().getVariableManager().createVariable( getCDIVariableObject()
); + } + return
fCDIVariable; + } + + protected
ICDIVariableObject
getCDIVariableObject() + { + return
fCDIVariableObject; + } + + private void
setCDIVariable( ICDIVariable variable
) + { + fCDIVariable =
variable; + } + + private void
setCDIVariableObject( ICDIVariableObject object
) + { + fCDIVariableObject =
object; + } + + protected synchronized void
invalidate() + { + try + { + if
( fCDIVariable != null
) + getCDISession().getVariableManager().destroyVariable(
fCDIVariable ); + } + catch(
CDIException e ) + { + logError(
e.getMessage() ); + } + setCDIVariable(
null ); + } + + protected void
dispose() + { + invalidate(); + setCDIVariableObject(
null ); + } + } + /** *
The parent object this variable is contained in.
*/ private CDebugElement
fParent; /** - * The underlying CDI
variable. + * The original internal variable.
*/ - private ICDIVariable fCDIVariable; + private
InternalVariable fOriginal; /** - * The
shadow CDI variable used for casting. + * The shadow internal variable
used for casting. */ - private ICDIVariable
fShadow; + private InternalVariable fShadow =
null; /** * Cache of current
value - see #getValue(). @@ -75,15 +139,6 @@ private Boolean
fEditable = null; /** - * Counter
corresponding to this variable's debug target - * suspend count
indicating the last time this value - * changed. This variable's value
has changed on the - * last suspend event if this counter is equal to
the - * debug target's suspend count. - */ - private
int fLastChangeIndex = -1; - - /** * Change
flag. */ protected boolean fChanged =
false; @@ -98,20 +153,80 @@ */ protected int
fFormat = ICDIFormat.NATURAL; + private boolean fIsEnabled =
true; + + /* + * Temporary solution to avoid NPE in
VariablesView. + * This is fixed in the Eclipse 2.1.1 Maintenance
Build. + */ + static private IValue fDisabledValue = new
IValue() + { + public
String getReferenceTypeName() throws
DebugException + { + return
null; + } + + public
String getValueString() throws
DebugException + { + return
null; + } + + public
boolean isAllocated() throws
DebugException + { + return
false; + } + + public
IVariable[] getVariables() throws
DebugException + { + return
null; + } + + public
boolean hasVariables() throws
DebugException + { + return
false; + } + + public
String
getModelIdentifier() + { + return
CDebugCorePlugin.getUniqueIdentifier(); + } + + public
IDebugTarget
getDebugTarget() + { + return
null; + } + + public
ILaunch
getLaunch() + { + return
null; + } + + public
Object getAdapter( Class adapter
) + { + return
null; + } + + }; /**
* Constructor for CVariable. * @param target
*/ - public CVariable( CDebugElement parent, ICDIVariable cdiVariable
) + public CVariable( CDebugElement parent, ICDIVariableObject
cdiVariableObject ) { super(
(CDebugTarget)parent.getDebugTarget() ); fParent =
parent; - fCDIVariable = cdiVariable; + fIsEnabled =
!enableVariableBookkeeping(); + fOriginal = createOriginal(
cdiVariableObject ); fShadow =
null; fFormat =
CDebugCorePlugin.getDefault().getPluginPreferences().getInt(
ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT
); getCDISession().getEventManager().addEventListener( this
); } + private InternalVariable createOriginal(
ICDIVariableObject varObject ) + { + return new
InternalVariable( varObject
); + } + /** * Returns the current
value of this variable. The value * is cached, but on each
access we see if the value has changed @@ -121,9 +236,13 @@
*/ public IValue getValue() throws
DebugException { + if ( !isEnabled()
) + return fDisabledValue; if ( fValue
== null ) { - fValue =
CValueFactory.createValue( this, getCurrentValue()
); + ICDIValue cdiValue =
getCurrentValue(); + if ( cdiValue != null
) + fValue = CValueFactory.createValue( this, cdiValue
); } return
fValue; } @@ -212,39 +331,11
@@ } /** - * Sets this
variable's change counter to the specified value - * - *
@param count new value - */ - protected void setChangeCount(
int count ) - { - fLastChangeIndex =
count; - } - - /** - * Returns this variable's
change counter. This corresponds to the - * last time this variable
changed. - * - * @return this variable's change
counter - */ - protected int
getChangeCount() - { - return
fLastChangeIndex; - } - - /** * Returns the
last known value for this variable */ protected
ICDIValue getLastKnownValue() { - if ( fValue ==
null ) - { - return
null; - } - else - { - return
fValue.getUnderlyingValue(); - } + return ( fValue
!= null ) ? fValue.getUnderlyingValue() :
null; } protected void
dispose() @@ -254,15 +345,8
@@ ((CValue)fValue).dispose(); } getCDISession().getEventManager().removeEventListener(
this ); - try - { - if (
getShadow() != null ) - destroyShadow( getShadow()
); - } - catch( DebugException e
) - { - logError( e
); - } + if ( getShadow() != null
) + getShadow().dispose(); } protected
synchronized void setChanged( boolean changed ) throws DebugException @@
-287,9 +371,16 @@ { if ( event
instanceof ICDIChangedEvent
) { - if ( source
instanceof ICDIVariable && source.equals( getCDIVariable() )
) + try + { + if
( source instanceof ICDIVariable && source.equals( getCDIVariable() )
) + { + handleChangedEvent(
(ICDIChangedEvent)event
); + } + } + catch(
CDIException e
) { - handleChangedEvent(
(ICDIChangedEvent)event ); + // do
nothing } } } @@
-323,10 +414,10 @@ * * @return the underlying
CDI variable */ - protected ICDIVariable
getCDIVariable() + protected ICDIVariable getCDIVariable() throws
CDIException { - if ( fShadow != null
) - return fShadow; + if ( getShadow() != null
) + return
getShadow().getCDIVariable(); return
getOriginalCDIVariable(); } @@ -346,7 +437,7
@@ { if ( fName == null
) { - String cdiName = (
getOriginalCDIVariable() != null ) ? getOriginalCDIVariable().getName() :
null; + String cdiName = ( fOriginal != null ) ?
fOriginal.getCDIVariableObject().getName() :
null; fName = cdiName; if
( cdiName != null && getParent() instanceof ICValue
) { @@ -369,7 +460,7 @@
*/ public String getReferenceTypeName() throws
DebugException { - return
getType().getName(); + return ( getType() != null ) ?
getType().getName() : null; } protected
void updateParentVariable( CValue parentValue ) throws DebugException @@
-410,11 +501,10
@@ { try { - ICDIVariable
newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type
); - ICDIVariable oldVar =
getShadow(); + InternalVariable newVar = createShadow(
getOriginalCDIVariable().getStackFrame(), type ); + if (
getShadow() != null
) + getShadow().dispose(); setShadow(
newVar ); - if ( oldVar != null
) - destroyShadow( oldVar
); } catch( CDIException e
) { @@ -422,15 +512,7
@@ } finally { - if
( fValue != null
) - { - ((CValue)fValue).dispose(); - fValue
= null; - } - fEditable =
null; - if ( fType != null
) - fType.dispose(); - fType =
null; + invalidateValue(); fireChangeEvent(
DebugEvent.STATE ); } } @@ -456,19
+538,11 @@ */ public void restoreDefault() throws
DebugException { - ICDIVariable oldVar =
getShadow(); + InternalVariable oldVar =
getShadow(); setShadow( null ); if (
oldVar != null ) - destroyShadow( oldVar
); - if ( fValue != null
) - { - ((CValue)fValue).dispose(); - fValue
= null; - } - fEditable = null; - if (
fType != null ) - fType.dispose(); - fType =
null; + oldVar.dispose(); + invalidateValue(); fireChangeEvent(
DebugEvent.STATE ); } @@ -481,27 +555,26
@@ return ( target != null && isEditable()
); } - protected ICDIVariable
getOriginalCDIVariable() + protected ICDIVariable
getOriginalCDIVariable() throws
CDIException { - return
fCDIVariable; + return ( fOriginal != null ) ?
fOriginal.getCDIVariable() : null; } - private
ICDIVariable getShadow() + private InternalVariable
getShadow() { return
fShadow; } - private void setShadow(
ICDIVariable shadow ) + private void setShadow( InternalVariable shadow
) { fShadow =
shadow; } - private ICDIVariable
createShadow( ICDIStackFrame cdiFrame, String type ) throws
DebugException + private InternalVariable createShadow( ICDIStackFrame
cdiFrame, String type ) throws
DebugException { try { - ICDIVariableObject
varObject = getCDISession().getVariableManager().getVariableObjectAsType(
getOriginalCDIVariable(), type ); - return
getCDISession().getVariableManager().createVariable( varObject
); + return new InternalVariable(
getCDISession().getVariableManager().getVariableObjectAsType(
getOriginalCDIVariable(), type )
); } catch( CDIException e
) { @@ -510,12 +583,11 @@ return
null; } - private ICDIVariable
createShadow( ICDIStackFrame cdiFrame, String type, int start, int length )
throws DebugException + private InternalVariable createShadow(
ICDIStackFrame cdiFrame, String type, int start, int length ) throws
DebugException { try { - ICDIVariableObject
varObject = getCDISession().getVariableManager().getVariableObjectAsArray(
getOriginalCDIVariable(), type, start, length ); - return
getCDISession().getVariableManager().createVariable( varObject
); + return new InternalVariable(
getCDISession().getVariableManager().getVariableObjectAsArray(
getOriginalCDIVariable(), type, start, length )
); } catch( CDIException e
) { @@ -523,18 +595,6
@@ } return
null; } - - private void destroyShadow(
ICDIVariable shadow ) throws
DebugException - { - try - { - getCDISession().getVariableManager().destroyVariable(
shadow ); - } - catch( CDIException e
) - { - targetRequestFailed( e.getMessage(),
null ); - } - } /*
(non-Javadoc) * @see
org.eclipse.cdt.debug.core.model.ICastToType#isCasted() @@ -551,11 +611,10
@@ { try { - ICDIVariable
newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type,
startIndex, length ); - ICDIVariable oldVar =
getShadow(); + InternalVariable newVar = createShadow(
getOriginalCDIVariable().getStackFrame(), type, startIndex, length
); + if ( getShadow() != null
) + getShadow().dispose(); setShadow(
newVar ); - if ( oldVar != null
) - destroyShadow( oldVar
); } catch( CDIException e
) { @@ -563,15 +622,7
@@ } finally { - if
( fValue != null
) - { - ((CValue)fValue).dispose(); - fValue
= null; - } - fEditable =
null; - if ( fType != null
) - fType.dispose(); - fType =
null; + invalidateValue(); fireChangeEvent(
DebugEvent.STATE ); } } @@ -606,11
+657,15 @@ */ public boolean
isEditable() { - if ( fEditable == null &&
getCDIVariable() != null ) + if ( !isEnabled()
) + return false; + if ( fEditable == null
) { try { - fEditable
= new Boolean( getCDIVariable().isEditable()
); + ICDIVariable var =
getCDIVariable(); + if ( var != null
) + fEditable = new Boolean( var.isEditable()
); } catch( CDIException e
) { @@ -689,11 +744,13 @@
*/ public ICType getType() throws
DebugException { - if ( fType == null &&
getCDIVariable() != null ) + if ( isEnabled() && fType ==
null
) { try { - fType
= new CType( getCDIVariable().getType()
); + ICDIVariable var =
getCDIVariable(); + if ( var != null
) + fType = new CType( var.getType()
); } catch( CDIException e
) { @@ -701,5 +758,76
@@ } } return
fType; + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#isEnabled() +
*/ + public boolean isEnabled() + { + return (
canEnableDisable() ) ? fIsEnabled : true; + } + + /*
(non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#setEnabled(boolean) +
*/ + public void setEnabled( boolean enabled ) throws
DebugException + { + setEnabled0( enabled
); + fireChangeEvent( DebugEvent.STATE
); + } + + private synchronized void setEnabled0( boolean
enabled ) + { + if ( fOriginal != null
) + fOriginal.invalidate(); + if ( getShadow()
!= null
) + getShadow().invalidate(); + fIsEnabled =
enabled; + invalidateValue(); + } + + private
void invalidateValue() + { + if ( fValue != null
) + { + ((CValue)fValue).dispose(); + fValue
= null; + } + fEditable = null; + if (
fType != null ) + fType.dispose(); + fType =
null; + } + + protected boolean
isArgument() + { + return ( fOriginal != null ) ? (
fOriginal.getCDIVariableObject() instanceof ICDIArgumentObject ) :
false; + } + + protected boolean sameVariableObject(
ICDIVariableObject object ) + { + return ( fOriginal !=
null ) ? ( object.getName().equals( fOriginal.getCDIVariableObject().getName() )
) : false; + } + + private boolean
enableVariableBookkeeping() + { + boolean result =
false; + try + { + result =
getLaunch().getLaunchConfiguration().getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
false ); + } + catch( CoreException e
) + { + } + return
result; + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable() +
*/ + public boolean
canEnableDisable() + { + return ( getParent() instanceof
CStackFrame ); } }
|