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

Improvements for the following bugs:

Bug200620: Added a memory cache
Bug205341: Updated the MemocryChangedEvent
This commit is contained in:
Francois Chouinard 2007-10-07 19:43:55 +00:00
parent ebd8d1632b
commit 4d45b0a3c4
2 changed files with 50 additions and 14 deletions

View file

@ -17,14 +17,17 @@ import java.util.ArrayList;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.utils.Addr64; import org.eclipse.cdt.utils.Addr64;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.concurrent.Query; import org.eclipse.dd.dsf.concurrent.Query;
import org.eclipse.dd.dsf.concurrent.RequestMonitor; import org.eclipse.dd.dsf.concurrent.RequestMonitor;
import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.debug.service.IMemory; 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.MemoryChangedEvent; import org.eclipse.dd.dsf.debug.service.IMemory.MemoryChangedEvent;
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
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;
@ -235,7 +238,8 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportsChangeManagement() * @see org.eclipse.debug.core.model.IMemoryBlockExtension#supportsChangeManagement()
*/ */
public boolean supportsChangeManagement() { public boolean supportsChangeManagement() {
// Let the UI handle block content modification // TODO: UI is a bit lazy. Implement change management ourselves.
// return true;
return false; return false;
} }
@ -354,20 +358,20 @@ 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 inherently asynchronous downstream calls // Use a Query to synchronize the downstream calls
Query<MemoryByte[]> query = new Query<MemoryByte[]>() { Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
@Override @Override
protected void execute(final DataRequestMonitor<MemoryByte[]> rm) { protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService(); IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
if (memoryService != null) { if (memoryService != null) {
// Go for it // Go for it
memoryService.getMemory( memoryService.getMemory(
fRetrieval.getContext(), address, 0, word_size, (int) length, fRetrieval.getContext(), address, 0, word_size, (int) length,
new DataRequestMonitor<MemoryByte[]>(fRetrieval.getExecutor(), rm) { new DataRequestMonitor<MemoryByte[]>(fRetrieval.getExecutor(), drm) {
@Override @Override
protected void handleOK() { protected void handleOK() {
rm.setData(getData()); drm.setData(getData());
rm.done(); drm.done();
} }
}); });
} }
@ -378,7 +382,9 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
try { try {
return query.get(); return query.get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println("Interrupted Exception"); //$NON-NLS-1$
} catch (ExecutionException e) { } catch (ExecutionException e) {
System.out.println("Execution Exception"); //$NON-NLS-1$
} }
return null; return null;
@ -386,11 +392,33 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
@DsfServiceEventHandler @DsfServiceEventHandler
public void eventDispatched(MemoryChangedEvent e) { public void eventDispatched(MemoryChangedEvent e) {
handleMemoryChange(e.getAddress().getValue());
// Find the container of the event
IContainerDMContext eventContext = DMContexts.getAncestorOfType(e.getContext(), IContainerDMContext.class);
if (eventContext == null) {
return;
}
// Find the container of the block
IContainerDMContext blockContext = DMContexts.getAncestorOfType(fRetrieval.getContext(), IContainerDMContext.class);
if (blockContext == null) {
// Should not happen: throw an exception
return;
}
// Check if we are in the same address space
if (eventContext != blockContext) {
return;
}
IAddress[] addresses = e.getAddresses();
for (int i = 0; i < addresses.length; i++)
handleMemoryChange(addresses[i].getValue());
} }
@DsfServiceEventHandler @DsfServiceEventHandler
public void eventDispatched(IRunControl.ISuspendedDMEvent e) { public void eventDispatched(IRunControl.ISuspendedDMEvent e) {
// TODO: Check if we are in the right context
handleMemoryChange(BigInteger.ZERO); handleMemoryChange(BigInteger.ZERO);
} }
@ -428,6 +456,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
* @param length * @param length
*/ */
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 = fBaseAddress.add(BigInteger.valueOf(fLength));
if (address.equals(BigInteger.ZERO) || if (address.equals(BigInteger.ZERO) ||

View file

@ -43,19 +43,26 @@ public interface IMemory extends IDsfService {
* *
* @DsfServiceEventHandler * @DsfServiceEventHandler
* public void eventDispatched(MemoryChangedEvent e) { * public void eventDispatched(MemoryChangedEvent e) {
* IAddress address = e.getAddress(); * IDMContext<?> context = e.getContext();
* IAddress[] addresses = e.getAddresses();
* // do whatever... * // do whatever...
* } * }
*/ */
public class MemoryChangedEvent { public class MemoryChangedEvent {
IAddress fAddress; IAddress[] fAddresses;
IDMContext<?> fContext;
public MemoryChangedEvent(IAddress address) { public MemoryChangedEvent(IDMContext<?> context, IAddress[] addresses) {
fAddress = address; fContext = context;
fAddresses = addresses;
} }
public IAddress getAddress() { public IDMContext<?> getContext() {
return fAddress; return fContext;
}
public IAddress[] getAddresses() {
return fAddresses;
} }
} }