mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 22:45:23 +02:00
[229914] Implement Update Policy support for Memory View; initial DsfMemoryBlock support
This commit is contained in:
parent
429d7531fc
commit
8c58d70bca
1 changed files with 59 additions and 4 deletions
|
@ -32,6 +32,7 @@ import org.eclipse.dd.dsf.debug.service.IMemory;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.dd.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
import org.eclipse.dd.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IMemory.IMemoryDMContext;
|
import org.eclipse.dd.dsf.debug.service.IMemory.IMemoryDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
||||||
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
@ -40,6 +41,7 @@ import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||||
|
import org.eclipse.debug.core.model.IMemoryBlockUpdatePolicy;
|
||||||
import org.eclipse.debug.core.model.MemoryByte;
|
import org.eclipse.debug.core.model.MemoryByte;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +50,12 @@ import org.eclipse.debug.core.model.MemoryByte;
|
||||||
*
|
*
|
||||||
* It performs its read/write functions using the MemoryService.
|
* It performs its read/write functions using the MemoryService.
|
||||||
*/
|
*/
|
||||||
public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtension
|
public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtension, IMemoryBlockUpdatePolicy
|
||||||
{
|
{
|
||||||
|
private final static String UPDATE_POLICY_AUTOMATIC = "Automatic"; //$NON-NLS-1$
|
||||||
|
private final static String UPDATE_POLICY_MANUAL = "Manual"; //$NON-NLS-1$
|
||||||
|
private final static String UPDATE_POLICY_BREAKPOINT = "On Breakpoint"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final IMemoryDMContext fContext;
|
private final IMemoryDMContext fContext;
|
||||||
private final ILaunch fLaunch;
|
private final ILaunch fLaunch;
|
||||||
private final IDebugTarget fDebugTarget;
|
private final IDebugTarget fDebugTarget;
|
||||||
|
@ -63,6 +69,8 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
private int fWordSize;
|
private int fWordSize;
|
||||||
private MemoryByte[] fBlock;
|
private MemoryByte[] fBlock;
|
||||||
|
|
||||||
|
private String fUpdatePolicy = UPDATE_POLICY_AUTOMATIC;
|
||||||
|
|
||||||
private ArrayList<Object> fConnections = new ArrayList<Object>();
|
private ArrayList<Object> fConnections = new ArrayList<Object>();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -264,10 +272,35 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
return getBytesFromAddress(fBlockAddress.add(offset), units);
|
return getBytesFromAddress(fBlockAddress.add(offset), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean fUseCachedData = false;
|
||||||
|
|
||||||
|
public void clearCache() {
|
||||||
|
fUseCachedData = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void handleCacheSuspendEvent(IRunControl.ISuspendedDMEvent e) {
|
||||||
|
e.getReason();
|
||||||
|
if(e.getReason() == StateChangeReason.BREAKPOINT)
|
||||||
|
fUseCachedData = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isUseCacheData()
|
||||||
|
{
|
||||||
|
if(fUpdatePolicy.equals(DsfMemoryBlock.UPDATE_POLICY_BREAKPOINT))
|
||||||
|
return fUseCachedData;
|
||||||
|
else if(fUpdatePolicy.equals(DsfMemoryBlock.UPDATE_POLICY_MANUAL))
|
||||||
|
return fUseCachedData;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromAddress(java.math.BigInteger, long)
|
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromAddress(java.math.BigInteger, long)
|
||||||
*/
|
*/
|
||||||
public MemoryByte[] getBytesFromAddress(BigInteger address, long units) throws DebugException {
|
public MemoryByte[] getBytesFromAddress(BigInteger address, long units) throws DebugException {
|
||||||
|
if(isUseCacheData() && fBlockAddress.compareTo(address) == 0 && units * getAddressableSize() <= fBlock.length)
|
||||||
|
return fBlock;
|
||||||
|
|
||||||
MemoryByte[] block = fetchMemoryBlock(address, units);
|
MemoryByte[] block = fetchMemoryBlock(address, units);
|
||||||
int newLength = (block != null) ? block.length : 0;
|
int newLength = (block != null) ? block.length : 0;
|
||||||
|
@ -326,6 +359,11 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
fBlockAddress = address;
|
fBlockAddress = address;
|
||||||
fLength = newLength;
|
fLength = newLength;
|
||||||
|
|
||||||
|
if(fUpdatePolicy.equals(DsfMemoryBlock.UPDATE_POLICY_BREAKPOINT))
|
||||||
|
fUseCachedData = true;
|
||||||
|
else if(fUpdatePolicy.equals(DsfMemoryBlock.UPDATE_POLICY_MANUAL))
|
||||||
|
fUseCachedData = true;
|
||||||
|
|
||||||
return fBlock;
|
return fBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,4 +575,21 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getUpdatePolicies() {
|
||||||
|
return new String[] {UPDATE_POLICY_AUTOMATIC, UPDATE_POLICY_MANUAL, UPDATE_POLICY_BREAKPOINT};
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdatePolicy()
|
||||||
|
{
|
||||||
|
return fUpdatePolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatePolicy(String policy)
|
||||||
|
{
|
||||||
|
fUpdatePolicy = policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdatePolicyDescription(String id) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue