diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalValue.java new file mode 100644 index 00000000000..a0a3655760f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalValue.java @@ -0,0 +1,38 @@ +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.debug.core.DebugException; + +/** + * + * Enter type comment. + * + * @since: Oct 2, 2002 + */ +public class CGlobalValue extends CValue +{ + private Boolean fHasChildren = null; + + + /** + * Constructor for CGlobalValue. + * @param parent + * @param cdiValue + */ + public CGlobalValue( CVariable parent, ICDIValue cdiValue ) + { + super( parent, cdiValue ); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#hasVariables() + */ + public boolean hasVariables() throws DebugException + { + if ( fHasChildren == null ) + { + fHasChildren = new Boolean( super.hasVariables() ); + } + return fHasChildren.booleanValue(); + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalVariable.java new file mode 100644 index 00000000000..d2d4e29e0a3 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CGlobalVariable.java @@ -0,0 +1,39 @@ +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IValue; + +/** + * + * Enter type comment. + * + * @since: Oct 2, 2002 + */ +public class CGlobalVariable extends CModificationVariable +{ + /** + * Constructor for CGlobalVariable. + * @param parent + * @param cdiVariable + */ + public CGlobalVariable( CDebugElement parent, ICDIVariable cdiVariable ) + { + super( parent, cdiVariable ); + } + + /** + * Returns the current value of this variable. The value + * is cached. + * + * @see org.eclipse.debug.core.model.IVariable#getValue() + */ + public IValue getValue() throws DebugException + { + if ( fValue == null ) + { + fValue = CValueFactory.createGlobalValue( this, getCurrentValue() ); + } + return fValue; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegister.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegister.java index 6ecbf74406c..f258a3227b5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegister.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegister.java @@ -6,7 +6,6 @@ package org.eclipse.cdt.debug.internal.core.model; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister; -import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IRegister; import org.eclipse.debug.core.model.IRegisterGroup; @@ -17,7 +16,7 @@ import org.eclipse.debug.core.model.IRegisterGroup; * * @since Sep 16, 2002 */ -public class CRegister extends CModificationVariable implements IRegister +public class CRegister extends CGlobalVariable implements IRegister { /** * Constructor for CRegister. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegisterGroup.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegisterGroup.java index d606b8cab2e..f8869e50f08 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegisterGroup.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CRegisterGroup.java @@ -6,7 +6,6 @@ package org.eclipse.cdt.debug.internal.core.model; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -84,11 +83,13 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup fRegisters.add( new CRegister( this, regs[i] ) ); } } +/* else if ( fRefresh ) { updateRegisters(); } fRefresh = false; +*/ return fRegisters; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java index 478cac1de93..054481d644f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java @@ -22,4 +22,9 @@ public class CValueFactory { return new CValue( parent, cdiValue ); } + + static public ICValue createGlobalValue( CVariable parent, ICDIValue cdiValue ) throws DebugException + { + return new CGlobalValue( parent, cdiValue ); + } } 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 72c9b574827..d0334bbe76f 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 @@ -5,8 +5,6 @@ */ package org.eclipse.cdt.debug.internal.core.model; -import java.text.MessageFormat; - import org.eclipse.cdt.debug.core.ICValue; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent; @@ -44,7 +42,7 @@ public abstract class CVariable extends CDebugElement /** * Cache of current value - see #getValue(). */ - private ICValue fValue; + protected ICValue fValue; /** * Counter corresponding to this variable's debug target @@ -60,6 +58,11 @@ public abstract class CVariable extends CDebugElement */ private boolean fChanged = false; + /** + * The type name of this variable. + */ + private String fTypeName = null; + /** * Constructor for CVariable. * @param target @@ -81,10 +84,9 @@ public abstract class CVariable extends CDebugElement */ public IValue getValue() throws DebugException { - ICDIValue currentValue = getCurrentValue(); if ( fValue == null ) { - fValue = CValueFactory.createValue( this, currentValue ); + fValue = CValueFactory.createValue( this, getCurrentValue() ); } return fValue; } @@ -321,16 +323,18 @@ public abstract class CVariable extends CDebugElement */ public String getReferenceTypeName() throws DebugException { - String type = null; - try + if ( fTypeName == null ) { - type = getCDIVariable().getTypeName(); + try + { + fTypeName = getCDIVariable().getTypeName(); + } + catch( CDIException e ) + { + targetRequestFailed( e.getMessage(), null ); + } } - catch( CDIException e ) - { - targetRequestFailed( e.getMessage(), null ); - } - return type; + return fTypeName; } protected void updateParentVariable( CValue parentValue ) throws DebugException