diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 429b309d50b..1dde54d0e50 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,7 @@ +2003-04-21 Mikhail Khodjaiants + Temporary fix for character values. + * CValue.java + 2003-04-20 Alain Magloire * CValue.java: 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 aa8a2ef7176..a13566efa2f 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 @@ -87,7 +87,8 @@ public class CValue extends CDebugElement implements ICValue { try { - fValueString = processCDIValue( getUnderlyingValue().getValueString() ); +// fValueString = processCDIValue( getUnderlyingValue().getValueString() ); + fValueString = getUnderlyingValue().getValueString(); } catch( CDIException e ) { @@ -95,7 +96,7 @@ public class CValue extends CDebugElement implements ICValue fValueString = e.getMessage(); } } - return fValueString; + return ( fValueString != null ) ? processCDIValue( fValueString ) : null; } /* (non-Javadoc) @@ -223,11 +224,17 @@ public class CValue extends CDebugElement implements ICValue end = result.length(); result = result.substring( 0, end ); } - else if ( result.endsWith("'")) + else if ( result.endsWith( "\'" ) ) { int start = result.indexOf( '\'' ); - if ( start != -1 ) + if ( start != -1 && result.length() - start == 3 ) + { result = result.substring( start ); + } + else + { + result = null; + } } } return result; @@ -262,28 +269,38 @@ public class CValue extends CDebugElement implements ICValue public String getUnderlyingValueString() { - ICDIValue cdiValue = getUnderlyingValue(); - String value = null; - if ( cdiValue != null ) + if ( fValueString == null && getUnderlyingValue() != null ) { try { - value = cdiValue.getValueString(); + fValueString = getUnderlyingValue().getValueString(); } catch( CDIException e ) { + logError( e ); + fValueString = e.getMessage(); } } - return value; + return fValueString; } public boolean isCharPointer() { - String value = getUnderlyingValueString(); + String value = getUnderlyingValueString().trim(); if ( value != null ) { return ( value.startsWith( "0x" ) && value.indexOf( ' ' ) != -1 ); } return false; } + + public boolean isCharacter() + { + String value = getUnderlyingValueString().trim(); + if ( value != null ) + { + return ( value.endsWith( "\'" ) ); + } + return false; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index b2032b4e0e7..d148cf36d73 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-04-21 Mikhail Khodjaiants + Temporary fix for character values. + * CDTDebugModelPresentation.java + 2003-04-16 Mikhail Khodjaiants Quick fix for variable values. * CDTDebugModelPresentation.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 ab297d91906..ed17bcf0a57 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 @@ -489,11 +489,13 @@ public class CDTDebugModelPresentation extends LabelProvider } label += var.getName(); IValue value = var.getValue(); - if ( value != null && value.getValueString() != null && value.getValueString().trim().length() > 0 ) + if ( value != null ) { - if ( value instanceof CValue && ((CValue)value).isCharPointer() ) + if ( value instanceof CValue && ((CValue)value).isCharacter() ) + label += getCharacterValue( (CValue)value ); + else if ( value instanceof CValue && ((CValue)value).isCharPointer() ) label += "= " + ((CValue)value).getUnderlyingValueString(); - else + else if ( value.getValueString() != null && value.getValueString().trim().length() > 0 ) label += getVariableValue( value.getValueString().trim() ); // label += "= " + value.getValueString(); } @@ -879,4 +881,54 @@ public class CDTDebugModelPresentation extends LabelProvider return ""; return "=" + value; } + + private String getCharacterValue( CValue value ) + { + String result = null; + String uv = value.getUnderlyingValueString(); + int index = uv.indexOf( '\\' ); + try + { + if ( index == -1 && value.getValueString() != null ) + return "=" + value.getValueString(); + char ch = '.'; + if ( uv.length() > index + 1 ) + { + switch( uv.charAt( index + 1 ) ) + { + case 'b': + ch = '\b'; + break; + case 'f': + ch = '\f'; + break; + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'r': + ch = '\r'; + break; + case '\'': + ch = '\''; + break; + case '\"': + ch = '\"'; + break; + case '\\': + ch = '\\'; + break; + default: + return "=" + new String( new char[] { ch } ); + } + result = "='" + new String( new char[] { ch } ) + '\''; + } + } + catch( DebugException e ) + { + } + return result; + } }