1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

2005-04-04 Alain Magloire

Move to Eclipse-31M6
	- src/org/eclipse/cdt/debug/internal/core/CMemoryBlockExtensionRetrieval.java
	+ src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java
	* src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
	* src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java
This commit is contained in:
Alain Magloire 2005-04-05 02:53:31 +00:00
parent 8ba02ba51a
commit eaa861dfd8
4 changed files with 101 additions and 62 deletions

View file

@ -1,3 +1,10 @@
2005-04-04 Alain Magloire
Move to Eclipse-31M6
- src/org/eclipse/cdt/debug/internal/core/CMemoryBlockExtensionRetrieval.java
+ src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java
* src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
* src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java
2005-03-24 Alain Magloire 2005-03-24 Alain Magloire
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java * cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java * cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java

View file

@ -29,62 +29,72 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval; import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IValue;
/** /**
* Implements the memory retrieval features based on the CDI model. * Implements the memory retrieval features based on the CDI model.
*/ */
public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetrieval { public class CMemoryBlockRetrievalExtension implements IMemoryBlockRetrievalExtension {
CDebugTarget fDebugTarget;
/** /**
* Constructor for CMemoryBlockExtensionRetrieval. * Constructor for CMemoryBlockRetrievalExtension.
*/ */
public CMemoryBlockExtensionRetrieval() { public CMemoryBlockRetrievalExtension(CDebugTarget debugTarget) {
fDebugTarget = debugTarget;
} }
protected CDebugTarget getDebugTarget() {
return fDebugTarget;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval#getExtendedMemoryBlock(java.lang.String, org.eclipse.debug.core.model.IDebugElement) * @see org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval#getExtendedMemoryBlock(java.lang.String, org.eclipse.debug.core.model.IDebugElement)
*/ */
public IMemoryBlockExtension getExtendedMemoryBlock( String expression, IDebugElement selected ) throws DebugException { public IMemoryBlockExtension getExtendedMemoryBlock( String expression, Object selected ) throws DebugException {
String address = null; String address = null;
CExpression exp = null; CExpression exp = null;
String msg = null; String msg = null;
try { try {
CStackFrame frame = getStackFrame( selected ); if (selected instanceof IDebugElement) {
if ( frame != null ) { IDebugElement debugElement = (IDebugElement)selected;
// We need to provide a better way for retrieving the address of expression CStackFrame frame = getStackFrame( debugElement );
ICDIExpression cdiExpression = frame.getCDITarget().createExpression( expression ); if ( frame != null ) {
exp = new CExpression( frame, cdiExpression, null ); // We need to provide a better way for retrieving the address of expression
IValue value = exp.getValue(); ICDIExpression cdiExpression = frame.getCDITarget().createExpression( expression );
if ( value instanceof ICValue ) { exp = new CExpression( frame, cdiExpression, null );
ICType type = ((ICValue)value).getType(); IValue value = exp.getValue();
if ( type != null && (type.isPointer() || type.isIntegralType()) ) { if ( value instanceof ICValue ) {
address = value.getValueString(); ICType type = ((ICValue)value).getType();
IDebugTarget target = selected.getDebugTarget(); if ( type != null && (type.isPointer() || type.isIntegralType()) ) {
if ( target instanceof CDebugTarget ) { address = value.getValueString();
if ( address != null ) { IDebugTarget target = debugElement.getDebugTarget();
// ??? if ( target instanceof CDebugTarget ) {
BigInteger a = ( address.startsWith( "0x" ) ) ? new BigInteger( address.substring( 2 ), 16 ) : new BigInteger( address ); //$NON-NLS-1$ if ( address != null ) {
return new CMemoryBlockExtension( (CDebugTarget)target, expression, a ); // ???
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( "CMemoryBlockRetrievalExtension.1" ), new String[] { expression } ); //$NON-NLS-1$
}
} }
else { else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.1" ), new String[] { expression } ); //$NON-NLS-1$ msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.2" ), new String[] { expression } ); //$NON-NLS-1$
} }
} }
else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.2" ), new String[] { expression } ); //$NON-NLS-1$
}
} }
} }
catch( CDIException e ) { catch( CDIException e ) {
msg = e.getMessage(); msg = e.getMessage();
} }
catch( NumberFormatException e ) { catch( NumberFormatException e ) {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.0" ), new String[] { expression, address } ); //$NON-NLS-1$ msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.0" ), new String[] { expression, address } ); //$NON-NLS-1$
} }
throw new DebugException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, msg, null ) ); throw new DebugException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, msg, null ) );
} }
@ -93,7 +103,6 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
* @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval() * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
*/ */
public boolean supportsStorageRetrieval() { public boolean supportsStorageRetrieval() {
// TODO Auto-generated method stub
return true; return true;
} }
@ -101,8 +110,10 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
* @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long) * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
*/ */
public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException { public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException {
// TODO Auto-generated method stub String expression = Long.toHexString(startAddress);
return null; BigInteger address = new BigInteger(expression, 16);
expression += "0x"; //$NON-NLS-1$
return new CMemoryBlockExtension( getDebugTarget(), expression, address );
} }
private CStackFrame getStackFrame( IDebugElement selected ) throws DebugException { private CStackFrame getStackFrame( IDebugElement selected ) throws DebugException {

View file

@ -78,7 +78,7 @@ import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CBreakpointManager; import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager; import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager;
import org.eclipse.cdt.debug.internal.core.CMemoryBlockExtensionRetrieval; import org.eclipse.cdt.debug.internal.core.CMemoryBlockRetrievalExtension;
import org.eclipse.cdt.debug.internal.core.CRegisterManager; import org.eclipse.cdt.debug.internal.core.CRegisterManager;
import org.eclipse.cdt.debug.internal.core.CSignalManager; import org.eclipse.cdt.debug.internal.core.CSignalManager;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
@ -106,8 +106,8 @@ import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression; import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval;
import org.eclipse.debug.core.model.IMemoryBlockRetrieval; import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.ISourceLocator;
@ -208,7 +208,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
/** /**
* Support for the memory retrival on this target. * Support for the memory retrival on this target.
*/ */
private CMemoryBlockExtensionRetrieval fMemoryBlockRetrieval; private CMemoryBlockRetrievalExtension fMemoryBlockRetrieval;
/** /**
* Constructor for CDebugTarget. * Constructor for CDebugTarget.
@ -232,7 +232,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setRegisterManager( new CRegisterManager( this ) ); setRegisterManager( new CRegisterManager( this ) );
setBreakpointManager( new CBreakpointManager( this ) ); setBreakpointManager( new CBreakpointManager( this ) );
setGlobalVariableManager( new CGlobalVariableManager( this ) ); setGlobalVariableManager( new CGlobalVariableManager( this ) );
setMemoryBlockRetrieval( new CMemoryBlockExtensionRetrieval() ); setMemoryBlockRetrieval( new CMemoryBlockRetrievalExtension( this ) );
initialize(); initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this ); DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this ); DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
@ -808,7 +808,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getGlobalVariableManager(); return getGlobalVariableManager();
if ( adapter.equals( ICDISession.class ) ) if ( adapter.equals( ICDISession.class ) )
return getCDISession(); return getCDISession();
if ( adapter.equals( IMemoryBlockExtensionRetrieval.class ) ) if ( adapter.equals( IMemoryBlockRetrievalExtension.class ) )
return getMemoryBlockRetrieval(); return getMemoryBlockRetrieval();
if ( adapter.equals( IMemoryBlockRetrieval.class ) ) if ( adapter.equals( IMemoryBlockRetrieval.class ) )
return getMemoryBlockRetrieval(); return getMemoryBlockRetrieval();
@ -1725,11 +1725,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return fAddressFactory; return fAddressFactory;
} }
private CMemoryBlockExtensionRetrieval getMemoryBlockRetrieval() { private CMemoryBlockRetrievalExtension getMemoryBlockRetrieval() {
return fMemoryBlockRetrieval; return fMemoryBlockRetrieval;
} }
private void setMemoryBlockRetrieval( CMemoryBlockExtensionRetrieval memoryBlockRetrieval ) { private void setMemoryBlockRetrieval( CMemoryBlockRetrievalExtension memoryBlockRetrieval ) {
fMemoryBlockRetrieval = memoryBlockRetrieval; fMemoryBlockRetrieval = memoryBlockRetrieval;
} }

View file

@ -80,7 +80,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getExpression() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#getExpression()
*/ */
public String getExpression() throws DebugException { public String getExpression() {
return fExpression; return fExpression;
} }
@ -98,6 +98,14 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
return ((CDebugTarget)getDebugTarget()).getAddressFactory().createAddress( getBigBaseAddress() ).getSize(); return ((CDebugTarget)getDebugTarget()).getAddressFactory().createAddress( getBigBaseAddress() ).getSize();
} }
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressableSize()
*/
public int getAddressableSize() throws DebugException {
ICDIMemoryBlock block = getCDIBlock();
return ( block != null ) ? block.getWordSize() : fWordSize;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportBaseAddressModification() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportBaseAddressModification()
*/ */
@ -111,10 +119,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
public void setBaseAddress( BigInteger address ) throws DebugException { public void setBaseAddress( BigInteger address ) throws DebugException {
} }
/* (non-Javadoc) public MemoryByte[] getBytesFromOffset(BigInteger unitOffset, long addressableUnits) throws DebugException {
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromOffset(long, long)
*/
public MemoryByte[] getBytesFromOffset( long offset, long length ) throws DebugException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@ -148,9 +153,17 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
fBytes = new MemoryByte[bytes.length]; fBytes = new MemoryByte[bytes.length];
for ( int i = 0; i < bytes.length; ++i ) { for ( int i = 0; i < bytes.length; ++i ) {
byte cdiFlags = getCDIBlock().getFlags( i ); byte cdiFlags = getCDIBlock().getFlags( i );
byte flags = MemoryByte.KNOWN; byte flags = 0;
flags |= ( (cdiFlags & ICDIMemoryBlock.VALID) != 0 ) ? MemoryByte.VALID : MemoryByte.READONLY; // ???? if ( (cdiFlags & ICDIMemoryBlock.READ_ONLY) != 0 ) {
flags |= ( (cdiFlags & ICDIMemoryBlock.READ_ONLY) != 0 ) ? MemoryByte.READONLY : 0; flags |= MemoryByte.READABLE;
} else {
flags |= MemoryByte.READABLE | MemoryByte.WRITABLE;
}
if (isBigEndian()) {
flags |= MemoryByte.ENDIANESS_KNOWN | MemoryByte.BIG_ENDIAN;
}
// flags |= ( (cdiFlags & ICDIMemoryBlock.VALID) != 0 ) ? MemoryByte.VALID : MemoryByte.READONLY; // ????
// flags |= ( (cdiFlags & ICDIMemoryBlock.READ_ONLY) != 0 ) ? MemoryByte.READABLE : 0;
if ( hasChanged( getRealBlockAddress().add( BigInteger.valueOf( i ) ) ) ) if ( hasChanged( getRealBlockAddress().add( BigInteger.valueOf( i ) ) ) )
flags |= MemoryByte.CHANGED; flags |= MemoryByte.CHANGED;
fBytes[i] = new MemoryByte( bytes[i], flags ); fBytes[i] = new MemoryByte( bytes[i], flags );
@ -171,10 +184,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
return result; return result;
} }
/* (non-Javadoc) private boolean isBigEndian() {
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#isBigEndian()
*/
public boolean isBigEndian() {
IExecFileInfo info = (IExecFileInfo)getDebugTarget().getAdapter( IExecFileInfo.class ); IExecFileInfo info = (IExecFileInfo)getDebugTarget().getAdapter( IExecFileInfo.class );
if ( info != null ) { if ( info != null ) {
return info.isLittleEndian(); return info.isLittleEndian();
@ -243,11 +253,15 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
* @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[]) * @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[])
*/ */
public void setValue( long offset, byte[] bytes ) throws DebugException { public void setValue( long offset, byte[] bytes ) throws DebugException {
setValue(BigInteger.valueOf(offset), bytes);
}
public void setValue(BigInteger offset, byte[] bytes) throws DebugException {
ICDIMemoryBlock block = getCDIBlock(); ICDIMemoryBlock block = getCDIBlock();
if ( block != null ) { if ( block != null ) {
BigInteger base = getBigBaseAddress(); BigInteger base = getBigBaseAddress();
BigInteger real = getRealBlockAddress(); BigInteger real = getRealBlockAddress();
long realOffset = base.add( BigInteger.valueOf( offset ) ).subtract( real ).longValue(); long realOffset = base.add( offset ).subtract( real ).longValue();
try { try {
block.setValue( realOffset, bytes ); block.setValue( realOffset, bytes );
} }
@ -371,12 +385,9 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc) public Object[] getConnections() {
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getConnected()
*/
public Object[] getConnected() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return new Object[0];
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -397,14 +408,6 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
getCDISession().getEventManager().removeEventListener( this ); getCDISession().getEventManager().removeEventListener( this );
} }
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressibleSize()
*/
public int getAddressibleSize() {
ICDIMemoryBlock block = getCDIBlock();
return ( block != null ) ? block.getWordSize() : fWordSize;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
@ -413,4 +416,22 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
return getMemoryBlockRetrieval(); return getMemoryBlockRetrieval();
return super.getAdapter( adapter ); return super.getAdapter( adapter );
} }
public BigInteger getMemoryBlockStartAddress() throws DebugException {
return null; // return null to mean not bounded ... according to the spec
}
public BigInteger getMemoryBlockEndAddress() throws DebugException {
return null;// return null to maen not bounded ... according to the spec
}
public BigInteger getBigLength() throws DebugException {
ICDIMemoryBlock block = getCDIBlock();
if (block != null) {
BigInteger length = new BigInteger(Long.toHexString(block.getLength()), 16);
return length;
}
return BigInteger.ZERO;
}
} }