diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index eba1ae589ea..52653cced13 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2002-11-01 Mikhail Khodjaiants + Implementing decimal format support of the Memory view. + * MemoryPresentation.java + 2002-10-31 Mikhail Khodjaiants Removed the 'Modified Value Color' field from the 'Debug/Memory Views' preference page. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java index 12df2c75ee2..6104f3f570a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java @@ -151,7 +151,7 @@ public class MemoryPresentation String[] items = row.getData(); for ( int i = 0; i < items.length; ++i ) { - result.append( items[i] ); + result.append( getDataItemPresentation( items[i] ) ); result.append( getInterval( INTERVAL_BETWEEN_DATA_ITEMS ) ); } if ( displayASCII() ) @@ -238,7 +238,17 @@ public class MemoryPresentation private int getDataItemLength() { if ( getMemoryBlock() != null ) - return getMemoryBlock().getWordSize() * 2; + { + switch( getDataFormat() ) + { + case IFormattedMemoryBlock.MEMORY_FORMAT_HEX: + return getMemoryBlock().getWordSize() * 2; + case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL: + return getDecimalDataItemLength( getMemoryBlock().getWordSize(), true ); + case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL: + return getDecimalDataItemLength( getMemoryBlock().getWordSize(), false ); + } + } return 0; } @@ -302,7 +312,7 @@ public class MemoryPresentation { if ( getMemoryBlock() != null ) return getMemoryBlock().getFormat(); - return -1; + return IFormattedMemoryBlock.MEMORY_FORMAT_HEX; } private Long[] getChangedAddresses() @@ -496,4 +506,54 @@ public class MemoryPresentation } return false; } + + private String getDataItemPresentation( String item ) + { + switch( getDataFormat() ) + { + case IFormattedMemoryBlock.MEMORY_FORMAT_HEX: + return item; + case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL: + return convertToDecimal( getWordSize(), item, true ); + case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL: + return convertToDecimal( getWordSize(), item, false ); + } + return ""; + } + + private int getDecimalDataItemLength( int wordSize, boolean signed ) + { + switch( wordSize ) + { + case IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD: + return ( signed ) ? 6 : 5; + case IFormattedMemoryBlock.MEMORY_SIZE_WORD: + return ( signed ) ? 11 : 10; + } + return 0; + } + + private int getWordSize() + { + if ( getMemoryBlock() != null ) + { + return getMemoryBlock().getWordSize(); + } + return 0; + } + + private String convertToDecimal( int wordSize, String item, boolean signed ) + { + String result = ""; + switch( wordSize ) + { + case IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD: + result = Long.toString( CDebugUtils.toShort( item.toCharArray(), signed ) ); + break; + case IFormattedMemoryBlock.MEMORY_SIZE_WORD: + result = Long.toString( CDebugUtils.toInt( item.toCharArray(), signed ) ); + break; + } + return CDebugUtils.prependString( result, getDataItemLength(), ' ' ); + } }