1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixes following Pawel's comments.

This commit is contained in:
Francois Chouinard 2007-10-17 20:10:55 +00:00
parent df21b47db1
commit 732160a2a5
3 changed files with 89 additions and 58 deletions

View file

@ -56,8 +56,10 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
private final DsfMemoryBlockRetrieval fRetrieval; private final DsfMemoryBlockRetrieval fRetrieval;
private final String fModelId; private final String fModelId;
private final String fExpression; private final String fExpression;
protected BigInteger fBaseAddress; private final BigInteger fBaseAddress;
protected int fLength;
private BigInteger fBlockAddress;
private int fLength;
private MemoryByte[] fBlock; private MemoryByte[] fBlock;
private ArrayList<Object> fConnections = new ArrayList<Object>(); private ArrayList<Object> fConnections = new ArrayList<Object>();
@ -76,14 +78,17 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
*/ */
DsfMemoryBlock(DsfMemoryBlockRetrieval retrieval, String modelId, String expression, BigInteger address, long length) { DsfMemoryBlock(DsfMemoryBlockRetrieval retrieval, String modelId, String expression, BigInteger address, long length) {
fLaunch = null; // TODO: fRetrieval.getLaunch(); fLaunch = retrieval.getLaunch();
fDebugTarget = null; // TODO: fRetrieval.getDebugTarget(); fDebugTarget = retrieval.getDebugTarget();
fRetrieval = retrieval; fRetrieval = retrieval;
fModelId = modelId; fModelId = modelId;
fExpression = expression; fExpression = expression;
fBaseAddress = address; fBaseAddress = address;
fLength = (int) length;
fBlock = null; // Current block information
fBlockAddress = address;
fLength = (int) length;
fBlock = null;
try { try {
fRetrieval.getExecutor().execute(new Runnable() { fRetrieval.getExecutor().execute(new Runnable() {
@ -169,8 +174,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification() * @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification()
*/ */
public boolean supportsValueModification() { public boolean supportsValueModification() {
// TODO: return fDebugTarget.supportsValueModification(this); return fRetrieval.supportsValueModification();
return true;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -226,21 +230,14 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressSize() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressSize()
*/ */
public int getAddressSize() throws DebugException { public int getAddressSize() throws DebugException {
// TODO: return fRetrieval.getAddressSize();
// try {
// return fDebugTarget.getAddressSize();
// } catch (CoreException e) {
// throw new DebugException(e.getStatus());
// }
return 4;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportBaseAddressModification() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportBaseAddressModification()
*/ */
public boolean supportBaseAddressModification() throws DebugException { public boolean supportBaseAddressModification() throws DebugException {
// TODO: return fDebugTarget.supportBaseAddressModification(this); return fRetrieval.supportBaseAddressModification();
return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -254,14 +251,14 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#setBaseAddress(java.math.BigInteger) * @see org.eclipse.debug.core.model.IMemoryBlockExtension#setBaseAddress(java.math.BigInteger)
*/ */
public void setBaseAddress(BigInteger address) throws DebugException { public void setBaseAddress(BigInteger address) throws DebugException {
fBaseAddress = address; fBlockAddress = address;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromOffset(java.math.BigInteger, long) * @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromOffset(java.math.BigInteger, long)
*/ */
public MemoryByte[] getBytesFromOffset(BigInteger offset, long units) throws DebugException { public MemoryByte[] getBytesFromOffset(BigInteger offset, long units) throws DebugException {
return getBytesFromAddress(fBaseAddress.add(offset), units); return getBytesFromAddress(fBlockAddress.add(offset), units);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -274,10 +271,10 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
// Flag the changed bytes // Flag the changed bytes
if (fBlock != null && newLength > 0) { if (fBlock != null && newLength > 0) {
switch (fBaseAddress.compareTo(address)) { switch (fBlockAddress.compareTo(address)) {
case -1: case -1:
{ {
int offset = address.subtract(fBaseAddress).intValue(); int offset = address.subtract(fBlockAddress).intValue();
int length = Math.min(fLength - offset, newLength); int length = Math.min(fLength - offset, newLength);
for (int i = 0; i < length; i += 4) { for (int i = 0; i < length; i += 4) {
boolean changed = false; boolean changed = false;
@ -298,7 +295,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
case 0: case 0:
case 1: case 1:
{ {
int offset = fBaseAddress.subtract(address).intValue(); int offset = fBlockAddress.subtract(address).intValue();
int length = Math.min(newLength - offset, fLength); int length = Math.min(newLength - offset, fLength);
for (int i = 0; i < length; i += 4) { for (int i = 0; i < length; i += 4) {
boolean changed = false; boolean changed = false;
@ -323,7 +320,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
// Update the internal state // Update the internal state
fBlock = block; fBlock = block;
fBaseAddress = address; fBlockAddress = address;
fLength = newLength; fLength = newLength;
return fBlock; return fBlock;
@ -397,8 +394,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressableSize() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressableSize()
*/ */
public int getAddressableSize() throws DebugException { public int getAddressableSize() throws DebugException {
// TODO: return fDebugTarget.getAddressableSize(); return fRetrieval.getAddressableSize();
return 1;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -421,7 +417,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
final Addr64 address = new Addr64(bigAddress); final Addr64 address = new Addr64(bigAddress);
final int word_size = 1; final int word_size = 1;
// Use a Query to synchronize the downstream calls // Use a Query to synchronise the downstream calls
Query<MemoryByte[]> query = new Query<MemoryByte[]>() { Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
@Override @Override
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) { protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
@ -437,10 +433,10 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
drm.done(); drm.done();
} }
}); });
}
} }
};
}
};
fRetrieval.getExecutor().execute(query); fRetrieval.getExecutor().execute(query);
try { try {
@ -468,16 +464,33 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
final Addr64 address = new Addr64(fBaseAddress); final Addr64 address = new Addr64(fBaseAddress);
final int word_size = 1; final int word_size = 1;
final IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService(); // Use a Query to synchronise the downstream calls
if (memoryService != null) { Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
memoryService.getExecutor().execute(new Runnable() { @Override
public void run() { protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
if (memoryService != null) {
// Go for it
memoryService.setMemory( memoryService.setMemory(
fRetrieval.getContext(), address, offset, word_size, bytes.length, bytes, fRetrieval.getContext(), address, offset, word_size, bytes.length, bytes,
new RequestMonitor(fRetrieval.getExecutor(), null)); new RequestMonitor(fRetrieval.getExecutor(), null));
} }
});
} }
};
fRetrieval.getExecutor().execute(query);
try {
query.get();
} catch (InterruptedException e) {
throw new DebugException(new Status(IStatus.ERROR,
DsfDebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
"Error writing memory block (InterruptedException)", e)); //$NON-NLS-1$
} catch (ExecutionException e) {
throw new DebugException(new Status(IStatus.ERROR,
DsfDebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
"Error writing memory block (ExecutionException)", e)); //$NON-NLS-1$
}
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -527,9 +540,9 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
public void handleMemoryChange(BigInteger address) { public void handleMemoryChange(BigInteger address) {
// Check if the change affects this particular block (0 is universal) // Check if the change affects this particular block (0 is universal)
BigInteger fEndAddress = fBaseAddress.add(BigInteger.valueOf(fLength)); BigInteger fEndAddress = fBlockAddress.add(BigInteger.valueOf(fLength));
if (address.equals(BigInteger.ZERO) || if (address.equals(BigInteger.ZERO) ||
((fBaseAddress.compareTo(address) != 1) && (fEndAddress.compareTo(address) == 1))) ((fBlockAddress.compareTo(address) != 1) && (fEndAddress.compareTo(address) == 1)))
{ {
// Notify the event listeners // Notify the event listeners
DebugEvent debugEvent = new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT); DebugEvent debugEvent = new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT);

View file

@ -36,6 +36,8 @@ import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.dsf.service.IDsfService;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
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.IMemoryBlockRetrievalExtension; import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
@ -137,30 +139,47 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
return fSession; return fSession;
} }
/**
*
* @return
*/
public DsfExecutor getExecutor() { public DsfExecutor getExecutor() {
return fExecutor; return fExecutor;
} }
/**
*
* @return
*/
public IDMContext<?> getContext() { public IDMContext<?> getContext() {
return fContext; return fContext;
} }
/**
*
* @return
*/
public ServiceTracker getServiceTracker() { public ServiceTracker getServiceTracker() {
return fMemoryServiceTracker; return fMemoryServiceTracker;
} }
// ////////////////////////////////////////////////////////////////////////
// Launch/Target specific information
// To be completed
// ////////////////////////////////////////////////////////////////////////
public ILaunch getLaunch() {
return null;
}
public IDebugTarget getDebugTarget() {
return null;
}
public int getAddressSize() {
return 4;
}
public int getAddressableSize() {
return 1;
}
public boolean supportsValueModification() {
return true;
}
public boolean supportBaseAddressModification() {
return false;
}
// //////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////
// IMemoryBlockRetrieval - obsoleted by IMemoryBlockRetrievalExtension // IMemoryBlockRetrieval - obsoleted by IMemoryBlockRetrievalExtension
// //////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////
@ -276,7 +295,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
private BigInteger resolveMemoryAddress(final IDMContext<?> idmContext, final String expression) throws DebugException { private BigInteger resolveMemoryAddress(final IDMContext<?> idmContext, final String expression) throws DebugException {
// Use a Query to "synchronize" the inherently asynchronous downstream calls // Use a Query to "synchronise" the downstream calls
Query<BigInteger> query = new Query<BigInteger>() { Query<BigInteger> query = new Query<BigInteger>() {
@Override @Override
protected void execute(final DataRequestMonitor<BigInteger> drm) { protected void execute(final DataRequestMonitor<BigInteger> drm) {

View file

@ -27,10 +27,10 @@ import org.eclipse.debug.core.model.MemoryByte;
public interface IMemory extends IDsfService { public interface IMemory extends IDsfService {
/** /**
* Event generated every time a byte is modified. * Event generated every time a range of bytes is modified.
* *
* A client wishing to receive such events has to register as a service * A client wishing to receive such events has to register as a service
* event listener and implement the corresponding dispatchEvent method. * event listener and implement the corresponding eventDispatched method.
* *
* E.g.: * E.g.:
* *
@ -119,9 +119,8 @@ public interface IMemory extends IDsfService {
* @param address the memory block address (on the target) * @param address the memory block address (on the target)
* @param offset the offset from the start address * @param offset the offset from the start address
* @param word_size the size, in bytes, of an addressable item * @param word_size the size, in bytes, of an addressable item
* @param count the number of data elements to write * @param count the number of times [pattern] will be written
* @param pattern the offset in the result buffer * @param pattern the source buffer
* @param buffer the source buffer
* @param rm the asynchronous data request monitor * @param rm the asynchronous data request monitor
*/ */
public void fillMemory(IDMContext<?> context, IAddress address, long offset, public void fillMemory(IDMContext<?> context, IAddress address, long offset,