mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Variable bookkeeping (phase 0.1).
This commit is contained in:
parent
bd7e73016d
commit
b121523ac4
9 changed files with 360 additions and 166 deletions
|
@ -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
|
||||
|
|
|
@ -86,12 +86,16 @@ public interface ICDTLaunchConfigurationConstants {
|
|||
*/
|
||||
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.
|
||||
* Startup debugger running the program.
|
||||
|
|
|
@ -29,4 +29,10 @@ public interface ICVariable extends IVariable
|
|||
boolean hasChildren();
|
||||
|
||||
String getQualifiedName() throws DebugException;
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
void setEnabled( boolean enabled ) throws DebugException;
|
||||
|
||||
boolean canEnableDisable();
|
||||
}
|
||||
|
|
|
@ -136,4 +136,12 @@ public class CArrayPartition extends CVariable
|
|||
{
|
||||
return fEnd;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
|
||||
*/
|
||||
public boolean canEnableDisable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,12 @@ package org.eclipse.cdt.debug.internal.core.model;
|
|||
|
||||
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 @@ public class CExpression extends CModificationVariable
|
|||
* @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 @@ public class CExpression extends CModificationVariable
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
protected ICDIExpression getCDIExpression()
|
||||
protected ICDIExpression getCDIExpression() throws CDIException
|
||||
{
|
||||
return (ICDIExpression)getCDIVariable();
|
||||
}
|
||||
|
@ -108,4 +109,20 @@ public class CExpression extends CModificationVariable
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.eclipse.cdt.debug.internal.core.model;
|
|||
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 @@ public class CModificationVariable extends CVariable
|
|||
* @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 class CModificationVariable extends CVariable
|
|||
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 = getCDIVariable();
|
||||
if ( cdiVariable != null )
|
||||
cdiVariable.setValue( newExpression );
|
||||
else
|
||||
requestFailed( "Unable to set value.", null );
|
||||
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
|
@ -86,16 +86,14 @@ public class CModificationVariable extends CVariable
|
|||
*/
|
||||
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 = getCDIVariable();
|
||||
if ( cdiVariable != null )
|
||||
cdiVariable.setValue( value );
|
||||
else
|
||||
requestFailed( "Unable to set value.", null );
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
|
|
|
@ -52,4 +52,20 @@ public class CRegister extends CGlobalVariable implements IRegister
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
|
|||
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 @@ public class CStackFrame extends CDebugElement
|
|||
{
|
||||
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 @@ public class CStackFrame extends CDebugElement
|
|||
*/
|
||||
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 @@ public class CStackFrame extends CDebugElement
|
|||
* 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 @@ public class CStackFrame extends CDebugElement
|
|||
* 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 @@ public class CStackFrame extends CDebugElement
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
protected List getAllCDIVariables() throws DebugException
|
||||
{
|
||||
List list = new ArrayList();
|
||||
|
@ -610,6 +609,14 @@ public class CStackFrame extends CDebugElement
|
|||
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 @@ public class CStackFrame extends CDebugElement
|
|||
}
|
||||
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 @@ public class CStackFrame extends CDebugElement
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ package org.eclipse.cdt.debug.internal.core.model;
|
|||
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.ICValue;
|
|||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
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().
|
||||
|
@ -74,15 +138,6 @@ public abstract class CVariable extends CDebugElement
|
|||
|
||||
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.
|
||||
*/
|
||||
|
@ -98,20 +153,80 @@ public abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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 abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -211,40 +330,12 @@ public abstract class CVariable extends CDebugElement
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public abstract class CVariable extends CDebugElement
|
|||
((CValue)fValue).dispose();
|
||||
}
|
||||
getCDISession().getEventManager().removeEventListener( this );
|
||||
try
|
||||
{
|
||||
if ( getShadow() != null )
|
||||
destroyShadow( getShadow() );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
logError( e );
|
||||
}
|
||||
getShadow().dispose();
|
||||
}
|
||||
|
||||
protected synchronized void setChanged( boolean changed ) throws DebugException
|
||||
|
@ -286,12 +370,19 @@ public abstract class CVariable extends CDebugElement
|
|||
if ( source.getTarget().equals( getCDITarget() ) )
|
||||
{
|
||||
if ( event instanceof ICDIChangedEvent )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( source instanceof ICDIVariable && source.equals( getCDIVariable() ) )
|
||||
{
|
||||
handleChangedEvent( (ICDIChangedEvent)event );
|
||||
}
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,10 +414,10 @@ public abstract class CVariable extends CDebugElement
|
|||
*
|
||||
* @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 @@ public abstract class CVariable extends CDebugElement
|
|||
{
|
||||
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 abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
{
|
||||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
}
|
||||
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 abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
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 )
|
||||
{
|
||||
|
@ -524,18 +596,6 @@ public abstract class CVariable extends CDebugElement
|
|||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
{
|
||||
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 @@ public abstract class CVariable extends CDebugElement
|
|||
}
|
||||
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 abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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 abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
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 )
|
||||
{
|
||||
|
@ -702,4 +759,75 @@ public abstract class CVariable extends CDebugElement
|
|||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue