diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 3e3692d1ced..caa7f31b841 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2004-10-06 Mikhail Khodjaiants + Use the same approach to generate expressions and variables labels. + * CDTDebugModelPresentation.java + 2004-09-21 Mikhail Khodjaiants Fixed the problems with the Disassembly view and address breakpoints caused by switch to IAddress. * CBreakpointPropertyPage.java 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 4f2ac4cb2cc..3f0b7aee1e4 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 @@ -307,6 +307,10 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo label.append( getVariableText( (IVariable)element ) ); return label.toString(); } + if ( element instanceof IValue ) { + label.append( getValueText( (IValue)element ) ); + return label.toString(); + } if ( element instanceof IStackFrame ) { label.append( getStackFrameText( (IStackFrame)element, showQualified ) ); return label.toString(); @@ -473,21 +477,23 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo } else { IValue value = expression.getValue(); - if ( value != null ) { + if ( value instanceof ICValue ) { + ICType type = null; + try { + type = ((ICValue)value).getType(); + } + catch( DebugException e1 ) { + } + if ( type != null && isShowVariableTypeNames() ) { + String typeName = getVariableTypeName( type ); + if ( !isEmpty( typeName ) ) { + result.insert( 0, typeName + ' ' ); + } + } String valueString = DebugUIPlugin.getModelPresentation().getText( value ); if ( valueString.length() > 0 ) { result.append( " = " ).append( valueString ); //$NON-NLS-1$ } - if ( isShowVariableTypeNames() ) { - String type = null; - try { - type = value.getReferenceTypeName(); - } - catch( DebugException e ) { - } - if ( !isEmpty( type ) ) - result.insert( 0, type + ' ' ); - } } } if ( !expression.isEnabled() ) { @@ -519,22 +525,42 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo label.append( ']' ); } } - label.append( ' ' ); } } String name = var.getName(); if ( name != null ) label.append( name.trim() ); IValue value = var.getValue(); - if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) { - label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$ + String valueString = DebugUIPlugin.getModelPresentation().getText( value ); + if ( !isEmpty( valueString ) ) { + label.append( " = " ); //$NON-NLS-1$ + label.append( valueString ); } - else if ( value instanceof ICValue && value.getValueString() != null ) { - String valueString = value.getValueString().trim(); + } + if ( !((ICVariable)var).isEnabled() ) { + label.append( ' ' ); + label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$ + } + return label.toString(); + } + + protected String getValueText( IValue value ) throws DebugException { + StringBuffer label = new StringBuffer(); + if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) { + label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$ + } + else if ( value instanceof ICValue ) { + ICType type = null; + try { + type = ((ICValue)value).getType(); + } + catch( DebugException e ) { + } + String valueString = value.getValueString().trim(); + if ( valueString != null ) { if ( type != null && type.isCharacter() ) { if ( valueString.length() == 0 ) valueString = "."; //$NON-NLS-1$ - label.append( "= " ); //$NON-NLS-1$ label.append( valueString ); } else if ( type != null && type.isFloatingPointType() ) { @@ -545,21 +571,15 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$ if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) ) valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$ - label.append( "= " ); //$NON-NLS-1$ label.append( valueString ); } else if ( type == null || (!type.isArray() && !type.isStructure()) ) { if ( valueString.length() > 0 ) { - label.append( "= " ); //$NON-NLS-1$ label.append( valueString ); } } } - } - if ( !((ICVariable)var).isEnabled() ) { - label.append( ' ' ); - label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$ - } + } return label.toString(); } @@ -811,13 +831,25 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo } private String getVariableTypeName( ICType type ) { + StringBuffer result = new StringBuffer(); String typeName = type.getName(); if ( type.isArray() && typeName != null ) { int index = typeName.indexOf( '[' ); if ( index != -1 ) - return typeName.substring( 0, index ).trim(); + typeName = typeName.substring( 0, index ).trim(); } - return typeName; + if ( typeName != null && typeName.length() > 0 ) { + result.append( typeName ); + if ( type.isArray() ) { + int[] dims = type.getArrayDimensions(); + for( int i = 0; i < dims.length; ++i ) { + result.append( '[' ); + result.append( dims[i] ); + result.append( ']' ); + } + } + } + return result.toString(); } /*