From 0375bb50a144391b0fc6eb9c6290d1db5b3109be Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Mon, 30 Jun 2003 20:05:43 +0000 Subject: [PATCH] Fix for PR 39100: CDT/Debug core is asking value 16 times. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 4 ++ .../cdt/debug/internal/core/model/CValue.java | 49 +++++++++++-------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 16259418f8c..c11f0244c70 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,7 @@ +2003-06-30 Mikhail Khodjaiants + Fix for PR 39100: CDT/Debug core is asking value 16 times. + * CValue.java + 2003-06-30 Mikhail Khodjaiants Fix for PR 39087: Cache the MI answer once we know if the variable is writable. * CVariable.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 b424f6258f7..fbd43146bed 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 @@ -305,12 +305,11 @@ public class CValue extends CDebugElement implements ICValue private String getCharValueString( ICDICharValue value ) throws CDIException { - byte byteValue = (byte)value.byteValue(); - short shortValue = value.shortValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: { + byte byteValue = (byte)value.byteValue(); return ( ( Character.isISOControl( (char)byteValue ) && byteValue != '\b' && byteValue != '\t' && @@ -320,12 +319,13 @@ public class CValue extends CDebugElement implements ICValue } case ICDIFormat.DECIMAL: { - return ( isUnsigned() ) ? Integer.toString( shortValue ) : Integer.toString( byteValue ); + return ( isUnsigned() ) ? Integer.toString( value.shortValue() ) : + Integer.toString( (byte)value.byteValue() ); } case ICDIFormat.HEXADECIMAL: { StringBuffer sb = new StringBuffer( "0x" ); - String stringValue = Integer.toHexString( ( isUnsigned() ) ? shortValue : byteValue ); + String stringValue = ( isUnsigned() ) ? Integer.toHexString( value.shortValue() ) : Integer.toHexString( (byte)value.byteValue() ); sb.append( ( stringValue.length() > 2 ) ? stringValue.substring( stringValue.length() - 2 ) : stringValue ); return sb.toString(); } @@ -335,17 +335,15 @@ public class CValue extends CDebugElement implements ICValue private String getShortValueString( ICDIShortValue value ) throws CDIException { - short shortValue = value.shortValue(); - int intValue = value.intValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: case ICDIFormat.DECIMAL: - return ( isUnsigned() ) ? Integer.toString( intValue ) : Short.toString( shortValue ); + return ( isUnsigned() ) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() ); case ICDIFormat.HEXADECIMAL: { StringBuffer sb = new StringBuffer( "0x" ); - String stringValue = Integer.toHexString( ( isUnsigned() ) ? intValue : shortValue ); + String stringValue = Integer.toHexString( ( isUnsigned() ) ? value.intValue() : value.shortValue() ); sb.append( ( stringValue.length() > 4 ) ? stringValue.substring( stringValue.length() - 4 ) : stringValue ); return sb.toString(); } @@ -355,17 +353,15 @@ public class CValue extends CDebugElement implements ICValue private String getIntValueString( ICDIIntValue value ) throws CDIException { - int intValue = value.intValue(); - long longValue = value.longValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: case ICDIFormat.DECIMAL: - return ( isUnsigned() ) ? Long.toString( longValue ) : Integer.toString( intValue ); + return ( isUnsigned() ) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() ); case ICDIFormat.HEXADECIMAL: { StringBuffer sb = new StringBuffer( "0x" ); - String stringValue = ( isUnsigned() ) ? Long.toHexString( longValue ) : Integer.toHexString( intValue ); + String stringValue = ( isUnsigned() ) ? Long.toHexString( value.longValue() ) : Integer.toHexString( value.intValue() ); sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue ); return sb.toString(); } @@ -375,17 +371,15 @@ public class CValue extends CDebugElement implements ICValue private String getLongValueString( ICDILongValue value ) throws CDIException { - int intValue = value.intValue(); - long longValue = value.longValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: case ICDIFormat.DECIMAL: - return ( isUnsigned() ) ? Long.toString( longValue ) : Integer.toString( intValue ); + return ( isUnsigned() ) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() ); case ICDIFormat.HEXADECIMAL: { StringBuffer sb = new StringBuffer( "0x" ); - String stringValue = Long.toHexString( ( isUnsigned() ) ? longValue : intValue ); + String stringValue = Long.toHexString( ( isUnsigned() ) ? value.longValue() : value.intValue() ); sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue ); return sb.toString(); } @@ -395,17 +389,30 @@ public class CValue extends CDebugElement implements ICValue private String getLongLongValueString( ICDILongLongValue value ) throws CDIException { - BigInteger bigValue = new BigInteger( value.getValueString() ); - long longValue = value.longValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: case ICDIFormat.DECIMAL: - return ( isUnsigned() ) ? bigValue.toString() : Long.toString( longValue ); + { + if ( isUnsigned() ) + { + BigInteger bigValue = new BigInteger( value.getValueString() ); + return bigValue.toString(); + } + else + return Long.toString( value.longValue() ); + } case ICDIFormat.HEXADECIMAL: { - StringBuffer sb = new StringBuffer( "0x" ); - sb.append( ( isUnsigned() ) ? bigValue.toString( 16 ) : Long.toHexString( longValue ) ); + StringBuffer sb = new StringBuffer( "0x" ); + + if ( isUnsigned() ) + { + BigInteger bigValue = new BigInteger( value.getValueString() ); + sb.append( bigValue.toString( 16 ) ); + } + else + sb.append( Long.toHexString( value.longValue() ) ); return sb.toString(); } }