mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 335098: JUnit tests don't always use the DSF executor when they should
This commit is contained in:
parent
dde309b5ee
commit
ed94590082
11 changed files with 256 additions and 161 deletions
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.framework;
|
package org.eclipse.cdt.tests.dsf.gdb.framework;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
||||||
|
@ -58,13 +60,31 @@ public class ServiceEventWaitor<V> {
|
||||||
fSession = session;
|
fSession = session;
|
||||||
fEventTypeClass = eventClass;
|
fEventTypeClass = eventClass;
|
||||||
fEvent = null;
|
fEvent = null;
|
||||||
fSession.addServiceEventListener(this, null);
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fSession.addServiceEventListener(ServiceEventWaitor.this, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
super.finalize();
|
super.finalize();
|
||||||
if (fEventTypeClass != null) fSession.removeServiceEventListener(this);
|
if (fEventTypeClass != null) {
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fSession.removeServiceEventListener(ServiceEventWaitor.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,6 +21,7 @@ import junit.framework.Assert;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
|
@ -28,7 +29,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
|
||||||
|
@ -37,7 +39,8 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
|
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIRunControl;
|
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIStack;
|
import org.eclipse.cdt.dsf.mi.service.MIStack;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIRunningEvent;
|
import org.eclipse.cdt.dsf.mi.service.command.events.MIRunningEvent;
|
||||||
|
@ -59,7 +62,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
public class SyncUtil {
|
public class SyncUtil {
|
||||||
|
|
||||||
private static ICommandControlService fCommandControl;
|
private static ICommandControlService fCommandControl;
|
||||||
private static MIRunControl fRunControl;
|
private static IMIRunControl fRunControl;
|
||||||
private static MIStack fStack;
|
private static MIStack fStack;
|
||||||
private static IExpressions fExpressions;
|
private static IExpressions fExpressions;
|
||||||
private static DsfSession fSession;
|
private static DsfSession fSession;
|
||||||
|
@ -67,30 +70,31 @@ public class SyncUtil {
|
||||||
private static CommandFactory fCommandFactory;
|
private static CommandFactory fCommandFactory;
|
||||||
|
|
||||||
private static IBreakpointsTargetDMContext fBreakpointsDmc;
|
private static IBreakpointsTargetDMContext fBreakpointsDmc;
|
||||||
private static IProcesses fProcessesService;
|
private static IMIProcesses fProcessesService;
|
||||||
|
|
||||||
public static final int WAIT_FOREVER = ServiceEventWaitor.WAIT_FOREVER;
|
|
||||||
|
|
||||||
// Initialize some common things, once the session has been established
|
// Initialize some common things, once the session has been established
|
||||||
public static void initialize(DsfSession session) {
|
public static void initialize(DsfSession session) throws Exception {
|
||||||
fSession = session;
|
fSession = session;
|
||||||
|
|
||||||
DsfServicesTracker tracker =
|
Runnable runnable = new Runnable() {
|
||||||
new DsfServicesTracker(TestsPlugin.getBundleContext(),
|
public void run() {
|
||||||
fSession.getId());
|
DsfServicesTracker tracker =
|
||||||
|
new DsfServicesTracker(TestsPlugin.getBundleContext(),
|
||||||
fCommandControl = tracker.getService(ICommandControlService.class);
|
fSession.getId());
|
||||||
|
|
||||||
fBreakpointsDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext();
|
fCommandControl = tracker.getService(ICommandControlService.class);
|
||||||
|
fRunControl = tracker.getService(IMIRunControl.class);
|
||||||
fRunControl = tracker.getService(MIRunControl.class);
|
fStack = tracker.getService(MIStack.class);
|
||||||
fStack = tracker.getService(MIStack.class);
|
fExpressions = tracker.getService(IExpressions.class);
|
||||||
fExpressions = tracker.getService(IExpressions.class);
|
fProcessesService = tracker.getService(IMIProcesses.class);
|
||||||
fProcessesService = tracker.getService(IProcesses.class);
|
fCommandFactory = tracker.getService(IMICommandControl.class).getCommandFactory();
|
||||||
|
|
||||||
fCommandFactory = tracker.getService(IMICommandControl.class).getCommandFactory();
|
fBreakpointsDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext();
|
||||||
|
|
||||||
tracker.dispose();
|
tracker.dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MIStoppedEvent step(int numSteps, final StepType stepType) throws Throwable {
|
public static MIStoppedEvent step(int numSteps, final StepType stepType) throws Throwable {
|
||||||
|
@ -429,7 +433,10 @@ public class SyncUtil {
|
||||||
public static IMIExecutionDMContext createExecutionContext(final IContainerDMContext parentCtx, final int threadId) throws Throwable {
|
public static IMIExecutionDMContext createExecutionContext(final IContainerDMContext parentCtx, final int threadId) throws Throwable {
|
||||||
Callable<IMIExecutionDMContext> callable = new Callable<IMIExecutionDMContext>() {
|
Callable<IMIExecutionDMContext> callable = new Callable<IMIExecutionDMContext>() {
|
||||||
public IMIExecutionDMContext call() throws Exception {
|
public IMIExecutionDMContext call() throws Exception {
|
||||||
return fRunControl.createMIExecutionContext(parentCtx, threadId);
|
String threadIdStr = Integer.toString(threadId);
|
||||||
|
IProcessDMContext processDmc = DMContexts.getAncestorOfType(parentCtx, IProcessDMContext.class);
|
||||||
|
IThreadDMContext threadDmc = fProcessesService.createThreadContext(processDmc, threadIdStr);
|
||||||
|
return fProcessesService.createExecutionContext(parentCtx, threadDmc, threadIdStr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return fSession.getExecutor().submit(callable).get();
|
return fSession.getExecutor().submit(callable).get();
|
||||||
|
|
|
@ -65,11 +65,13 @@ public class GDBProcessesTest extends BaseTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
Runnable runnable = new Runnable() {
|
||||||
/*
|
public void run() {
|
||||||
* Get the GDBProcesses & MIRunControl service.
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
*/
|
fProcService = fServicesTracker.getService(IMIProcesses.class);
|
||||||
fProcService = fServicesTracker.getService(IMIProcesses.class);
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -96,6 +96,7 @@ public class MIBreakpointsTest extends BaseTestCase {
|
||||||
protected DsfServicesTracker fServicesTracker;
|
protected DsfServicesTracker fServicesTracker;
|
||||||
protected MIRunControl fRunControl;
|
protected MIRunControl fRunControl;
|
||||||
protected IBreakpoints fBreakpointService;
|
protected IBreakpoints fBreakpointService;
|
||||||
|
protected IExpressions fExpressionService;
|
||||||
|
|
||||||
// Event Management
|
// Event Management
|
||||||
protected static Boolean lock = true;
|
protected static Boolean lock = true;
|
||||||
|
@ -176,34 +177,47 @@ public class MIBreakpointsTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void testCaseInitialization() {
|
public void testCaseInitialization() throws Exception {
|
||||||
|
|
||||||
// Get a reference to the breakpoint service
|
// Get a reference to the breakpoint service
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
Runnable runnable = new Runnable() {
|
||||||
assert(fServicesTracker != null);
|
public void run() {
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
assert(fServicesTracker != null);
|
||||||
|
|
||||||
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
||||||
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
||||||
assert(fBreakpointsDmc != null);
|
assert(fBreakpointsDmc != null);
|
||||||
|
|
||||||
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
||||||
assert(fRunControl != null);
|
assert(fRunControl != null);
|
||||||
|
|
||||||
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
||||||
assert(fBreakpointService != null);
|
assert(fBreakpointService != null);
|
||||||
|
|
||||||
// Register to breakpoint events
|
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
||||||
fRunControl.getSession().addServiceEventListener(MIBreakpointsTest.this, null);
|
assert(fExpressionService != null);
|
||||||
|
|
||||||
clearEventCounters();
|
// Register to breakpoint events
|
||||||
|
fRunControl.getSession().addServiceEventListener(MIBreakpointsTest.this, null);
|
||||||
|
|
||||||
|
clearEventCounters();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void testCaseCleanup() {
|
public void testCaseCleanup() throws Exception {
|
||||||
|
|
||||||
// Clear the references (not strictly necessary)
|
// Clear the references (not strictly necessary)
|
||||||
fRunControl.getSession().removeServiceEventListener(MIBreakpointsTest.this);
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fRunControl.getSession().removeServiceEventListener(MIBreakpointsTest.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
fBreakpointService = null;
|
fBreakpointService = null;
|
||||||
fRunControl = null;
|
fRunControl = null;
|
||||||
fServicesTracker.dispose();
|
fServicesTracker.dispose();
|
||||||
|
@ -361,9 +375,6 @@ public class MIBreakpointsTest extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
private BigInteger evaluateExpression(IDMContext ctx, String expression) throws Throwable {
|
private BigInteger evaluateExpression(IDMContext ctx, String expression) throws Throwable {
|
||||||
|
|
||||||
final IExpressions fExpressionService = fServicesTracker.getService(IExpressions.class);
|
|
||||||
assert (fExpressionService != null);
|
|
||||||
|
|
||||||
// Get a stack context (temporary - should be an MIcontainerDMC)
|
// Get a stack context (temporary - should be an MIcontainerDMC)
|
||||||
final IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
final IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
||||||
final FormattedValueDMContext formattedValueDMC = SyncUtil.getFormattedValue(fExpressionService,
|
final FormattedValueDMContext formattedValueDMC = SyncUtil.getFormattedValue(fExpressionService,
|
||||||
|
|
|
@ -99,7 +99,8 @@ public class MICatchpointsTest extends BaseTestCase {
|
||||||
private DsfServicesTracker fServicesTracker;
|
private DsfServicesTracker fServicesTracker;
|
||||||
private MIRunControl fRunControl;
|
private MIRunControl fRunControl;
|
||||||
private IBreakpoints fBreakpointService;
|
private IBreakpoints fBreakpointService;
|
||||||
|
private IExpressions fExpressionService;
|
||||||
|
|
||||||
// Event Management
|
// Event Management
|
||||||
private static Boolean fEventHandlerLock = true;
|
private static Boolean fEventHandlerLock = true;
|
||||||
private enum Events { BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT }
|
private enum Events { BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT }
|
||||||
|
@ -157,34 +158,48 @@ public class MICatchpointsTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void testCaseInitialization() {
|
public void testCaseInitialization() throws Exception {
|
||||||
|
|
||||||
// Get a reference to the breakpoint service
|
// Get a reference to the breakpoint service
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
Runnable runnable = new Runnable() {
|
||||||
assertNotNull(fServicesTracker);
|
public void run() {
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
assertNotNull(fServicesTracker);
|
||||||
|
|
||||||
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
||||||
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
||||||
assertNotNull(fBreakpointsDmc);
|
assertNotNull(fBreakpointsDmc);
|
||||||
|
|
||||||
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
||||||
assertNotNull(fRunControl);
|
assertNotNull(fRunControl);
|
||||||
|
|
||||||
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
||||||
assertNotNull(fBreakpointService);
|
assertNotNull(fBreakpointService);
|
||||||
|
|
||||||
// Register to receive breakpoint events
|
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
||||||
fRunControl.getSession().addServiceEventListener(MICatchpointsTest.this, null);
|
assertNotNull(fExpressionService);
|
||||||
|
|
||||||
clearEventCounters();
|
|
||||||
|
// Register to receive breakpoint events
|
||||||
|
fRunControl.getSession().addServiceEventListener(MICatchpointsTest.this, null);
|
||||||
|
|
||||||
|
clearEventCounters();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void testCaseCleanup() {
|
public void testCaseCleanup() throws Exception {
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fRunControl.getSession().removeServiceEventListener(MICatchpointsTest.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
|
|
||||||
// Clear the references (not strictly necessary)
|
// Clear the references (not strictly necessary)
|
||||||
fRunControl.getSession().removeServiceEventListener(MICatchpointsTest.this);
|
|
||||||
fBreakpointService = null;
|
fBreakpointService = null;
|
||||||
fRunControl = null;
|
fRunControl = null;
|
||||||
fServicesTracker.dispose();
|
fServicesTracker.dispose();
|
||||||
|
@ -316,9 +331,6 @@ public class MICatchpointsTest extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
private BigInteger evaluateExpression(IDMContext ctx, String expression) throws Throwable {
|
private BigInteger evaluateExpression(IDMContext ctx, String expression) throws Throwable {
|
||||||
|
|
||||||
final IExpressions fExpressionService = fServicesTracker.getService(IExpressions.class);
|
|
||||||
assert (fExpressionService != null);
|
|
||||||
|
|
||||||
// Get a stack context (temporary - should be an MIcontainerDMC)
|
// Get a stack context (temporary - should be an MIcontainerDMC)
|
||||||
final IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
final IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
||||||
final FormattedValueDMContext formattedValueDMC = SyncUtil.getFormattedValue(fExpressionService,
|
final FormattedValueDMContext formattedValueDMC = SyncUtil.getFormattedValue(fExpressionService,
|
||||||
|
|
|
@ -19,14 +19,14 @@ import java.math.BigInteger;
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIDisassembly;
|
import org.eclipse.cdt.dsf.mi.service.MIDisassembly;
|
||||||
|
@ -88,30 +88,30 @@ public class MIDisassemblyTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void testCaseInitialization() {
|
public void testCaseInitialization() throws Exception {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// Get a reference to the memory service
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
assert(fServicesTracker != null);
|
||||||
|
|
||||||
// Get a reference to the memory service
|
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
fDisassemblyDmc = (IDisassemblyDMContext)commandControl.getContext();
|
||||||
assert(fServicesTracker != null);
|
assert(fDisassemblyDmc != null);
|
||||||
|
|
||||||
|
fDisassembly = fServicesTracker.getService(MIDisassembly.class);
|
||||||
|
assert(fDisassembly != null);
|
||||||
|
|
||||||
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
||||||
fDisassemblyDmc = (IDisassemblyDMContext)commandControl.getContext();
|
assert(fExpressionService != null);
|
||||||
assert(fDisassemblyDmc != null);
|
}
|
||||||
|
};
|
||||||
fDisassembly = fServicesTracker.getService(MIDisassembly.class);
|
fSession.getExecutor().submit(runnable).get();
|
||||||
assert(fDisassembly != null);
|
|
||||||
|
|
||||||
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
|
||||||
assert(fExpressionService != null);
|
|
||||||
|
|
||||||
// fSession.addServiceEventListener(MIDisassemblyTest.this, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void testCaseCleanup() {
|
public void testCaseCleanup() {
|
||||||
// Clear the references (not strictly necessary)
|
|
||||||
// fSession.removeServiceEventListener(MIDisassemblyTest.this);
|
|
||||||
fExpressionService = null;
|
fExpressionService = null;
|
||||||
fDisassembly = null;
|
fDisassembly = null;
|
||||||
fServicesTracker.dispose();
|
fServicesTracker.dispose();
|
||||||
|
|
|
@ -77,18 +77,28 @@ public class MIExpressionsTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() throws Exception {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
fExpService = fServicesTracker.getService(IExpressions.class);
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
fSession.addServiceEventListener(this, null);
|
|
||||||
clearExprChangedData();
|
fExpService = fServicesTracker.getService(IExpressions.class);
|
||||||
|
fSession.addServiceEventListener(MIExpressionsTest.this, null);
|
||||||
|
clearExprChangedData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void shutdown() {
|
public void shutdown() throws Exception {
|
||||||
fSession.removeServiceEventListener(this);
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fSession.removeServiceEventListener(MIExpressionsTest.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
fExpService = null;
|
fExpService = null;
|
||||||
fServicesTracker.dispose();
|
fServicesTracker.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,33 +94,43 @@ public class MIMemoryTest extends BaseTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void testCaseInitialization() throws Throwable {
|
public void testCaseInitialization() throws Throwable {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
|
fMemoryDmc = (IMemoryDMContext)SyncUtil.getContainerContext();
|
||||||
|
assert(fMemoryDmc != null);
|
||||||
|
|
||||||
// Get a reference to the memory service
|
Runnable runnable = new Runnable() {
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
public void run() {
|
||||||
assert(fServicesTracker != null);
|
// Get a reference to the memory service
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
assert(fServicesTracker != null);
|
||||||
|
|
||||||
fMemoryDmc = (IMemoryDMContext)SyncUtil.getContainerContext();
|
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
||||||
assert(fMemoryDmc != null);
|
assert(fRunControl != null);
|
||||||
|
|
||||||
fRunControl = fServicesTracker.getService(MIRunControl.class);
|
|
||||||
assert(fRunControl != null);
|
|
||||||
|
|
||||||
fMemoryService = fServicesTracker.getService(IMemory.class);
|
fMemoryService = fServicesTracker.getService(IMemory.class);
|
||||||
assert(fMemoryService != null);
|
assert(fMemoryService != null);
|
||||||
|
|
||||||
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
fExpressionService = fServicesTracker.getService(IExpressions.class);
|
||||||
assert(fExpressionService != null);
|
assert(fExpressionService != null);
|
||||||
|
|
||||||
fSession.addServiceEventListener(MIMemoryTest.this, null);
|
fSession.addServiceEventListener(MIMemoryTest.this, null);
|
||||||
fBaseAddress = null;
|
fBaseAddress = null;
|
||||||
clearEventCounters();
|
clearEventCounters();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void testCaseCleanup() {
|
public void testCaseCleanup() throws Exception {
|
||||||
// Clear the references (not strictly necessary)
|
// Clear the references (not strictly necessary)
|
||||||
fBaseAddress = null;
|
Runnable runnable = new Runnable() {
|
||||||
fSession.removeServiceEventListener(MIMemoryTest.this);
|
public void run() {
|
||||||
|
fSession.removeServiceEventListener(MIMemoryTest.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
|
|
||||||
|
fBaseAddress = null;
|
||||||
fExpressionService = null;
|
fExpressionService = null;
|
||||||
fMemoryService = null;
|
fMemoryService = null;
|
||||||
fRunControl = null;
|
fRunControl = null;
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -28,10 +28,10 @@ import org.eclipse.cdt.dsf.datamodel.CompositeDMContext;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMData;
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext;
|
||||||
|
@ -95,18 +95,23 @@ public class MIRegistersTest extends BaseTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
// We obtain the services we need after the new
|
|
||||||
// launch has been performed
|
Runnable runnable = new Runnable() {
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
public void run() {
|
||||||
|
// We obtain the services we need after the new
|
||||||
|
// launch has been performed
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
|
||||||
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
||||||
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
||||||
IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
||||||
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
||||||
|
|
||||||
|
fRegService = fServicesTracker.getService(IRegisters.class);
|
||||||
fRegService = fServicesTracker.getService(IRegisters.class);
|
fRunControl = fServicesTracker.getService(IRunControl.class);
|
||||||
fRunControl = fServicesTracker.getService(IRunControl.class);
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.dsf.mi.service.MIRunControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
||||||
|
@ -99,18 +100,25 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
fServicesTracker =
|
final DsfSession session = getGDBLaunch().getSession();
|
||||||
new DsfServicesTracker(TestsPlugin.getBundleContext(),
|
|
||||||
getGDBLaunch().getSession().getId());
|
Runnable runnable = new Runnable() {
|
||||||
fGDBCtrl = fServicesTracker.getService(IGDBControl.class);
|
public void run() {
|
||||||
|
fServicesTracker =
|
||||||
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
new DsfServicesTracker(TestsPlugin.getBundleContext(),
|
||||||
IProcessDMContext procDmc = procService.createProcessContext(fGDBCtrl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
session.getId());
|
||||||
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
fGDBCtrl = fServicesTracker.getService(IGDBControl.class);
|
||||||
IThreadDMContext threadDmc = procService.createThreadContext(procDmc, "1");
|
|
||||||
fThreadExecDmc = procService.createExecutionContext(fContainerDmc, threadDmc, "1");
|
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
||||||
|
IProcessDMContext procDmc = procService.createProcessContext(fGDBCtrl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
||||||
fRunCtrl = fServicesTracker.getService(IMIRunControl.class);
|
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
||||||
|
IThreadDMContext threadDmc = procService.createThreadContext(procDmc, "1");
|
||||||
|
fThreadExecDmc = procService.createExecutionContext(fContainerDmc, threadDmc, "1");
|
||||||
|
|
||||||
|
fRunCtrl = fServicesTracker.getService(IMIRunControl.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
session.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,30 +119,40 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initialTest() throws Throwable {
|
public void initialTest() throws Exception {
|
||||||
fSession = getGDBLaunch().getSession();
|
fSession = getGDBLaunch().getSession();
|
||||||
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
|
||||||
|
|
||||||
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
|
||||||
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
|
||||||
assert(fBreakpointsDmc != null);
|
assert(fBreakpointsDmc != null);
|
||||||
|
|
||||||
// fTraceTargetDmc = (ITraceTargetDMContext)commandControl.getContext();
|
// fTraceTargetDmc = (ITraceTargetDMContext)commandControl.getContext();
|
||||||
|
|
||||||
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
|
||||||
// fTraceService = fServicesTracker.getService(ITraceControl.class);
|
// fTraceService = fServicesTracker.getService(ITraceControl.class);
|
||||||
fSession.addServiceEventListener(this, null);
|
fSession.addServiceEventListener(GDBRemoteTracepointsTest_7_0.this, null);
|
||||||
|
|
||||||
// Create a large array to make sure we don't run out
|
// Create a large array to make sure we don't run out
|
||||||
fTracepoints = new IBreakpointDMContext[100];
|
fTracepoints = new IBreakpointDMContext[100];
|
||||||
|
|
||||||
// Run an initial test to check that everything is ok with GDB
|
// Run an initial test to check that everything is ok with GDB
|
||||||
checkTraceInitialStatus();
|
checkTraceInitialStatus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void shutdown() {
|
public void shutdown() throws Exception {
|
||||||
fSession.removeServiceEventListener(this);
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fSession.removeServiceEventListener(GDBRemoteTracepointsTest_7_0.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fSession.getExecutor().submit(runnable).get();
|
||||||
fBreakpointService = null;
|
fBreakpointService = null;
|
||||||
fServicesTracker.dispose();
|
fServicesTracker.dispose();
|
||||||
}
|
}
|
||||||
|
@ -604,7 +614,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
* by the @Before method; this allows to verify every launch of GDB.
|
* by the @Before method; this allows to verify every launch of GDB.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void checkTraceInitialStatus() throws Throwable {
|
public void checkTraceInitialStatus() {
|
||||||
// checkTraceStatus(true, false, 0);
|
// checkTraceStatus(true, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue