Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorJohn Cortell2007-02-09 14:24:05 +0000
committerJohn Cortell2007-02-09 14:24:05 +0000
commitdf61873f6dc834d10baf04e29cc7016823be8ae0 (patch)
tree6de4e92280cfe6e747b64e9d5cc40927e75ea6f8 /debug
parent88be86e73054ceedec372c00f27c6809d2967cc5 (diff)
downloadorg.eclipse.cdt-df61873f6dc834d10baf04e29cc7016823be8ae0.tar.gz
org.eclipse.cdt-df61873f6dc834d10baf04e29cc7016823be8ae0.tar.xz
org.eclipse.cdt-df61873f6dc834d10baf04e29cc7016823be8ae0.zip
Correct improper handling and general confusion of the addressable size concept in the memory APIs (173420)
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java10
-rw-r--r--debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java9
-rw-r--r--debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement2.java3
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java44
4 files changed, 46 insertions, 20 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
index 33c66a6c999..c46980965f3 100644
--- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
@@ -49,7 +49,15 @@ public interface ICDIMemoryBlock extends ICDIObject {
long getLength();
/**
- * @return The size of each memory word in bytes.
+ * This method is a misnomer. It should be getAddressableSize. This is how
+ * CDT finds out from the CDI client the addressable size of the
+ * memory--i.e., how many bytes per address. Some embedded systems have
+ * memory with addressable sizes >1. Such backends should make sure to
+ * ignore the now deprecated wordSize parameter of
+ * ICDIMemoryBlockManagement.createMemory block() and not regurgitate that
+ * value in the implementation of this method.
+ *
+ * @return The addressable size of the memory
*/
int getWordSize();
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java
index 0be1511d5c4..22d679df4f1 100644
--- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement.java
@@ -25,8 +25,13 @@ public interface ICDIMemoryBlockManagement {
/**
* Returns a memory block specified by given identifier.
* @param address
- * @param units - number of units
- * @param wordSize - The size of each memory word in bytes
+ * @param units - number of bytes
+ * @param wordSize - this parameter has been deprecated in 4.0
+ * and will always be passed as the value 1. If the memory
+ * has an addressable size (number of bytes per address)
+ * greather than 1, the CDI client should take care not to
+ * return the value of wordSize we pass in here, but rather
+ * return the actual addressable size for that memory.
* @return a memory block with the specified identifier
* @throws CDIException on failure. Reasons include:
*/
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement2.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement2.java
index 9689fbb65e6..fbda1058bc7 100644
--- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement2.java
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlockManagement2.java
@@ -28,10 +28,9 @@ public interface ICDIMemoryBlockManagement2 extends ICDIMemoryBlockManagement {
* @param address
* @param memorySpaceID - value is meaningful only to the backend
* @param units - number of units
- * @param wordSize - The size of each memory word in bytes
* @return a memory block with the specified identifier
* @throws CDIException on failure. Reasons include:
*/
- ICDIMemoryBlock createMemoryBlock(BigInteger address, String memorySpaceID, int units, int wordSize)
+ ICDIMemoryBlock createMemoryBlock(BigInteger address, String memorySpaceID, int units)
throws CDIException;
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java
index 9620684926b..834be102123 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CMemoryBlockExtension.java
@@ -67,14 +67,15 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
private HashSet fChanges = new HashSet();
- private int fWordSize;
-
/**
* Constructor for CMemoryBlockExtension.
*/
public CMemoryBlockExtension( CDebugTarget target, String expression, BigInteger baseAddress ) {
- this( target, expression, baseAddress, 1 );
+ super( target );
+
+ fExpression = expression;
+ fBaseAddress = baseAddress;
}
/**
@@ -84,7 +85,6 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
super( target );
fExpression = expression;
fBaseAddress = baseAddress;
- fWordSize = wordSize;
}
/**
@@ -95,7 +95,6 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
super( target );
fBaseAddress = baseAddress;
fMemorySpaceID = memorySpaceID;
- fWordSize = 1;
if (target.getCDITarget() instanceof ICDIMemorySpaceManagement)
fExpression = ((ICDIMemorySpaceManagement)target.getCDITarget()).addressToString(baseAddress, memorySpaceID);
@@ -130,8 +129,17 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressableSize()
*/
public int getAddressableSize() throws DebugException {
- ICDIMemoryBlock block = getCDIBlock();
- return ( block != null ) ? block.getWordSize() : fWordSize;
+ if (getCDIBlock() == null) {
+ try {
+ // create a CDI block of an arbitrary size so we can call into
+ // the backed to determine the memory's addressable size
+ setCDIBlock( createCDIBlock( fBaseAddress, 100 ));
+ }
+ catch( CDIException e ) {
+ targetRequestFailed( e.getMessage(), null );
+ }
+ }
+ return getCDIBlock().getWordSize();
}
/* (non-Javadoc)
@@ -162,19 +170,19 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
ICDIMemoryBlock cdiBlock = getCDIBlock();
if ( cdiBlock == null ||
cdiBlock.getStartAddress().compareTo( address ) > 0 ||
- cdiBlock.getStartAddress().add( BigInteger.valueOf( cdiBlock.getLength() ) ).compareTo( address.add( BigInteger.valueOf( length ) ) ) < 0 ) {
+ cdiBlock.getStartAddress().add( BigInteger.valueOf( cdiBlock.getLength()/cdiBlock.getWordSize() ) ).compareTo( address.add( BigInteger.valueOf( length ) ) ) < 0 ) {
synchronized( this ) {
byte[] bytes = null;
try {
cdiBlock = getCDIBlock();
if ( cdiBlock == null ||
cdiBlock.getStartAddress().compareTo( address ) > 0 ||
- cdiBlock.getStartAddress().add( BigInteger.valueOf( cdiBlock.getLength() ) ).compareTo( address.add( BigInteger.valueOf( length ) ) ) < 0 ) {
+ cdiBlock.getStartAddress().add( BigInteger.valueOf( cdiBlock.getLength()/cdiBlock.getWordSize() ) ).compareTo( address.add( BigInteger.valueOf( length ) ) ) < 0 ) {
if ( cdiBlock != null ) {
disposeCDIBlock();
fBytes = null;
}
- setCDIBlock( createCDIBlock( address, length, fWordSize ) );
+ setCDIBlock( cdiBlock = createCDIBlock( address, length ) );
}
bytes = getCDIBlock().getBytes();
}
@@ -190,11 +198,13 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
MemoryByte[] result = new MemoryByte[0];
if ( fBytes != null ) {
int offset = address.subtract( getRealBlockAddress() ).intValue();
+ int offsetInBytes = offset * cdiBlock.getWordSize();
+ long lengthInBytes = length * cdiBlock.getWordSize();
if ( offset >= 0 ) {
- int size = ( fBytes.length - offset >= length ) ? (int)length : fBytes.length - offset;
+ int size = ( fBytes.length - offsetInBytes >= lengthInBytes ) ? (int)lengthInBytes : fBytes.length - offsetInBytes;
if ( size > 0 ) {
result = new MemoryByte[size];
- System.arraycopy( fBytes, offset, result, 0, size );
+ System.arraycopy( fBytes, offsetInBytes, result, 0, size );
}
}
}
@@ -291,14 +301,18 @@ public class CMemoryBlockExtension extends CDebugElement implements IMemoryBlock
}
}
- private ICDIMemoryBlock createCDIBlock( BigInteger address, long length, int wordSize ) throws CDIException {
+ private ICDIMemoryBlock createCDIBlock( BigInteger address, long length) throws CDIException {
ICDIMemoryBlock block = null;
CDebugTarget target = (CDebugTarget)getDebugTarget();
ICDITarget cdiTarget = target.getCDITarget();
if ((fMemorySpaceID != null) && (cdiTarget instanceof ICDIMemoryBlockManagement2)) {
- block = ((ICDIMemoryBlockManagement2)cdiTarget).createMemoryBlock(address, fMemorySpaceID, (int)length, wordSize);
+ block = ((ICDIMemoryBlockManagement2)cdiTarget).createMemoryBlock(address, fMemorySpaceID, (int)length);
} else {
- block = cdiTarget.createMemoryBlock( address.toString(), (int)length, wordSize );
+ // Note that CDI clients should ignore the word size
+ // parameter. It has been deprecated in 4.0. We continue to
+ // pass in 1 as has always been the case to maintain backwards
+ // compatibility.
+ block = cdiTarget.createMemoryBlock( address.toString(), (int)length, 1);
}
block.setFrozen( false );
getCDISession().getEventManager().addEventListener( this );

Back to the top