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
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java

View file

@ -29,30 +29,39 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
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.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IValue;
/**
* 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)
* @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;
CExpression exp = null;
String msg = null;
try {
CStackFrame frame = getStackFrame( selected );
if (selected instanceof IDebugElement) {
IDebugElement debugElement = (IDebugElement)selected;
CStackFrame frame = getStackFrame( debugElement );
if ( frame != null ) {
// We need to provide a better way for retrieving the address of expression
ICDIExpression cdiExpression = frame.getCDITarget().createExpression( expression );
@ -62,7 +71,7 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
ICType type = ((ICValue)value).getType();
if ( type != null && (type.isPointer() || type.isIntegralType()) ) {
address = value.getValueString();
IDebugTarget target = selected.getDebugTarget();
IDebugTarget target = debugElement.getDebugTarget();
if ( target instanceof CDebugTarget ) {
if ( address != null ) {
// ???
@ -72,11 +81,12 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
}
}
else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.1" ), new String[] { expression } ); //$NON-NLS-1$
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.1" ), new String[] { expression } ); //$NON-NLS-1$
}
}
else {
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockExtensionRetrieval.2" ), new String[] { expression } ); //$NON-NLS-1$
msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.2" ), new String[] { expression } ); //$NON-NLS-1$
}
}
}
}
@ -84,7 +94,7 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
msg = e.getMessage();
}
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 ) );
}
@ -93,7 +103,6 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
* @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
*/
public boolean supportsStorageRetrieval() {
// TODO Auto-generated method stub
return true;
}
@ -101,8 +110,10 @@ public class CMemoryBlockExtensionRetrieval implements IMemoryBlockExtensionRetr
* @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
*/
public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException {
// TODO Auto-generated method stub
return null;
String expression = Long.toHexString(startAddress);
BigInteger address = new BigInteger(expression, 16);
expression += "0x"; //$NON-NLS-1$
return new CMemoryBlockExtension( getDebugTarget(), expression, address );
}
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.internal.core.CBreakpointManager;
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.CSignalManager;
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.IExpression;
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.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IRegisterGroup;
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.
*/
private CMemoryBlockExtensionRetrieval fMemoryBlockRetrieval;
private CMemoryBlockRetrievalExtension fMemoryBlockRetrieval;
/**
* Constructor for CDebugTarget.
@ -232,7 +232,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setRegisterManager( new CRegisterManager( this ) );
setBreakpointManager( new CBreakpointManager( this ) );
setGlobalVariableManager( new CGlobalVariableManager( this ) );
setMemoryBlockRetrieval( new CMemoryBlockExtensionRetrieval() );
setMemoryBlockRetrieval( new CMemoryBlockRetrievalExtension( this ) );
initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
@ -808,7 +808,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getGlobalVariableManager();
if ( adapter.equals( ICDISession.class ) )
return getCDISession();
if ( adapter.equals( IMemoryBlockExtensionRetrieval.class ) )
if ( adapter.equals( IMemoryBlockRetrievalExtension.class ) )
return getMemoryBlockRetrieval();
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
return getMemoryBlockRetrieval();
@ -1725,11 +1725,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return fAddressFactory;
}
private CMemoryBlockExtensionRetrieval getMemoryBlockRetrieval() {
private CMemoryBlockRetrievalExtension getMemoryBlockRetrieval() {
return fMemoryBlockRetrieval;
}
private void setMemoryBlockRetrieval( CMemoryBlockExtensionRetrieval memoryBlockRetrieval ) {
private void setMemoryBlockRetrieval( CMemoryBlockRetrievalExtension memoryBlockRetrieval ) {
fMemoryBlockRetrieval = memoryBlockRetrieval;
}

View file

@ -80,7 +80,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getExpression()
*/
public String getExpression() throws DebugException {
public String getExpression() {
return fExpression;
}
@ -98,6 +98,14 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
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)
* @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 {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromOffset(long, long)
*/
public MemoryByte[] getBytesFromOffset( long offset, long length ) throws DebugException {
public MemoryByte[] getBytesFromOffset(BigInteger unitOffset, long addressableUnits) throws DebugException {
// TODO Auto-generated method stub
return null;
}
@ -148,9 +153,17 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
fBytes = new MemoryByte[bytes.length];
for ( int i = 0; i < bytes.length; ++i ) {
byte cdiFlags = getCDIBlock().getFlags( i );
byte flags = MemoryByte.KNOWN;
flags |= ( (cdiFlags & ICDIMemoryBlock.VALID) != 0 ) ? MemoryByte.VALID : MemoryByte.READONLY; // ????
flags |= ( (cdiFlags & ICDIMemoryBlock.READ_ONLY) != 0 ) ? MemoryByte.READONLY : 0;
byte flags = 0;
if ( (cdiFlags & ICDIMemoryBlock.READ_ONLY) != 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 ) ) ) )
flags |= MemoryByte.CHANGED;
fBytes[i] = new MemoryByte( bytes[i], flags );
@ -171,10 +184,7 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
return result;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#isBigEndian()
*/
public boolean isBigEndian() {
private boolean isBigEndian() {
IExecFileInfo info = (IExecFileInfo)getDebugTarget().getAdapter( IExecFileInfo.class );
if ( info != null ) {
return info.isLittleEndian();
@ -243,11 +253,15 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
* @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[])
*/
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();
if ( block != null ) {
BigInteger base = getBigBaseAddress();
BigInteger real = getRealBlockAddress();
long realOffset = base.add( BigInteger.valueOf( offset ) ).subtract( real ).longValue();
long realOffset = base.add( offset ).subtract( real ).longValue();
try {
block.setValue( realOffset, bytes );
}
@ -371,12 +385,9 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getConnected()
*/
public Object[] getConnected() {
public Object[] getConnections() {
// TODO Auto-generated method stub
return null;
return new Object[0];
}
/* (non-Javadoc)
@ -397,14 +408,6 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
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)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@ -413,4 +416,22 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
return getMemoryBlockRetrieval();
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;
}
}