1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Implementing decimal format support of the Memory view.

This commit is contained in:
Mikhail Khodjaiants 2002-11-01 23:25:06 +00:00
parent f1fe1808af
commit 6be5cda658
2 changed files with 67 additions and 3 deletions

View file

@ -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.

View file

@ -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 )
{
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(), ' ' );
}
}