1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 73168: Use memory view provided by Eclipse platform in CDT.

This commit is contained in:
Mikhail Khodjaiants 2005-01-10 18:53:41 +00:00
parent 74ebb4ef75
commit 46c23f102c
6 changed files with 77 additions and 21 deletions

View file

@ -1,3 +1,10 @@
2005-01-10 Mikhail Khodjaiants
Bug 73168: Use memory view provided by Eclipse platform in CDT.
* ICType.java
* CType.java
* CMemoryBlockExtension.java
* CMemoryBlockExtensionRetrieval.java
2005-01-04 Mikhail Khodjaiants
Fix for bug 82184: arrayboundsexception on display of array variable.
* CIndexedValue.java

View file

@ -79,4 +79,11 @@ public interface ICType {
* @return whether this is an unsigned type
*/
boolean isUnsigned();
/**
* Returns whether this is an integral type.
*
* @return whether this is an integral type
*/
boolean isIntegralType();
}

View file

@ -13,7 +13,12 @@ package org.eclipse.cdt.debug.internal.core;
import java.math.BigInteger;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CMemoryBlockExtension;
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
import org.eclipse.cdt.debug.internal.core.model.CThread;
@ -26,6 +31,7 @@ import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IValue;
/**
* Implements the memory retrieval features based on the CDI model.
@ -43,28 +49,44 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
*/
public IMemoryBlockExtension getExtendedMemoryBlock( String expression, IDebugElement selected ) throws DebugException {
String address = null;
if ( selected instanceof CStackFrame ) {
address = ((CStackFrame)selected).evaluateExpressionToString( expression );
}
else if ( selected instanceof CThread ) {
IStackFrame frame = ((CThread)selected).getTopStackFrame();
if ( frame instanceof CStackFrame ) {
address = ((CStackFrame)selected).evaluateExpressionToString( expression );
}
}
CExpression exp = null;
String msg = null;
try {
CStackFrame frame = getStackFrame( selected );
if ( frame != null ) {
// We need to provide a better way for retrieving the address of expression
ICDIExpression cdiExpression = frame.getCDITarget().createExpression( expression );
exp = new CExpression( frame, cdiExpression, null );
IValue value = exp.getValue();
if ( value instanceof ICValue ) {
ICType type = ((ICValue)value).getType();
if ( type != null && (type.isPointer() || type.isIntegralType()) ) {
address = value.getValueString();
IDebugTarget target = selected.getDebugTarget();
if ( target instanceof CDebugTarget ) {
if ( address != null ) {
try {
// ???
BigInteger a = ( address.startsWith( "0x" ) ) ? new BigInteger( address.substring( 2 ), 16 ) : new BigInteger( address ); //$NON-NLS-1$
return new CMemoryBlockExtension( (CDebugTarget)target, expression, a );
}
}
}
else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.1" ), new String[] { expression } ); //$NON-NLS-1$
}
}
else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.2" ), new String[] { expression } ); //$NON-NLS-1$
}
}
}
catch( CDIException e ) {
msg = e.getMessage();
}
catch( NumberFormatException e ) {
throw new DebugException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.0" ), new String[] { expression, address } ), null ) ); //$NON-NLS-1$
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.0" ), new String[] { expression, address } ); //$NON-NLS-1$
}
}
}
return null;
throw new DebugException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, msg, null ) );
}
/* (non-Javadoc)
@ -90,4 +112,16 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
// TODO Auto-generated method stub
return null;
}
private CStackFrame getStackFrame( IDebugElement selected ) throws DebugException {
if ( selected instanceof CStackFrame ) {
return (CStackFrame)selected;
}
if ( selected instanceof CThread ) {
IStackFrame frame = ((CThread)selected).getTopStackFrame();
if ( frame instanceof CStackFrame )
return (CStackFrame)frame;
}
return null;
}
}

View file

@ -14,6 +14,8 @@ CBreakpointManager.2=Set breakpoint failed. Reason: {0}.
CBreakpointManager.4=Change breakpoint properties failed. Reason: {0}.
CGlobalVariableManager.0=Invalid global variables data.
CMemoryBlockExtensionRetrieval.0=Expression ''{0}'' evaluated to invalid address value: {1}.
CMemoryBlockExtensionRetrieval.1=Invalid expression type: ''{0}''
CMemoryBlockExtensionRetrieval.2=Invalid expression: ''{0}''
DebugConfiguration.0=This debugger no longer supports this operation
CDebugAdapter.0=This debugger does not support debugging external files
CDebugAdapter.1=Debugger Process

View file

@ -136,7 +136,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
}
fBytes = new MemoryByte[bytes.length];
for ( int i = 0; i < bytes.length; ++i ) {
byte flags = MemoryByte.VALID;
byte flags = MemoryByte.VALID | MemoryByte.KNOWN;
if ( hasChanged( getRealBlockAddress().add( BigInteger.valueOf( i ) ) ) )
flags |= MemoryByte.CHANGED;
fBytes[i] = new MemoryByte( bytes[i], flags );

View file

@ -114,8 +114,14 @@ public class CType implements ICType {
* @see org.eclipse.cdt.debug.core.model.ICType#isUnsigned()
*/
public boolean isUnsigned() {
ICDIType cdiType = getCDIType();
return ( cdiType instanceof ICDIIntegralType ) ? ((ICDIIntegralType)cdiType).isUnsigned() : false;
return ( isIntegralType() ) ? ((ICDIIntegralType)getCDIType()).isUnsigned() : false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICType#isIntegralType()
*/
public boolean isIntegralType() {
return ( getCDIType() instanceof ICDIIntegralType );
}
protected ICDIType getCDIType() {