1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 242234 The JUnit tests made use of GDBControl in a hard-coded fashion. This patch replaces uses by ICommandControlService or IGDBControl

This commit is contained in:
Marc Khouzam 2008-09-10 18:49:32 +00:00
parent 49b922013a
commit 57fde8187e
8 changed files with 61 additions and 55 deletions

View file

@ -38,7 +38,6 @@ import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.mi.service.ClassAccessor.MIExpressionDMCAccessor;
import org.eclipse.dd.mi.service.command.events.MIStoppedEvent;
import org.eclipse.dd.tests.gdb.framework.AsyncCompletionWaitor;
@ -60,8 +59,6 @@ public class ExpressionServiceTest extends BaseTestCase {
private DsfServicesTracker fServicesTracker;
private GDBControl fGdbControl;
private IExpressions fExpService;
private int fExprChangedEventCount = 0;
@ -83,7 +80,6 @@ public class ExpressionServiceTest extends BaseTestCase {
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
fExpService = fServicesTracker.getService(IExpressions.class);
fGdbControl = fServicesTracker.getService(GDBControl.class);
fSession.addServiceEventListener(this, null);
clearExprChangedData();
}
@ -2874,11 +2870,13 @@ public class ExpressionServiceTest extends BaseTestCase {
assertTrue(wait.getMessage(), wait.isOK());
IExpressionDMAddress addr = (IExpressionDMAddress)wait.getReturnInfo();
assertTrue("Unable to get address", addr != null);
assertTrue("Received wrong address of " + addr.toString() + " instead of (" +
actualAddrStr + ", " + actualAddrSize + ")",
addressesEqual(addr, actualAddrStr, actualAddrSize));
if (addr != null) {
assertTrue("Received wrong address of " + addr.toString() + " instead of (" +
actualAddrStr + ", " + actualAddrSize + ")",
addressesEqual(addr, actualAddrStr, actualAddrSize));
}
}
private void doTestChildren(MIStoppedEvent stoppedEvent) throws Throwable {

View file

@ -26,7 +26,7 @@ import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.IGDBControl;
import org.eclipse.dd.mi.service.MIProcesses;
import org.eclipse.dd.tests.gdb.framework.AsyncCompletionWaitor;
import org.eclipse.dd.tests.gdb.framework.BaseTestCase;
@ -51,7 +51,7 @@ public class GDBProcessesTest extends BaseTestCase {
private DsfSession fSession;
private DsfServicesTracker fServicesTracker;
private GDBControl fGdbCtrl;
private IGDBControl fGdbCtrl;
private MIProcesses fProcService;
/*
@ -68,7 +68,7 @@ public class GDBProcessesTest extends BaseTestCase {
* Get the GDBProcesses & MIRunControl service.
*/
fProcService = fServicesTracker.getService(MIProcesses.class);
fGdbCtrl = fServicesTracker.getService(GDBControl.class);
fGdbCtrl = fServicesTracker.getService(IGDBControl.class);
}
@After
@ -113,7 +113,7 @@ public class GDBProcessesTest extends BaseTestCase {
@Override
protected void handleSuccess() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGdbCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGdbCtrl.getContext(), pid);
fProcService.getExecutionData(procDmc, rm);
}
});
@ -164,7 +164,7 @@ public class GDBProcessesTest extends BaseTestCase {
fProcService.getExecutor().submit(new Runnable() {
public void run() {
String groupId = fProcService.getExecutionGroupIdFromThread(THREAD_ID);
IProcessDMContext procDmc = fProcService.createProcessContext(fGdbCtrl.getGDBDMContext(), groupId);
IProcessDMContext procDmc = fProcService.createProcessContext(fGdbCtrl.getContext(), groupId);
IThreadDMContext threadDmc = fProcService.createThreadContext(procDmc, THREAD_ID);
fProcService.getExecutionData(threadDmc, rm);
}

View file

@ -35,10 +35,10 @@ import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext;
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.mi.service.MIBreakpointDMData;
import org.eclipse.dd.mi.service.MIBreakpoints;
@ -178,8 +178,8 @@ public class MIBreakpointsTest extends BaseTestCase {
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
assert(fServicesTracker != null);
GDBControl gdbControl = fServicesTracker.getService(GDBControl.class);
fGdbControlDmc = gdbControl.getGDBDMContext();
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
fGdbControlDmc = (GDBControlDMContext)commandControl.getContext();
assert(fGdbControlDmc != null);
fRunControl = fServicesTracker.getService(MIRunControl.class);

View file

@ -29,9 +29,9 @@ import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext;
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.mi.service.MIDisassembly;
import org.eclipse.dd.mi.service.command.events.MIStoppedEvent;
@ -96,8 +96,8 @@ public class MIDisassemblyTest extends BaseTestCase {
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
assert(fServicesTracker != null);
GDBControl gdbControl = fServicesTracker.getService(GDBControl.class);
fGdbControlDmc = gdbControl.getGDBDMContext();
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
fGdbControlDmc = (GDBControlDMContext)commandControl.getContext();
assert(fGdbControlDmc != null);
fDisassembly = fServicesTracker.getService(MIDisassembly.class);

View file

@ -29,10 +29,10 @@ 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.IRunControl.StepType;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.mi.service.MIRunControl;
import org.eclipse.dd.mi.service.command.events.MIStoppedEvent;
@ -101,8 +101,8 @@ public class MIMemoryTest extends BaseTestCase {
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
assert(fServicesTracker != null);
GDBControl gdbControl = fServicesTracker.getService(GDBControl.class);
fGdbControlDmc = gdbControl.getGDBDMContext();
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
fGdbControlDmc = (GDBControlDMContext)commandControl.getContext();
assert(fGdbControlDmc != null);
fRunControl = fServicesTracker.getService(MIRunControl.class);

View file

@ -26,9 +26,9 @@ import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterGroupDMData;
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.mi.service.command.events.MIStoppedEvent;
import org.eclipse.dd.tests.gdb.framework.AsyncCompletionWaitor;
@ -73,8 +73,8 @@ public class MIRegistersTest extends BaseTestCase {
// launch has been performed
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
GDBControl gdbControl = fServicesTracker.getService(GDBControl.class);
fGdbControlDmc = gdbControl.getGDBDMContext();
ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
fGdbControlDmc = (GDBControlDMContext)commandControl.getContext();
fRegService = fServicesTracker.getService(IRegisters.class);
}

View file

@ -24,7 +24,8 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IStartedDMEvent;
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.dd.dsf.debug.service.IRunControl.StepType;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.gdb.internal.provisional.service.command.IGDBControl;
import org.eclipse.dd.mi.service.IMIExecutionDMContext;
import org.eclipse.dd.mi.service.IMIProcesses;
import org.eclipse.dd.mi.service.MIRunControl;
@ -50,10 +51,12 @@ public class MIRunControlTest extends BaseTestCase {
private DsfServicesTracker fServicesTracker;
private GDBControl fGDBCtrl;
private IGDBControl fGDBCtrl;
private MIRunControl fRunCtrl;
private IMIProcesses fProcService;
private GDBControlDMContext fGdbControlDmc;
/*
* Path to executable
*/
@ -69,7 +72,8 @@ public class MIRunControlTest extends BaseTestCase {
fServicesTracker =
new DsfServicesTracker(TestsPlugin.getBundleContext(),
getGDBLaunch().getSession().getId());
fGDBCtrl = fServicesTracker.getService(GDBControl.class);
fGDBCtrl = fServicesTracker.getService(IGDBControl.class);
fGdbControlDmc = (GDBControlDMContext)fGDBCtrl.getContext();
fRunCtrl = fServicesTracker.getService(MIRunControl.class);
fProcService = fServicesTracker.getService(IMIProcesses.class);
}
@ -116,7 +120,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleSuccess() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
fRunCtrl.getExecutionContexts(groupDmc, rm);
}
@ -178,7 +182,7 @@ public class MIRunControlTest extends BaseTestCase {
/*
* Run till line for 2 threads to be created
*/
SyncUtil.SyncRunToLine(fGDBCtrl.getGDBDMContext(), SOURCE_NAME, "22", true);
SyncUtil.SyncRunToLine(fGdbControlDmc, SOURCE_NAME, "22", true);
}
catch(Throwable t){
Assert.fail("Exception in SyncUtil.SyncRunToLine: " + t.getMessage());
@ -208,7 +212,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleSuccess() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
fRunCtrl.getExecutionContexts(groupDmc, rmExecutionCtxts);
}
@ -266,7 +270,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleSuccess() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
fRunCtrl.getExecutionData(fRunCtrl.createMIExecutionContext(groupDmc, 1), rm);
}
@ -395,7 +399,7 @@ public class MIRunControlTest extends BaseTestCase {
fRunCtrl.getExecutor().submit(new Runnable() {
public void run() {
fRunCtrl.getExecutionData(fGDBCtrl.getGDBDMContext(), rm);
fRunCtrl.getExecutionData(fGdbControlDmc, rm);
}
});
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
@ -435,7 +439,7 @@ public class MIRunControlTest extends BaseTestCase {
fRunCtrl.getExecutor().submit(new Runnable() {
public void run() {
// Pass an invalid dmc
fRunCtrl.getExecutionContexts(fGDBCtrl.getGDBDMContext(), rm);
fRunCtrl.getExecutionContexts(fGdbControlDmc, rm);
}
});
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
@ -491,7 +495,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleSuccess() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
fRunCtrl.resume(groupDmc, rm);
}
@ -517,7 +521,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleCompleted() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
wait.setReturnInfo(fRunCtrl.isSuspended(groupDmc));
@ -555,7 +559,7 @@ public class MIRunControlTest extends BaseTestCase {
fRunCtrl.getExecutor().submit(new Runnable() {
public void run() {
fRunCtrl.resume(fGDBCtrl.getGDBDMContext(), rm);
fRunCtrl.resume(fGdbControlDmc, rm);
}
});
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
@ -578,7 +582,7 @@ public class MIRunControlTest extends BaseTestCase {
@Override
protected void handleCompleted() {
String pid = getData();
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getGDBDMContext(), pid);
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
IContainerDMContext groupDmc = fProcService.createExecutionGroupContext(procDmc, pid);
wait.setReturnInfo(fRunCtrl.isSuspended(groupDmc));

View file

@ -30,9 +30,10 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl.StepType;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext;
import org.eclipse.dd.mi.service.IMIExecutionDMContext;
import org.eclipse.dd.mi.service.MIRunControl;
import org.eclipse.dd.mi.service.MIStack;
@ -53,12 +54,14 @@ import org.eclipse.dd.tests.gdb.launching.TestsPlugin;
public class SyncUtil {
private static GDBControl fGDBControl;
private static ICommandControlService fCommandControl;
private static MIRunControl fRunControl;
private static MIStack fStack;
private static IExpressions fExpressions;
private static DsfSession fSession;
private static GDBControlDMContext fGdbControlDmc;
// Initialize some common things, once the session has been established
public static void initialize(DsfSession session) {
fSession = session;
@ -67,7 +70,8 @@ public class SyncUtil {
new DsfServicesTracker(TestsPlugin.getBundleContext(),
fSession.getId());
fGDBControl = tracker.getService(GDBControl.class);
fCommandControl = tracker.getService(ICommandControlService.class);
fGdbControlDmc = (GDBControlDMContext)fCommandControl.getContext();
fRunControl = tracker.getService(MIRunControl.class);
fStack = tracker.getService(MIStack.class);
fExpressions = tracker.getService(IExpressions.class);
@ -84,7 +88,7 @@ public class SyncUtil {
}
public static MIStoppedEvent SyncStep(final StepType stepType) throws Throwable {
return SyncStep(fGDBControl.getGDBDMContext(), stepType);
return SyncStep(fGdbControlDmc, stepType);
}
public static MIStoppedEvent SyncStep(final IExecutionDMContext dmc, final StepType stepType) throws Throwable {
@ -100,13 +104,13 @@ public class SyncUtil {
// ServiceEvent telling us the program has been suspended again
switch(stepType) {
case STEP_INTO:
fGDBControl.queueCommand(new MIExecStep(dmc), null);
fCommandControl.queueCommand(new MIExecStep(dmc), null);
break;
case STEP_OVER:
fGDBControl.queueCommand(new MIExecNext(dmc), null);
fCommandControl.queueCommand(new MIExecNext(dmc), null);
break;
case STEP_RETURN:
fGDBControl.queueCommand(new MIExecFinish(fStack.createFrameDMContext(dmc, 0)), null);
fCommandControl.queueCommand(new MIExecFinish(fStack.createFrameDMContext(dmc, 0)), null);
break;
default:
Assert.assertTrue("Unsupported step type; " + stepType.toString(), false);
@ -131,7 +135,7 @@ public class SyncUtil {
// No need for a RequestMonitor since we will wait for the
// ServiceEvent telling us the program has been suspended again
fGDBControl.queueCommand(
fCommandControl.queueCommand(
new MIExecUntil(dmc, fileName + ":" + lineNo), //$NON-NLS-1$
null);
}
@ -143,11 +147,11 @@ public class SyncUtil {
public static MIStoppedEvent SyncRunToLine(final String fileName, final String lineNo,
final boolean skipBreakpoints) throws Throwable {
return SyncRunToLine(fGDBControl.getGDBDMContext(), fileName, lineNo, skipBreakpoints);
return SyncRunToLine(fGdbControlDmc, fileName, lineNo, skipBreakpoints);
}
public static MIStoppedEvent SyncRunToLine(final String fileName, final String lineNo) throws Throwable {
return SyncRunToLine(fGDBControl.getGDBDMContext(), fileName, lineNo, false);
return SyncRunToLine(fGdbControlDmc, fileName, lineNo, false);
}
@ -172,8 +176,8 @@ public class SyncUtil {
}
};
fGDBControl.queueCommand(
new MIBreakInsert(fGDBControl.getGDBDMContext(), temporary, false, null, 0, location, 0),
fCommandControl.queueCommand(
new MIBreakInsert(fGdbControlDmc, temporary, false, null, 0, location, 0),
addBreakDone);
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
@ -198,7 +202,7 @@ public class SyncUtil {
}
};
fGDBControl.queueCommand(new MIBreakList(fGDBControl.getGDBDMContext()), listDRM);
fCommandControl.queueCommand(new MIBreakList(fGdbControlDmc), listDRM);
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
assertTrue(wait.getMessage(), wait.isOK());
@ -231,8 +235,8 @@ public class SyncUtil {
}
};
fGDBControl.queueCommand(
new MIBreakDelete(fGDBControl.getGDBDMContext(), breakpointIndices), //$NON-NLS-1$
fCommandControl.queueCommand(
new MIBreakDelete(fGdbControlDmc, breakpointIndices), //$NON-NLS-1$
deleteBreakDone);
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
@ -250,7 +254,7 @@ public class SyncUtil {
public void run() {
// No need for a RequestMonitor since we will wait for the
// ServiceEvent telling us the program has been suspended again
fGDBControl.queueCommand(
fCommandControl.queueCommand(
new MIExecContinue(dmc),
null);
}
@ -261,7 +265,7 @@ public class SyncUtil {
}
public static MIStoppedEvent SyncResumeUntilStopped() throws Throwable {
return SyncResumeUntilStopped(fGDBControl.getGDBDMContext());
return SyncResumeUntilStopped(fGdbControlDmc);
}
public static MIStoppedEvent SyncRunToLocation(final String location) throws Throwable {