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:
parent
df21b47db1
commit
732160a2a5
3 changed files with 89 additions and 58 deletions
|
@ -56,8 +56,10 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
private final DsfMemoryBlockRetrieval fRetrieval;
|
||||
private final String fModelId;
|
||||
private final String fExpression;
|
||||
protected BigInteger fBaseAddress;
|
||||
protected int fLength;
|
||||
private final BigInteger fBaseAddress;
|
||||
|
||||
private BigInteger fBlockAddress;
|
||||
private int fLength;
|
||||
private MemoryByte[] fBlock;
|
||||
|
||||
private ArrayList<Object> fConnections = new ArrayList<Object>();
|
||||
|
@ -76,12 +78,15 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
*/
|
||||
DsfMemoryBlock(DsfMemoryBlockRetrieval retrieval, String modelId, String expression, BigInteger address, long length) {
|
||||
|
||||
fLaunch = null; // TODO: fRetrieval.getLaunch();
|
||||
fDebugTarget = null; // TODO: fRetrieval.getDebugTarget();
|
||||
fLaunch = retrieval.getLaunch();
|
||||
fDebugTarget = retrieval.getDebugTarget();
|
||||
fRetrieval = retrieval;
|
||||
fModelId = modelId;
|
||||
fExpression = expression;
|
||||
fBaseAddress = address;
|
||||
|
||||
// Current block information
|
||||
fBlockAddress = address;
|
||||
fLength = (int) length;
|
||||
fBlock = null;
|
||||
|
||||
|
@ -169,8 +174,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
* @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification()
|
||||
*/
|
||||
public boolean supportsValueModification() {
|
||||
// TODO: return fDebugTarget.supportsValueModification(this);
|
||||
return true;
|
||||
return fRetrieval.supportsValueModification();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -226,21 +230,14 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressSize()
|
||||
*/
|
||||
public int getAddressSize() throws DebugException {
|
||||
// TODO:
|
||||
// try {
|
||||
// return fDebugTarget.getAddressSize();
|
||||
// } catch (CoreException e) {
|
||||
// throw new DebugException(e.getStatus());
|
||||
// }
|
||||
return 4;
|
||||
return fRetrieval.getAddressSize();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportBaseAddressModification()
|
||||
*/
|
||||
public boolean supportBaseAddressModification() throws DebugException {
|
||||
// TODO: return fDebugTarget.supportBaseAddressModification(this);
|
||||
return false;
|
||||
return fRetrieval.supportBaseAddressModification();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -254,14 +251,14 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#setBaseAddress(java.math.BigInteger)
|
||||
*/
|
||||
public void setBaseAddress(BigInteger address) throws DebugException {
|
||||
fBaseAddress = address;
|
||||
fBlockAddress = address;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromOffset(java.math.BigInteger, long)
|
||||
*/
|
||||
public MemoryByte[] getBytesFromOffset(BigInteger offset, long units) throws DebugException {
|
||||
return getBytesFromAddress(fBaseAddress.add(offset), units);
|
||||
return getBytesFromAddress(fBlockAddress.add(offset), units);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -274,10 +271,10 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
|
||||
// Flag the changed bytes
|
||||
if (fBlock != null && newLength > 0) {
|
||||
switch (fBaseAddress.compareTo(address)) {
|
||||
switch (fBlockAddress.compareTo(address)) {
|
||||
case -1:
|
||||
{
|
||||
int offset = address.subtract(fBaseAddress).intValue();
|
||||
int offset = address.subtract(fBlockAddress).intValue();
|
||||
int length = Math.min(fLength - offset, newLength);
|
||||
for (int i = 0; i < length; i += 4) {
|
||||
boolean changed = false;
|
||||
|
@ -298,7 +295,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
case 0:
|
||||
case 1:
|
||||
{
|
||||
int offset = fBaseAddress.subtract(address).intValue();
|
||||
int offset = fBlockAddress.subtract(address).intValue();
|
||||
int length = Math.min(newLength - offset, fLength);
|
||||
for (int i = 0; i < length; i += 4) {
|
||||
boolean changed = false;
|
||||
|
@ -323,7 +320,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
|
||||
// Update the internal state
|
||||
fBlock = block;
|
||||
fBaseAddress = address;
|
||||
fBlockAddress = address;
|
||||
fLength = newLength;
|
||||
|
||||
return fBlock;
|
||||
|
@ -397,8 +394,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getAddressableSize()
|
||||
*/
|
||||
public int getAddressableSize() throws DebugException {
|
||||
// TODO: return fDebugTarget.getAddressableSize();
|
||||
return 1;
|
||||
return fRetrieval.getAddressableSize();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -421,7 +417,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
final Addr64 address = new Addr64(bigAddress);
|
||||
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[]>() {
|
||||
@Override
|
||||
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
||||
|
@ -468,15 +464,32 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
|||
final Addr64 address = new Addr64(fBaseAddress);
|
||||
final int word_size = 1;
|
||||
|
||||
final IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
|
||||
// Use a Query to synchronise the downstream calls
|
||||
Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
|
||||
@Override
|
||||
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
||||
IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
|
||||
if (memoryService != null) {
|
||||
memoryService.getExecutor().execute(new Runnable() {
|
||||
public void run() {
|
||||
// Go for it
|
||||
memoryService.setMemory(
|
||||
fRetrieval.getContext(), address, offset, word_size, bytes.length, bytes,
|
||||
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) {
|
||||
|
||||
// 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) ||
|
||||
((fBaseAddress.compareTo(address) != 1) && (fEndAddress.compareTo(address) == 1)))
|
||||
((fBlockAddress.compareTo(address) != 1) && (fEndAddress.compareTo(address) == 1)))
|
||||
{
|
||||
// Notify the event listeners
|
||||
DebugEvent debugEvent = new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT);
|
||||
|
|
|
@ -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.IDsfService;
|
||||
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.IMemoryBlockExtension;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
|
||||
|
@ -137,30 +139,47 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
|||
return fSession;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DsfExecutor getExecutor() {
|
||||
return fExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IDMContext<?> getContext() {
|
||||
return fContext;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ServiceTracker getServiceTracker() {
|
||||
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
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
|
@ -276,7 +295,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
|||
|
||||
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>() {
|
||||
@Override
|
||||
protected void execute(final DataRequestMonitor<BigInteger> drm) {
|
||||
|
|
|
@ -27,10 +27,10 @@ import org.eclipse.debug.core.model.MemoryByte;
|
|||
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
|
||||
* event listener and implement the corresponding dispatchEvent method.
|
||||
* event listener and implement the corresponding eventDispatched method.
|
||||
*
|
||||
* E.g.:
|
||||
*
|
||||
|
@ -119,9 +119,8 @@ public interface IMemory extends IDsfService {
|
|||
* @param address the memory block address (on the target)
|
||||
* @param offset the offset from the start address
|
||||
* @param word_size the size, in bytes, of an addressable item
|
||||
* @param count the number of data elements to write
|
||||
* @param pattern the offset in the result buffer
|
||||
* @param buffer the source buffer
|
||||
* @param count the number of times [pattern] will be written
|
||||
* @param pattern the source buffer
|
||||
* @param rm the asynchronous data request monitor
|
||||
*/
|
||||
public void fillMemory(IDMContext<?> context, IAddress address, long offset,
|
||||
|
|
Loading…
Add table
Reference in a new issue