mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
Added support of the formatting actions of the Memory view.
This commit is contained in:
parent
6be5cda658
commit
74a706751c
5 changed files with 80 additions and 48 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-11-03 Mikhail Khodjaiants
|
||||
Added support of the formatting actions of the Memory view.
|
||||
* IFormattedMemoryBlock.java
|
||||
* CFormattedMemoryBlock.java
|
||||
* CDebugTarget.java
|
||||
* CDebugUtils.java
|
||||
|
||||
2002-11-01 Mikhail Khodjaiants
|
||||
Added conversion utilities to support decimal format in the Memory View.
|
||||
* CDebugUtils.java
|
||||
|
|
|
@ -130,4 +130,8 @@ public interface IFormattedMemoryBlock extends IMemoryBlock
|
|||
void saveChanges() throws DebugException;
|
||||
|
||||
void refresh() throws DebugException;
|
||||
|
||||
boolean canChangeFormat( int format );
|
||||
|
||||
boolean isLittleEndian();
|
||||
}
|
||||
|
|
|
@ -135,42 +135,58 @@ public class CDebugUtils
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static short toShort( char[] bytes, boolean le )
|
||||
public static byte toByte( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 2 )
|
||||
return 0;
|
||||
return Short.parseShort( bytesToString( bytes, le, true ), 16 );
|
||||
return (byte)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
||||
}
|
||||
|
||||
public static short toUnsignedByte( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 2 )
|
||||
return 0;
|
||||
return (short)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
||||
}
|
||||
|
||||
public static short toShort( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 4 )
|
||||
return 0;
|
||||
return (short)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
||||
}
|
||||
|
||||
public static int toUnsignedShort( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 2 )
|
||||
if ( bytes.length != 4 )
|
||||
return 0;
|
||||
return Integer.parseInt( bytesToString( bytes, le, false ), 16 );
|
||||
return (int)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
||||
}
|
||||
|
||||
public static int toInt( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 4 )
|
||||
if ( bytes.length != 8 )
|
||||
return 0;
|
||||
return Integer.parseInt( bytesToString( bytes, le, true ), 16 );
|
||||
return (int)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
||||
}
|
||||
|
||||
public static long toUnsignedInt( char[] bytes, boolean le )
|
||||
{
|
||||
if ( bytes.length != 4 )
|
||||
if ( bytes.length != 8 )
|
||||
return 0;
|
||||
return Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
||||
return (long)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
||||
}
|
||||
|
||||
public static long toLong( char[] bytes, boolean le )
|
||||
public static long toLongLong( char[] bytes, boolean le )
|
||||
{
|
||||
return toInt( bytes, le );
|
||||
if ( bytes.length != 16 )
|
||||
return 0;
|
||||
return (long)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
||||
}
|
||||
|
||||
public static long toUnsignedLong( char[] bytes, boolean le )
|
||||
public static long toUnsignedLongLong( char[] bytes, boolean le )
|
||||
{
|
||||
return toUnsignedInt( bytes, le );
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static String bytesToString( char[] bytes, boolean le, boolean signed )
|
||||
|
@ -188,41 +204,7 @@ public class CDebugUtils
|
|||
{
|
||||
System.arraycopy( bytes, 0, copy, 0, copy.length );
|
||||
}
|
||||
StringBuffer sb = new StringBuffer( copy.length );
|
||||
if ( signed )
|
||||
{
|
||||
switch( copy[0] )
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
break;
|
||||
case '8':
|
||||
case '9':
|
||||
case 'a':
|
||||
case 'A':
|
||||
case 'b':
|
||||
case 'B':
|
||||
case 'c':
|
||||
case 'C':
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'F':
|
||||
sb.append( '-' );
|
||||
copy[0] -= '8';
|
||||
break;
|
||||
}
|
||||
}
|
||||
sb.append( copy );
|
||||
return sb.toString();
|
||||
return new String( copy );
|
||||
}
|
||||
|
||||
public static String prependString( String text, int length, char ch )
|
||||
|
|
|
@ -845,6 +845,8 @@ public class CDebugTarget extends CDebugElement
|
|||
return getMemoryManager();
|
||||
if ( adapter.equals( IDebuggerProcessSupport.class ) )
|
||||
return this;
|
||||
if ( adapter.equals( IExecFileInfo.class ) )
|
||||
return this;
|
||||
return super.getAdapter( adapter );
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.IExecFileInfo;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
|
@ -264,7 +265,9 @@ public class CFormattedMemoryBlock extends CDebugElement
|
|||
*/
|
||||
public boolean displayASCII()
|
||||
{
|
||||
return ( getWordSize() == IFormattedMemoryBlock.MEMORY_SIZE_BYTE && fDisplayAscii );
|
||||
return ( getWordSize() == IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&
|
||||
/*getFormat() == IFormattedMemoryBlock.MEMORY_FORMAT_HEX &&*/
|
||||
fDisplayAscii );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -351,6 +354,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
|||
int numberOfColumns ) throws DebugException
|
||||
{
|
||||
resetRows();
|
||||
fFormat = format;
|
||||
fWordSize = wordSize;
|
||||
fNumberOfRows = numberOfRows;
|
||||
fNumberOfColumns = numberOfColumns;
|
||||
|
@ -366,6 +370,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
|||
char paddingChar ) throws DebugException
|
||||
{
|
||||
resetRows();
|
||||
fFormat = format;
|
||||
fWordSize = wordSize;
|
||||
fNumberOfRows = numberOfRows;
|
||||
fNumberOfColumns = numberOfColumns;
|
||||
|
@ -693,4 +698,36 @@ public class CFormattedMemoryBlock extends CDebugElement
|
|||
{
|
||||
return new DirtyBytes( size );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#canChangeFormat(int)
|
||||
*/
|
||||
public boolean canChangeFormat( int format )
|
||||
{
|
||||
switch( format )
|
||||
{
|
||||
case IFormattedMemoryBlock.MEMORY_FORMAT_HEX:
|
||||
return true;
|
||||
case IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL:
|
||||
return ( /*getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&*/
|
||||
getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD );
|
||||
case IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL:
|
||||
return ( /*getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_BYTE &&*/
|
||||
getWordSize() != IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#isLittleEndian()
|
||||
*/
|
||||
public boolean isLittleEndian()
|
||||
{
|
||||
IExecFileInfo info = (IExecFileInfo)getDebugTarget().getAdapter( IExecFileInfo.class );
|
||||
if ( info != null )
|
||||
{
|
||||
return info.isLittleEndian();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue