Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPawel Piech2012-05-09 17:42:48 +0000
committerEugene Tarassov2012-05-11 18:57:37 +0000
commitf8a6494457f29c7f6153a37dd441ee84549db94d (patch)
tree21e473c57151e75cf7d5014b5d541ab4ca31d80f /tests
parentb83ec96307bae55571efb0bc11eea9c33659ad22 (diff)
downloadorg.eclipse.tcf-f8a6494457f29c7f6153a37dd441ee84549db94d.tar.gz
org.eclipse.tcf-f8a6494457f29c7f6153a37dd441ee84549db94d.tar.xz
org.eclipse.tcf-f8a6494457f29c7f6153a37dd441ee84549db94d.zip
Bug 379189 - [tests] Add test to measure stepping performance
Added performance measurement of stepping with source display only.
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/META-INF/MANIFEST.MF3
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/pom.xml3
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java141
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java74
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SourceDisplayListener.java8
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java187
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ResetMap.java15
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java8
8 files changed, 357 insertions, 82 deletions
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/META-INF/MANIFEST.MF b/tests/plugins/org.eclipse.tcf.debug.test/META-INF/MANIFEST.MF
index b3136d046..1547232ee 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/META-INF/MANIFEST.MF
+++ b/tests/plugins/org.eclipse.tcf.debug.test/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.workbench.texteditor;bundle-version="3.8.0",
org.eclipse.jface.text;bundle-version="3.8.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.core.filesystem;bundle-version="1.3.200"
+ org.eclipse.core.filesystem;bundle-version="1.3.200",
+ org.eclipse.test.performance;bundle-version="3.8.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.eclipse.debug.internal.ui.viewers.model
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/pom.xml b/tests/plugins/org.eclipse.tcf.debug.test/pom.xml
index 949358f95..216d62cf5 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/pom.xml
+++ b/tests/plugins/org.eclipse.tcf.debug.test/pom.xml
@@ -32,9 +32,8 @@
<version>${tycho-version}</version>
<configuration>
<includes>
- <!--
<include>**/BreakpointsTest.*</include>
- -->
+ <include>**/SampleTest.*</include>
<include>**/CacheTests.*</include>
<include>**/QueryTests.*</include>
<include>**/TransactionTests.*</include>
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
index 7995951c7..e4948b8ef 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
@@ -44,6 +44,7 @@ import org.eclipse.tcf.core.TransientPeer;
import org.eclipse.tcf.debug.test.services.BreakpointsCM;
import org.eclipse.tcf.debug.test.services.DiagnosticsCM;
import org.eclipse.tcf.debug.test.services.LineNumbersCM;
+import org.eclipse.tcf.debug.test.services.RegistersCM;
import org.eclipse.tcf.debug.test.services.RunControlCM;
import org.eclipse.tcf.debug.test.services.RunControlCM.ContextState;
import org.eclipse.tcf.debug.test.services.StackTraceCM;
@@ -60,6 +61,7 @@ import org.eclipse.tcf.debug.ui.ITCFObject;
import org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.JSON;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IBreakpoints;
import org.eclipse.tcf.services.IDiagnostics;
@@ -67,6 +69,8 @@ import org.eclipse.tcf.services.IDiagnostics.ISymbol;
import org.eclipse.tcf.services.IExpressions;
import org.eclipse.tcf.services.ILineNumbers;
import org.eclipse.tcf.services.IMemoryMap;
+import org.eclipse.tcf.services.IRegisters;
+import org.eclipse.tcf.services.IRegisters.RegistersContext;
import org.eclipse.tcf.services.IRunControl;
import org.eclipse.tcf.services.IRunControl.RunControlContext;
import org.eclipse.tcf.services.IStackTrace;
@@ -109,6 +113,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
protected IBreakpoints bp;
protected IMemoryMap fMemoryMap;
protected ILineNumbers fLineNumbers;
+ protected IRegisters fRegisters;
protected RunControlCM fRunControlCM;
protected DiagnosticsCM fDiagnosticsCM;
@@ -116,7 +121,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
protected StackTraceCM fStackTraceCM;
protected SymbolsCM fSymbolsCM;
protected LineNumbersCM fLineNumbersCM;
-
+ protected RegistersCM fRegistersCM;
protected String fTestId;
protected RunControlContext fTestCtx;
protected String fProcessId = "";
@@ -179,7 +184,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
// Do not activate debug view or debug perspective, also to avoid interferring
// with tests' virtual viewers.
setProperty(IConfigurationProperties.TARGET_PERSPECTIVE, "org.eclipse.cdt.ui.CPerspective"); //$NON-NLS-1$
- setProperty(IConfigurationProperties.TARGET_VIEW, "org.eclipse.cdt.internal.ui.cview.CView"); //$NON-NLS-1$
+ setProperty(IConfigurationProperties.TARGET_VIEW, "org.eclipse.cdt.ui.CView"); //$NON-NLS-1$
}
@Override
@@ -264,9 +269,11 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
fStackTraceCM = new StackTraceCM(stk, rc);
fSymbolsCM = new SymbolsCM(syms, fRunControlCM, fMemoryMap);
fLineNumbersCM = new LineNumbersCM(fLineNumbers, fMemoryMap, fRunControlCM);
+ fRegistersCM = new RegistersCM(fRegisters, rc);
}
protected void tearDownServiceListeners() throws Exception{
+ fRegistersCM.dispose();
fSymbolsCM.dispose();
fBreakpointsCM.dispose();
fStackTraceCM.dispose();
@@ -386,6 +393,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
bp = channels[0].getRemoteService(IBreakpoints.class);
fMemoryMap = channels[0].getRemoteService(IMemoryMap.class);
fLineNumbers = channels[0].getRemoteService(ILineNumbers.class);
+ fRegisters = channels[0].getRemoteService(IRegisters.class);
};
});
}
@@ -583,47 +591,46 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
}
private boolean runToTestEntry(final String testFunc) throws InterruptedException, ExecutionException {
- return new Transaction<Boolean>() {
- Object fWaitForResumeKey;
- Object fWaitForSuspendKey;
- boolean fSuspendEventReceived = false;
- @Override
+ return new Transaction<Boolean>() {
+ Object fWaitForResumeKey;
+ Object fWaitForSuspendKey;
+ boolean fSuspendEventReceived = false;
protected Boolean process() throws Transaction.InvalidCacheException ,ExecutionException {
- ISymbol sym_func0 = validate( fDiagnosticsCM.getSymbol(fProcessId, testFunc) );
- String sym_func0_value = sym_func0.getValue().toString();
- ContextState state = validate (fRunControlCM.getState(fThreadId));
-
- while (!state.suspended || !new BigInteger(state.pc).equals(new BigInteger(sym_func0_value))) {
- if (state.suspended && fWaitForSuspendKey == null) {
- fSuspendEventReceived = true;
- // We are not at test entry. Create a new suspend wait cache.
- fWaitForResumeKey = new Object();
- fWaitForSuspendKey = new Object();
- ICache<Object> waitForResume = fRunControlCM.waitForContextResumed(fThreadId, fWaitForResumeKey);
-
- // Issue resume command.
- validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
-
- // Wait until we receive the resume event.
- validate(waitForResume);
- fWaitForSuspendKey = new Object();
- fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey);
- } else {
- if (fWaitForResumeKey != null) {
- // Validate resume command
- validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
- fWaitForResumeKey = null;
-
- }
- // Wait until we suspend.
- validate( fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey) );
- fWaitForSuspendKey = null;
- }
- }
-
- return fSuspendEventReceived;
- }
- }.get();
+ ISymbol sym_func0 = validate( fDiagnosticsCM.getSymbol(fProcessId, testFunc) );
+ String sym_func0_value = sym_func0.getValue().toString();
+ ContextState state = validate (fRunControlCM.getState(fThreadId));
+
+ while (!state.suspended || !new BigInteger(state.pc).equals(new BigInteger(sym_func0_value))) {
+ if (state.suspended && fWaitForSuspendKey == null) {
+ fSuspendEventReceived = true;
+ // We are not at test entry. Create a new suspend wait cache.
+ fWaitForResumeKey = new Object();
+ fWaitForSuspendKey = new Object();
+ ICache<Object> waitForResume = fRunControlCM.waitForContextResumed(fThreadId, fWaitForResumeKey);
+
+ // Issue resume command.
+ validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
+
+ // Wait until we receive the resume event.
+ validate(waitForResume);
+ fWaitForSuspendKey = new Object();
+ fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey);
+ } else {
+ if (fWaitForResumeKey != null) {
+ // Validate resume command
+ validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
+ fWaitForResumeKey = null;
+
+ }
+ // Wait until we suspend.
+ validate( fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey) );
+ fWaitForSuspendKey = null;
+ }
+ }
+
+ return fSuspendEventReceived;
+ }
+ }.get();
}
protected void initProcessModel(String testFunc) throws Exception {
@@ -739,4 +746,54 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
}.get();
}
+ protected void moveToLocation(final String context, final Number address) throws
+ DebugException, ExecutionException, InterruptedException
+ {
+ final RegistersContext pcReg = new Transaction<RegistersContext>() {
+ protected RegistersContext process() throws InvalidCacheException ,ExecutionException {
+ String[] registers = validate(fRegistersCM.getChildren(context));
+ return findPCRegister(registers);
+ }
+
+ private RegistersContext findPCRegister(String[] registerIds) throws InvalidCacheException ,ExecutionException {
+ for (String regId : registerIds) {
+ RegistersContext reg = validate(fRegistersCM.getContext(regId));
+ if ( IRegisters.ROLE_PC.equals(reg.getRole()) ) {
+ return reg;
+ }
+ }
+ for (String regId : registerIds) {
+ String[] children = validate(fRegistersCM.getChildren(regId));
+ RegistersContext pc = findPCRegister(children);
+ if (pc != null) return pc;
+ }
+ return null;
+ }
+ }.get();
+
+ assertNotNull("Cannot find PC register", pcReg);
+
+ new Transaction<Object>() {
+ protected Object process() throws Transaction.InvalidCacheException ,ExecutionException {
+ byte[] value = addressToByteArray(address, pcReg.getSize(), pcReg.isBigEndian());
+ validate(fRegistersCM.setContextValue(pcReg, this, value));
+ return null;
+ };
+ }.get();
+ }
+
+ private byte[] addressToByteArray(Number address, int size, boolean bigEndian) {
+ byte[] bytes = new byte[size];
+ byte[] addrBytes = JSON.toBigInteger(address).toByteArray();
+ for (int i=0; i < bytes.length; ++i) {
+ byte b = 0;
+ if (i < addrBytes.length) {
+ b = addrBytes[addrBytes.length - i - 1];
+ }
+ bytes[bigEndian ? size -i - 1 : i] = b;
+ }
+ return bytes;
+ }
+
+
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
index 0585cb4c9..3edacaa34 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
@@ -10,6 +10,7 @@ import java.util.regex.Pattern;
import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualItem;
import org.eclipse.tcf.debug.test.services.IWaitForEventCache;
import org.eclipse.tcf.debug.test.services.RunControlCM;
+import org.eclipse.tcf.debug.test.services.RunControlCM.ContextState;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.RangeCache;
import org.eclipse.tcf.debug.test.util.Transaction;
@@ -19,6 +20,8 @@ import org.eclipse.tcf.services.IRunControl.RunControlContext;
import org.eclipse.tcf.services.IStackTrace.StackTraceContext;
import org.eclipse.tcf.services.ISymbols;
import org.eclipse.tcf.services.ISymbols.Symbol;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
import org.junit.Assert;
@SuppressWarnings("restriction")
@@ -66,6 +69,8 @@ public class SampleTest extends AbstractTcfUITest {
initProcessModel("tcf_test_func0");
+
+
// Execute step loop
String previousThreadLabel = null;
for (int stepNum = 0; stepNum < 100; stepNum++) {
@@ -87,33 +92,58 @@ public class SampleTest extends AbstractTcfUITest {
}
}
- public void testSteppingSourceDisplay() throws Exception {
+ public void testSteppingPerformanceWithSourceDisplay() throws Exception {
initProcessModel("tcf_test_func0");
+
+ final Number sym_func0_address = new Transaction<Number>() {
+ protected Number process() throws Transaction.InvalidCacheException ,ExecutionException {
+ return validate( fDiagnosticsCM.getSymbol(fProcessId, "tcf_test_func0") ).getValue();
+ };
+ }.get();
- // Execute step loop
- String previousThreadLabel = null;
- for (int stepNum = 0; stepNum < 100; stepNum++) {
- fDebugViewListener.reset();
- fSourceDisplayListener.reset();
-
- resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
- CodeArea area = calcPCCodeArea();
- if (area != null) {
- fSourceDisplayListener.setCodeArea(calcPCCodeArea());
- }
+ final Number sym_func3_address = new Transaction<Number>() {
+ protected Number process() throws Transaction.InvalidCacheException ,ExecutionException {
+ return validate( fDiagnosticsCM.getSymbol(fProcessId, "tcf_test_func3") ).getValue();
+ };
+ }.get();
- fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
- if (area != null) {
- fSourceDisplayListener.waitTillFinished();
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+
+ try {
+ // Execute step loop
+ for (int stepNum = 0; stepNum < 100; stepNum++) {
+ fDebugViewListener.reset();
+ fSourceDisplayListener.reset();
+
+ meter.start();
+
+ ContextState state = resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
+
+ CodeArea area = calcPCCodeArea();
+ if (area != null) {
+ fSourceDisplayListener.setCodeArea(calcPCCodeArea());
+ }
+
+ fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+ if (area != null) {
+ fSourceDisplayListener.waitTillFinished();
+ }
+
+ meter.stop();
+
+ if (new BigInteger(state.pc).equals(new BigInteger(sym_func3_address.toString()))) {
+ moveToLocation(fThreadId, sym_func0_address);
+ }
+
}
-
- VirtualItem topFrameItem = fDebugViewListener.findElement(
- new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + fProcessId + ".*\\(Step.*"), Pattern.compile(".*")});
- Assert.assertTrue(topFrameItem != null);
- String topFrameLabel = ((String[])topFrameItem.getData(VirtualItem.LABEL_KEY))[0];
- Assert.assertTrue(!topFrameLabel.equals(previousThreadLabel));
- previousThreadLabel = topFrameLabel;
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
}
+
}
private CodeArea calcPCCodeArea() throws ExecutionException, InterruptedException {
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SourceDisplayListener.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SourceDisplayListener.java
index b59df2a12..2522744d3 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SourceDisplayListener.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SourceDisplayListener.java
@@ -95,12 +95,10 @@ public class SourceDisplayListener implements IPartListener, IAnnotationModelLis
}
public void partActivated(IWorkbenchPart part) {
- System.out.println("activated");
partBroughtToTop(part);
}
public void partBroughtToTop(IWorkbenchPart part) {
- System.out.println("top");
fActiveEditor = null;
if (fAnnotationModel != null) {
fAnnotationModel.removeAnnotationModelListener(this);
@@ -112,14 +110,12 @@ public class SourceDisplayListener implements IPartListener, IAnnotationModelLis
}
}
public void partClosed(IWorkbenchPart part) {
- System.out.println("closed");
-
}
+
public void partDeactivated(IWorkbenchPart part) {
- System.out.println("deactivated");
}
+
public void partOpened(IWorkbenchPart part) {
- System.out.println("opened");
}
public void modelChanged(IAnnotationModel model) {
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java
new file mode 100644
index 000000000..f14b80d55
--- /dev/null
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.debug.test.services;
+
+import java.util.Map;
+
+import org.eclipse.tcf.debug.test.util.ICache;
+import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.services.IRegisters;
+import org.eclipse.tcf.services.IRegisters.RegistersContext;
+import org.eclipse.tcf.services.IRunControl;
+import org.eclipse.tcf.services.IRunControl.RunControlContext;
+
+/**
+ *
+ */
+public class RegistersCM extends AbstractCacheManager implements IRunControl.RunControlListener, IRegisters.RegistersListener {
+ private IRegisters fService;
+ private IRunControl fRunControl;
+ private final ResetMap fRunControlStateResetMap = new ResetMap();
+ private final ResetMap fRegistersMap = new ResetMap();
+
+ public RegistersCM(IRegisters service, IRunControl runControl) {
+ fService = service;
+ fRunControl = runControl;
+ fRunControl.addListener(this);
+ }
+
+ @Override
+ public void dispose() {
+ fRunControl.removeListener(this);
+ super.dispose();
+ }
+
+ public ICache<String[]> getChildren(final String id) {
+ class MyCache extends TokenCache<String[]> implements IRegisters.DoneGetChildren {
+ @Override
+ protected IToken retrieveToken() {
+ return fService.getChildren(id, this);
+ }
+
+ public void doneGetChildren(IToken token, Exception error, String[] context_ids) {
+ fRegistersMap.addValid(id, this);
+ set(token, context_ids, error);
+ }
+ };
+
+ return mapCache(new IdKey<MyCache>(MyCache.class, id) {
+ @Override MyCache createCache() { return new MyCache(); }
+ });
+ }
+
+ public ICache<RegistersContext> getContext(final String id) {
+ class MyCache extends TokenCache<RegistersContext> implements IRegisters.DoneGetContext {
+ @Override
+ protected IToken retrieveToken() {
+ return fService.getContext(id, this);
+ }
+
+ public void doneGetContext(IToken token, Exception error, RegistersContext context) {
+ fRegistersMap.addValid(id, this);
+ set(token, context, error);
+ }
+ };
+
+ return mapCache(new IdKey<MyCache>(MyCache.class, id) {
+ @Override MyCache createCache() { return new MyCache(); }
+ });
+ }
+
+ public ICache<byte[]> getContextValue(final RegistersContext context) {
+ class MyCache extends TokenCache<byte[]> implements IRegisters.DoneGet {
+ @Override
+ protected IToken retrieveToken() {
+ return context.get(this);
+ }
+
+ public void doneGet(IToken token, Exception error, byte[] value) {
+ fRegistersMap.addValid(context.getID(), this);
+ set(token, value, error);
+ }
+ };
+
+ return mapCache(new IdKey<MyCache>(MyCache.class, context.getID()) {
+ @Override MyCache createCache() { return new MyCache(); }
+ });
+ }
+
+ protected abstract static class ContextCommandKey<V> extends IdKey<V> {
+ Object fClientKey;
+
+ ContextCommandKey(Class<V> cacheClass, String id, Object clientKey) {
+ super(cacheClass, id);
+ fClientKey = clientKey;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (super.equals(obj) && obj instanceof ContextCommandKey<?>) {
+ return ((ContextCommandKey<?>)obj).fClientKey.equals(fClientKey);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode() + fClientKey.hashCode();
+ }
+ }
+
+
+ public ICache<Object> setContextValue(final RegistersContext context, Object clientKey, final byte[] value) {
+ class MyCache extends TokenCache<Object> implements IRegisters.DoneSet {
+ @Override
+ protected IToken retrieveToken() {
+ return context.set(value, this);
+ }
+
+ public void doneSet(IToken token, Exception error) {
+ fRegistersMap.addValid(context.getID(), this);
+ set(token, null, error);
+ }
+ };
+
+ return mapCache(new ContextCommandKey<MyCache>(MyCache.class, context.getID(), clientKey) {
+ @Override MyCache createCache() { return new MyCache(); }
+ });
+ }
+
+ public void contextChanged() {
+ fRegistersMap.resetAll();
+ }
+
+ public void registerChanged(String id) {
+ fRegistersMap.reset(id);
+ }
+
+ public void contextAdded(RunControlContext[] contexts) {
+ }
+
+ public void contextRemoved(String[] context_ids) {
+ for (String id : context_ids) {
+ fRunControlStateResetMap.reset(id);
+ }
+ }
+
+ public void contextChanged(RunControlContext[] contexts) {
+ for (RunControlContext context : contexts) {
+ fRunControlStateResetMap.reset(context.getID());
+ }
+ }
+
+ public void contextSuspended(String context, String pc, String reason, Map<String, Object> params) {
+ fRunControlStateResetMap.reset(context);
+ }
+
+ public void contextResumed(String context) {
+ fRunControlStateResetMap.reset(context);
+ }
+
+ public void containerSuspended(String context, String pc, String reason, Map<String, Object> params,
+ String[] suspended_ids)
+ {
+ for (String id : suspended_ids) {
+ fRunControlStateResetMap.reset(id);
+ }
+ }
+
+ public void containerResumed(String[] context_ids) {
+ for (String id : context_ids) {
+ fRunControlStateResetMap.reset(id);
+ }
+ }
+
+ public void contextException(String context, String msg) {
+ fRunControlStateResetMap.reset(context);
+ }
+}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ResetMap.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ResetMap.java
index ac9ff8822..49d8f0ea1 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ResetMap.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ResetMap.java
@@ -11,6 +11,7 @@
package org.eclipse.tcf.debug.test.services;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -19,7 +20,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.eclipse.tcf.debug.test.util.AbstractCache;
import org.eclipse.tcf.protocol.Protocol;
/**
@@ -36,6 +36,8 @@ public class ResetMap {
private Map<String, List<IResettable>> fValid = new TreeMap<String, List<IResettable>>();
private Map<String, Set<String>> fChildren = new TreeMap<String, Set<String>>();
private Map<String, String> fParents = new TreeMap<String, String>();
+
+ // Mapping of context IDs that were reset while a given cache was pending.
private Map<IResettable, Set<String>> fPending = new LinkedHashMap<IResettable, Set<String>>();
public synchronized Set<String> removePending(IResettable cache) {
@@ -155,6 +157,17 @@ public class ResetMap {
}
}
+ public synchronized void resetAll() {
+ Collection<List<IResettable>> valid = null;
+ synchronized (this) {
+ valid = fValid.values();
+ }
+
+ for (List<IResettable> validList : valid) {
+ resetList(validList);
+ }
+ }
+
public synchronized void addPending(IResettable cache) {
fPending.put(cache, new TreeSet<String>());
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
index e913a26b4..a50943712 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
@@ -52,12 +52,10 @@ public class StackTraceCM extends AbstractCacheManager implements IRunControl.Ru
class MyCache extends TokenCache<String[]> implements IStackTrace.DoneGetChildren {
@Override
protected IToken retrieveToken() {
- fRunControlStateResetMap.addPending(this);
return fService.getChildren(id, this);
}
public void doneGetChildren(IToken token, Exception error, String[] context_ids) {
- fRunControlStateResetMap.removePending(this);
fRunControlStateResetMap.addValid(id, this);
set(token, context_ids, error);
}
@@ -72,10 +70,8 @@ public class StackTraceCM extends AbstractCacheManager implements IRunControl.Ru
class MyCache extends RangeCache<StackTraceContext> implements IResettable {
boolean fIsValid = false;
- boolean fIsPending = false;
@Override
protected void retrieve(final long offset, final int count, DataCallback<List<StackTraceContext>> rm) {
- if (!fIsPending) fRunControlStateResetMap.addPending(MyCache.this);
new Transaction<List<StackTraceContext>>() {
@Override
protected List<StackTraceContext> process() throws InvalidCacheException, ExecutionException {
@@ -85,7 +81,6 @@ public class StackTraceCM extends AbstractCacheManager implements IRunControl.Ru
System.arraycopy(ids, (int)offset, subIds, 0, adjustedCount);
StackTraceContext[] contexts = validate(getContexts(subIds));
if (!fIsValid) {
- fRunControlStateResetMap.removePending(MyCache.this);
fRunControlStateResetMap.addValid(parentId, MyCache.this);
}
return Arrays.asList(contexts);
@@ -96,7 +91,6 @@ public class StackTraceCM extends AbstractCacheManager implements IRunControl.Ru
public void reset() {
fIsValid = false;
- fIsPending = false;
@SuppressWarnings("unchecked")
List<StackTraceContext> emptyData = (List<StackTraceContext>)Collections.EMPTY_LIST;
set(0, 0, emptyData, new Throwable("Cache invalid") );
@@ -133,8 +127,6 @@ public class StackTraceCM extends AbstractCacheManager implements IRunControl.Ru
public void contextAdded(RunControlContext[] contexts) {
- // TODO Auto-generated method stub
-
}
public void contextChanged(RunControlContext[] contexts) {

Back to the top