From 43e52e0f88e4d56032dcdea09965086bebbbb239 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 10 Sep 2002 22:41:10 +0000 Subject: [PATCH] Implementation of variables presentation in Variables view. --- .../org/eclipse/cdt/debug/core/ICValue.java | 39 +++++ .../core/model/CArrayEntryVariable.java | 78 ++++++++++ .../internal/core/model/CArrayPartition.java | 141 +++++++++++++++++ .../core/model/CArrayPartitionValue.java | 124 +++++++++++++++ .../internal/core/model/CLocalVariable.java | 7 +- .../cdt/debug/internal/core/model/CValue.java | 143 ++++++++++++++---- .../internal/core/model/CValueFactory.java | 29 ++++ .../debug/internal/core/model/CVariable.java | 17 +-- .../icons/full/obj16/var_aggr.gif | Bin 0 -> 147 bytes .../icons/full/obj16/var_env.gif | Bin 0 -> 198 bytes .../icons/full/obj16/var_global.gif | Bin 0 -> 132 bytes .../icons/full/obj16/var_global_aggr.gif | Bin 0 -> 147 bytes .../icons/full/obj16/var_pointer.gif | Bin 0 -> 130 bytes .../icons/full/obj16/var_simple.gif | Bin 0 -> 132 bytes .../icons/full/obj16/var_simple_aggr.gif | Bin 0 -> 147 bytes .../icons/full/obj16/var_static.gif | Bin 0 -> 132 bytes .../icons/full/obj16/var_static_aggr.gif | Bin 0 -> 147 bytes .../icons/full/obj16/var_string.gif | Bin 0 -> 71 bytes .../ui/CDTDebugModelPresentation.java | 59 +++++++- .../cdt/debug/internal/ui/CDebugImages.java | 8 + 20 files changed, 602 insertions(+), 43 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_aggr.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_env.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_global.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_global_aggr.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_pointer.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_simple.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_simple_aggr.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static_aggr.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_string.gif diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java new file mode 100644 index 00000000000..9ff06a52f9a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICValue.java @@ -0,0 +1,39 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.core; + +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.debug.core.model.IValue; + +/** + * + * Extends the IValue interface by C/C++ specific functionality. + * + * @since Sep 9, 2002 + */ +public interface ICValue extends IValue +{ + static final public int TYPE_SIMPLE = 0; + static final public int TYPE_ARRAY = 1; + static final public int TYPE_STRUCTURE = 2; + static final public int TYPE_STRING = 3; + static final public int TYPE_POINTER = 4; + static final public int TYPE_ARRAY_PARTITION = 5; + static final public int TYPE_ARRAY_ENTRY = 7; + + /** + * Returns the type of this value. + * + * @return the type of this value + */ + int getType(); + + /** + * Returns the underlying CDI value for this value. + */ + ICDIValue getUnderlyingValue(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java new file mode 100644 index 00000000000..63b84b31a87 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java @@ -0,0 +1,78 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.debug.core.DebugException; + +/** + * + * An entry in an array. + * + * @since Sep 9, 2002 + */ +public class CArrayEntryVariable extends CLocalVariable +{ + /** + * The index of the variable entry. + */ + private int fIndex; + + /** + * The type name of this variable. Cached lazily. + */ + private String fReferenceTypeName = null; + + /** + * Constructor for CArrayEntryVariable. + * @param target + */ + public CArrayEntryVariable( CDebugTarget target, ICDIVariable cdiVariable, int index ) + { + super( target, cdiVariable ); + fIndex = index; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IVariable#getName() + */ + public String getName() throws DebugException + { + return "[" + getIndex() + "]"; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName() + */ + public String getReferenceTypeName() throws DebugException + { + return stripBrackets( super.getReferenceTypeName() ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvent(ICDIEvent) + */ + public void handleDebugEvent(ICDIEvent event) + { + } + + protected int getIndex() + { + return fIndex; + } + + protected String stripBrackets( String typeName ) + { + int index = typeName.lastIndexOf( '[' ); + if ( index < 0 ) + return typeName; + return typeName.substring( 0, index ); + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java new file mode 100644 index 00000000000..d39ed9e0d24 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java @@ -0,0 +1,141 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.debug.core.cdi.CDIException; +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.model.ICDIObject; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IValue; + +/** + * + * A sub-range of an array. + * + * @since Sep 9, 2002 + */ +public class CArrayPartition extends CVariable +{ + static final protected int SLOT_SIZE = 100; + + private int fStart; + private int fEnd; + private List fCDIVariables; + + /** + * Cache of value. + */ + private CArrayPartitionValue fArrayPartitionValue = null; + + /** + * Constructor for CArrayPartition. + * @param target + */ + public CArrayPartition( CDebugTarget target, List cdiVariables, int start, int end ) + { + super( target ); + fStart = start; + fEnd = end; + fCDIVariables = cdiVariables; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.core.model.CVariable#retrieveValue() + */ + protected ICDIValue retrieveValue() throws DebugException, CDIException + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IVariable#getName() + */ + public String getName() throws DebugException + { + StringBuffer name = new StringBuffer(); + name.append( '[' ); + name.append( fStart ); + name.append( ".." ); + name.append( fEnd ); + name.append( ']' ); + return name.toString(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName() + */ + public String getReferenceTypeName() throws DebugException + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvent(ICDIEvent) + */ + public void handleDebugEvent( ICDIEvent event ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IVariable#getValue() + */ + public IValue getValue() throws DebugException + { + if ( fArrayPartitionValue == null ) + { + fArrayPartitionValue = new CArrayPartitionValue( (CDebugTarget)getDebugTarget(), fCDIVariables, getStart(), getEnd() ); + } + return fArrayPartitionValue; + } + + static public List splitArray( CDebugTarget target, List cdiVars, int start, int end ) + { + ArrayList children = new ArrayList(); + int perSlot = 1; + int len = end - start; + while( perSlot * SLOT_SIZE < len ) + { + perSlot = perSlot * SLOT_SIZE; + } + + while( start <= end ) + { + if ( start + perSlot > end ) + { + perSlot = end - start + 1; + } + CVariable var = null; + if ( perSlot == 1 ) + { + var = new CArrayEntryVariable( target, (ICDIVariable)cdiVars.get( start ), start ); + } + else + { + var = new CArrayPartition( target, cdiVars.subList( start, start + perSlot - 1 ), start, start + perSlot - 1 ); + } + children.add( var ); + start += perSlot; + } + return children; + } + + protected int getStart() + { + return fStart; + } + + protected int getEnd() + { + return fEnd; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java new file mode 100644 index 00000000000..651d80a3e14 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java @@ -0,0 +1,124 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.debug.core.ICValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IVariable; + +/** + * + * The value for an array partition. + * + * @since Sep 9, 2002 + */ +public class CArrayPartitionValue extends CDebugElement implements ICValue +{ + /** + * The underlying CDI variables. + */ + private List fCDIVariables; + + /** + * List of child variables. + */ + private List fVariables = Collections.EMPTY_LIST; + + private int fStart; + + private int fEnd; + + /** + * Constructor for CArrayPartitionValue. + * @param target + */ + public CArrayPartitionValue( CDebugTarget target, List cdiVariables, int start, int end ) + { + super( target ); + fCDIVariables = cdiVariables; + fStart = start; + fEnd = end; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICValue#getType() + */ + public int getType() + { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICValue#getUnderlyingValue() + */ + public ICDIValue getUnderlyingValue() + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName() + */ + public String getReferenceTypeName() throws DebugException + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#getValueString() + */ + public String getValueString() throws DebugException + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#isAllocated() + */ + public boolean isAllocated() throws DebugException + { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#getVariables() + */ + public IVariable[] getVariables() throws DebugException + { + if ( fVariables.isEmpty() ) + { + fVariables = new ArrayList( getEnd() - getStart() + 1 ); + for ( int i = getStart(); i <= getEnd(); ++i ) + fVariables.add( new CArrayEntryVariable( (CDebugTarget)getDebugTarget(), (ICDIVariable)fCDIVariables.get( i - getStart() ), i ) ); + } + return (IVariable[])fVariables.toArray( new IVariable[fVariables.size()] ); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IValue#hasVariables() + */ + public boolean hasVariables() throws DebugException + { + return true; + } + + protected int getStart() + { + return fStart; + } + + protected int getEnd() + { + return fEnd; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java index dbf250a9d0e..4ca128e3496 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java @@ -158,11 +158,8 @@ public class CLocalVariable extends CModificationVariable try { //setValue( getCurrentValue() ); - if ( !getValue().hasVariables() ) - { - setChanged( true ); - getParent().fireChangeEvent( DebugEvent.CONTENT ); - } + setChanged( true ); + getParent().fireChangeEvent( DebugEvent.CONTENT ); } catch( DebugException e ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index 65f3117e94a..db879c6dd08 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -12,6 +12,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.eclipse.cdt.debug.core.ICValue; 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; @@ -25,26 +26,37 @@ import org.eclipse.debug.core.model.IVariable; * * @since Aug 9, 2002 */ -public class CValue extends CDebugElement implements IValue +public class CValue extends CDebugElement implements ICValue { + /** + * Cached value. + */ + private String fValueString = null; + /** * Underlying CDI value. */ - private ICDIValue fValue; + private ICDIValue fCDIValue; /** * List of child variables. */ private List fVariables = Collections.EMPTY_LIST; + /** + * Type (simple, array, structure or string) of this value. + */ + private int fType = TYPE_SIMPLE; + /** * Constructor for CValue. * @param target */ - public CValue( CDebugTarget target, ICDIValue cdiValue ) + public CValue( CDebugTarget target, ICDIValue cdiValue ) throws DebugException { super( target ); - fValue = cdiValue; + fCDIValue = cdiValue; + calculateType(); } /* (non-Javadoc) @@ -52,7 +64,19 @@ public class CValue extends CDebugElement implements IValue */ public String getReferenceTypeName() throws DebugException { - return null; + String typeName = null; + try + { + if ( fCDIValue != null ) + { + typeName = fCDIValue.getTypeName(); + } + } + catch( CDIException e ) + { + targetRequestFailed( "Operation failed. Reason: ", e ); + } + return typeName; } /* (non-Javadoc) @@ -60,12 +84,11 @@ public class CValue extends CDebugElement implements IValue */ public String getValueString() throws DebugException { - String result = null; - if ( getUnderlyingValue() != null ) + if ( fValueString == null && getUnderlyingValue() != null ) { try { - result = getUnderlyingValue().getValueString(); + fValueString = processCDIValue( getUnderlyingValue().getValueString() ); } catch( CDIException e ) { @@ -73,7 +96,7 @@ public class CValue extends CDebugElement implements IValue requestFailed( "", e ); } } - return result; + return fValueString; } /* (non-Javadoc) @@ -100,11 +123,20 @@ public class CValue extends CDebugElement implements IValue if ( fVariables.size() == 0 ) { List vars = getCDIVariables(); - fVariables = new ArrayList( vars.size() ); - Iterator it = vars.iterator(); - while( it.hasNext() ) + if ( getType() == ICValue.TYPE_ARRAY ) { - fVariables.add( new CLocalVariable( this, (ICDIVariable)it.next() ) ); + int length = getNumberOfChildren(); + if ( length > 0 ) + fVariables = CArrayPartition.splitArray( (CDebugTarget)getDebugTarget(), vars, 0, length - 1 ); + } + else + { + fVariables = new ArrayList( vars.size() ); + Iterator it = vars.iterator(); + while( it.hasNext() ) + { + fVariables.add( new CLocalVariable( this, (ICDIVariable)it.next() ) ); + } } } return fVariables; @@ -119,7 +151,7 @@ public class CValue extends CDebugElement implements IValue { ICDIValue value = getUnderlyingValue(); if ( value != null ) - return value.hasChildren(); + return value.getChildrenNumber() > 0; } catch( CDIException e ) { @@ -128,21 +160,12 @@ public class CValue extends CDebugElement implements IValue return false; } - /** - * Creates the appropriate kind of value, or null. - * + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICValue#getUnderlyingValue() */ - public static CValue createValue( CDebugTarget target, ICDIValue value ) + public ICDIValue getUnderlyingValue() { - return new CValue( target, value ); - } - - /** - * Returns this value's underlying CDI value - */ - protected ICDIValue getUnderlyingValue() - { - return fValue; + return fCDIValue; } protected List getCDIVariables() throws DebugException @@ -161,4 +184,70 @@ public class CValue extends CDebugElement implements IValue } return Collections.EMPTY_LIST; } + + protected void calculateType() throws DebugException + { + String stringValue = getValueString(); + if ( stringValue != null && stringValue.trim().length() > 0 ) + { + stringValue = stringValue.trim(); + if ( stringValue.charAt( 0 ) == '[' ) + { + fType = TYPE_ARRAY; + } + else if ( stringValue.charAt( 0 ) == '{' ) + { + fType = TYPE_STRUCTURE; + } + else if ( stringValue.startsWith( "0x" ) ) + { + fType = TYPE_POINTER; + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICValue#getType() + */ + public int getType() + { + return fType; + } + + protected int getNumberOfChildren() throws DebugException + { + int result = 0; + try + { + result = getUnderlyingValue().getChildrenNumber(); + } + catch( CDIException e ) + { + targetRequestFailed( "Operation failed. Reason: ", e ); + } + return result; + } + + protected String processCDIValue( String cdiValue ) + { + return cdiValue; + } + + public synchronized void setChanged( boolean changed ) throws DebugException + { + if ( changed ) + { + fValueString = null; + } +/* + if ( hasVariables() ) + { + IVariable[] vars = getVariables(); + for ( int i = 0; i < vars.length; ++i ) + { + ((CVariable)vars[i]).setChanged( changed ); + } + } +*/ + } } 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 new file mode 100644 index 00000000000..c3009a1eb5d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java @@ -0,0 +1,29 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.ICValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.debug.core.DebugException; + +/** + * + * Generates variable values. + * + * @since Sep 9, 2002 + */ +public class CValueFactory +{ + /** + * Creates the appropriate kind of value, or null. + * + */ + static public ICValue createValue( CDebugTarget target, ICDIValue cdiValue ) throws DebugException + { + return new CValue( target, 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 a8b877fd331..21fd4eb6aa3 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 @@ -7,6 +7,7 @@ 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.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; @@ -27,7 +28,7 @@ public abstract class CVariable extends CDebugElement /** * Cache of current value - see #getValue(). */ - private CValue fValue; + private ICValue fValue; /** * Counter corresponding to this variable's debug target @@ -65,7 +66,7 @@ public abstract class CVariable extends CDebugElement ICDIValue currentValue = getCurrentValue(); if ( fValue == null ) { - fValue = CValue.createValue( (CDebugTarget)getDebugTarget(), currentValue ); + fValue = CValueFactory.createValue( (CDebugTarget)getDebugTarget(), currentValue ); } return fValue; } @@ -199,17 +200,13 @@ public abstract class CVariable extends CDebugElement protected synchronized void setChanged( boolean changed ) throws DebugException { - if ( getValue().hasVariables() ) + if ( getValue() != null ) { - IVariable[] vars = getValue().getVariables(); - for ( int i = 0; i < vars.length; ++i ) + ((CValue)getValue()).setChanged( changed ); + if ( !getValue().hasVariables() ) { - ((CVariable)vars[i]).setChanged( changed ); + fChanged = changed; } } - else - { - fChanged = changed; - } } } diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_aggr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_aggr.gif new file mode 100644 index 0000000000000000000000000000000000000000..1aec8baac603a57f51d988166d66a1bc95802587 GIT binary patch literal 147 zcmZ?wbhEHb6krfw*v!Ci;prcSlGhCJ2N@ii(4_j7f>om{<*y@*6`=@d+SOWlUYB@Im literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_env.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_env.gif new file mode 100644 index 0000000000000000000000000000000000000000..65d63ec00d629d98c809a5589f41250a05792927 GIT binary patch literal 198 zcmZ?wbhEHb6krfwIKseCoU8f!=Yv1L9{ag5JU+|j@6Ht9!TjVrZ;%&jkQdw23&PJX zh$lw!q$h}Fr%1hfnD+JUqOb2({rqzL=hrj8f81qYVEF(4Kaj))6o0ZXGBAiS=ztV} z>||hdUZC2Sk~uG9mercYo0?RZ-@Ob72z3ldX1BbTH_^bd!AjPp(ZH|C=ET8-9*(Ik cO}eM5Gje%aBMet8gUO+-#1PC|NlP& zDp35%!pOkD#h?Qc2ARRYVi<7JbM;<}=tI@|(F$ywO*{@25>DN5E(dmL%4|8*Ey%f6 Xup>s7`O4p(S%(4+=UABvGFSruO_(bv literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_global_aggr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_global_aggr.gif new file mode 100644 index 0000000000000000000000000000000000000000..694d6f6f3bd6c6c48b5cec95cd3d8d41da8e3b18 GIT binary patch literal 147 zcmZ?wbhEHb6krfw*v!Dttj+NA%(g%GFTD0CMz|Wuq+Z^fq|1j2P6(MgMr1+;H2m3y%y1js`aB4*iIDkI8;bDb;r3J*rh46`Y literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_simple_aggr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_simple_aggr.gif new file mode 100644 index 0000000000000000000000000000000000000000..9ff5c50ace92650cbb2e9b8c8c67554035023438 GIT binary patch literal 147 zcmZ?wbhEHb6krfw*v!Dd5YfEt@y`oy|1ivd&CqmEzVC?fruW8E4*Ku;n0oZ{#B1L# zzx)0F|9_xD2vGdV!pOkD!=MA=g3MrGahPz@bM;<}=)=|avlY0!CJ8vqP;l;!Ydf$@ vQ)kQJ(;~B-yxXLXPB?Luhw)*{3S*t7*=Y@nr^sZnHiWHyS+##E2ZJ>LH?=!7 literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static.gif new file mode 100644 index 0000000000000000000000000000000000000000..1ffe406e283853ab302a0741a9d436b94b1b80b1 GIT binary patch literal 132 zcmZ?wbhEHb6krfw*v!E2dM(4jK8EH*hWGo756(9Jc+CIv+0@VHQorAs_~+w=|Ns9p zpaR98EQ|~cTnsuOVUQUNEQSFmJy-9wxP7o%Jz7caL?Me)hKNIVob#bwnsc@s=;q~E X%iA8K%Y5Z;kJO=n!#P%_f(+IGZhbDU literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static_aggr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/var_static_aggr.gif new file mode 100644 index 0000000000000000000000000000000000000000..c63f58ee7b3799c468c26443dce4e40524c7fb75 GIT binary patch literal 147 zcmZ?wbhEHb6krfw*v!E2dM(4jK8EH*h9fiO-|sU%INSK+G5^nJQ$L?e{eEZS&llVN ze7x}c1_O)3hLfJF_gX|Bs@A`)q{rFB;#48w&>eT= x&@RnATMpdjiFWdCk!o!?ag~GXVap0-gQnTbnifwH$zpB{Tm70r5dH3`}x8{VPwu&1Yyx49i%1I#BOr VA(y&Z%9n*#mju4!)@Eg}1^|kL6)OM$ literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 07aa3c1b2cf..57a24cd4fbf 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -13,6 +13,7 @@ import org.eclipse.cdt.debug.core.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.ICBreakpoint; import org.eclipse.cdt.debug.core.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.ICLineBreakpoint; +import org.eclipse.cdt.debug.core.ICValue; import org.eclipse.cdt.debug.core.ICWatchpoint; import org.eclipse.cdt.debug.core.IStackFrameInfo; import org.eclipse.cdt.debug.core.IState; @@ -21,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIExitInfo; import org.eclipse.cdt.debug.core.cdi.ICDISignal; import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope; import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger; +import org.eclipse.cdt.debug.internal.core.model.CValue; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; @@ -173,6 +175,10 @@ public class CDTDebugModelPresentation extends LabelProvider { return getBreakpointImage( (ICBreakpoint)element ); } + if ( element instanceof IVariable ) + { + return getVariableImage( (IVariable)element ); + } } catch( CoreException e ) { @@ -366,9 +372,34 @@ public class CDTDebugModelPresentation extends LabelProvider String label = new String(); if ( var != null ) { + if ( isShowVariableTypeNames() ) + { + label += var.getReferenceTypeName() + " "; + } label += var.getName(); IValue value = var.getValue(); - label += "= " + value.getValueString(); + if ( value != null && value.getValueString() != null ) + { + if ( value instanceof ICValue ) + { + switch( ((ICValue)value).getType() ) + { + case ICValue.TYPE_ARRAY: + label += value.getValueString(); + break; + case ICValue.TYPE_STRUCTURE: + break; + default: + label += "= " + value.getValueString(); + break; + + } + } + else + { + label += "= " + value.getValueString(); + } + } } return label; } @@ -585,4 +616,30 @@ public class CDTDebugModelPresentation extends LabelProvider } return flags; } + + protected Image getVariableImage( IVariable element ) throws DebugException + { + if ( element != null ) + { + IValue value = element.getValue(); + if ( value instanceof ICValue ) + return getValueTypeImage( (ICValue)value ); + } + return null; + } + + protected Image getValueTypeImage( ICValue element ) + { + if ( element != null ) + { + if ( element.getType() == ICValue.TYPE_ARRAY || + element.getType() == ICValue.TYPE_STRUCTURE ) + return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE, 0 ) ); + else if ( element.getType() == ICValue.TYPE_POINTER ) + return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_POINTER, 0 ) ); + else + return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_SIMPLE, 0 ) ); + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index a6755f702a1..cb329814eb3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -54,6 +54,10 @@ public class CDebugImages public static final String IMG_OBJS_READ_WATCHPOINT_DISABLED = NAME_PREFIX + "read_obj_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_SIMPLE = NAME_PREFIX + "var_simple.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_AGGREGATE = NAME_PREFIX + "var_aggr.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_POINTER = NAME_PREFIX + "var_pointer.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_STRING = NAME_PREFIX + "var_string.gif"; //$NON-NLS-1$ /* * Set of predefined Image Descriptors. @@ -75,6 +79,10 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_DISABLED ); public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_DISABLED ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE = createManaged( T_OBJ, IMG_OBJS_VARIABLE_SIMPLE ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE = createManaged( T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER = createManaged( T_OBJ, IMG_OBJS_VARIABLE_POINTER ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_STRING = createManaged( T_OBJ, IMG_OBJS_VARIABLE_STRING ); /** * Returns the image managed under the given key in this registry.