|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2010 Ericsson and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Ericsson AB - Initial implementation of Test cases |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.cdt.tests.dsf.gdb.tests; |
| 12 |
|
| 13 |
|
| 14 |
import static org.junit.Assert.fail; |
| 15 |
|
| 16 |
import java.util.concurrent.ExecutionException; |
| 17 |
import java.util.concurrent.TimeUnit; |
| 18 |
import java.util.concurrent.TimeoutException; |
| 19 |
|
| 20 |
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; |
| 21 |
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; |
| 22 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
| 23 |
import org.eclipse.cdt.dsf.concurrent.Query; |
| 24 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
| 25 |
import org.eclipse.cdt.dsf.concurrent.Sequence.Step; |
| 26 |
import org.eclipse.cdt.dsf.datamodel.DMContexts; |
| 27 |
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; |
| 28 |
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; |
| 29 |
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; |
| 30 |
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; |
| 31 |
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; |
| 32 |
import org.eclipse.cdt.dsf.mi.service.IMIProcesses; |
| 33 |
import org.eclipse.cdt.dsf.mi.service.IMIRunControl; |
| 34 |
import org.eclipse.cdt.dsf.mi.service.MIProcesses; |
| 35 |
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; |
| 36 |
import org.eclipse.cdt.dsf.service.DsfServicesTracker; |
| 37 |
import org.eclipse.cdt.dsf.service.DsfSession; |
| 38 |
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; |
| 39 |
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; |
| 40 |
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor; |
| 41 |
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; |
| 42 |
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; |
| 43 |
import org.junit.After; |
| 44 |
import org.junit.Assert; |
| 45 |
import org.junit.Before; |
| 46 |
import org.junit.BeforeClass; |
| 47 |
import org.junit.Test; |
| 48 |
import org.junit.runner.RunWith; |
| 49 |
|
| 50 |
|
| 51 |
/** |
| 52 |
* Tests MIRunControl class for for the execWhileTargetAvailable() method. |
| 53 |
*/ |
| 54 |
@RunWith(BackgroundRunner.class) |
| 55 |
public class MIRunControlTargetAvailableTest extends BaseTestCase { |
| 56 |
|
| 57 |
private static final String TIMEOUT_MESSAGE = "Timeout"; |
| 58 |
|
| 59 |
private DsfServicesTracker fServicesTracker; |
| 60 |
|
| 61 |
private IGDBControl fGDBCtrl; |
| 62 |
private IMIRunControl fRunCtrl; |
| 63 |
|
| 64 |
private IContainerDMContext fContainerDmc; |
| 65 |
|
| 66 |
/* |
| 67 |
* Path to executable |
| 68 |
*/ |
| 69 |
private static final String EXEC_PATH = "data/launch/bin/"; |
| 70 |
/* |
| 71 |
* Name of the executable |
| 72 |
*/ |
| 73 |
private static final String EXEC_NAME = "TargetAvail.exe"; |
| 74 |
private static final String SOURCE_NAME = "TargetAvail.cc"; |
| 75 |
|
| 76 |
@Before |
| 77 |
public void init() throws Exception { |
| 78 |
final DsfSession session = getGDBLaunch().getSession(); |
| 79 |
|
| 80 |
Runnable runnable = new Runnable() { |
| 81 |
public void run() { |
| 82 |
fServicesTracker = |
| 83 |
new DsfServicesTracker(TestsPlugin.getBundleContext(), |
| 84 |
session.getId()); |
| 85 |
fGDBCtrl = fServicesTracker.getService(IGDBControl.class); |
| 86 |
|
| 87 |
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class); |
| 88 |
IProcessDMContext procDmc = procService.createProcessContext(fGDBCtrl.getContext(), MIProcesses.UNIQUE_GROUP_ID); |
| 89 |
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID); |
| 90 |
|
| 91 |
fRunCtrl = fServicesTracker.getService(IMIRunControl.class); |
| 92 |
} |
| 93 |
}; |
| 94 |
session.getExecutor().submit(runnable).get(); |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
@After |
| 99 |
public void tearDown() { |
| 100 |
fServicesTracker.dispose(); |
| 101 |
} |
| 102 |
|
| 103 |
@BeforeClass |
| 104 |
public static void beforeClassMethod() { |
| 105 |
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, |
| 106 |
EXEC_PATH + EXEC_NAME); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Test that the executeWhileTargetAvailale interface works properly |
| 111 |
* for a single operation with a single step when the target is stopped. |
| 112 |
*/ |
| 113 |
@Test |
| 114 |
public void executeSingleStepSingleOpWhileTargetStopped() throws Throwable { |
| 115 |
// The target is currently stopped. |
| 116 |
|
| 117 |
// A single step that will set a breakpoint at PrintHello, which we will then make sure hits |
| 118 |
final Step[] steps = new Step[] { |
| 119 |
new Step() { |
| 120 |
@Override |
| 121 |
public void execute(RequestMonitor rm) { |
| 122 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 123 |
|
| 124 |
fGDBCtrl.queueCommand( |
| 125 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 126 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 127 |
}} |
| 128 |
}; |
| 129 |
|
| 130 |
Query<Boolean> query = new Query<Boolean>() { |
| 131 |
@Override |
| 132 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 133 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 134 |
} |
| 135 |
}; |
| 136 |
try { |
| 137 |
fRunCtrl.getExecutor().execute(query); |
| 138 |
query.get(500, TimeUnit.MILLISECONDS); |
| 139 |
} catch (InterruptedException e) { |
| 140 |
fail(e.getMessage()); |
| 141 |
} catch (ExecutionException e) { |
| 142 |
fail(e.getCause().getMessage()); |
| 143 |
} catch (TimeoutException e) { |
| 144 |
fail(TIMEOUT_MESSAGE); |
| 145 |
} |
| 146 |
|
| 147 |
// Now resume the target and check that we stop at the breakpoint. |
| 148 |
|
| 149 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 150 |
getGDBLaunch().getSession(), |
| 151 |
ISuspendedDMEvent.class); |
| 152 |
|
| 153 |
SyncUtil.resume(); |
| 154 |
|
| 155 |
// Wait up to 3 second for the target to suspend. Should happen within 2 second. |
| 156 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* Test that the executeWhileTargetAvailale interface works properly |
| 161 |
* for a single operation with a single step when the target is running. |
| 162 |
*/ |
| 163 |
@Test |
| 164 |
public void executeSingleStepSingleOpWhileTargetRunning() throws Throwable { |
| 165 |
// A single step that will set a breakpoint at PrintHello, which we will then make sure hits |
| 166 |
final Step[] steps = new Step[] { |
| 167 |
new Step() { |
| 168 |
@Override |
| 169 |
public void execute(RequestMonitor rm) { |
| 170 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 171 |
|
| 172 |
fGDBCtrl.queueCommand( |
| 173 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 174 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 175 |
}} |
| 176 |
}; |
| 177 |
|
| 178 |
// The target is currently stopped so we resume it |
| 179 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 180 |
getGDBLaunch().getSession(), |
| 181 |
ISuspendedDMEvent.class); |
| 182 |
|
| 183 |
SyncUtil.resume(); |
| 184 |
|
| 185 |
Query<Boolean> query = new Query<Boolean>() { |
| 186 |
@Override |
| 187 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 188 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 189 |
} |
| 190 |
}; |
| 191 |
try { |
| 192 |
fRunCtrl.getExecutor().execute(query); |
| 193 |
query.get(500, TimeUnit.MILLISECONDS); |
| 194 |
} catch (InterruptedException e) { |
| 195 |
fail(e.getMessage()); |
| 196 |
} catch (ExecutionException e) { |
| 197 |
fail(e.getCause().getMessage()); |
| 198 |
} catch (TimeoutException e) { |
| 199 |
fail(TIMEOUT_MESSAGE); |
| 200 |
} |
| 201 |
|
| 202 |
// Now check that the target is stopped at the breakpoint. |
| 203 |
// Wait up to 3 second for the target to suspend. Should happen at most in 2 seconds. |
| 204 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* Test that the executeWhileTargetAvailale interface works properly |
| 209 |
* for a single operation with multiple steps when the target is stopped. |
| 210 |
*/ |
| 211 |
@Test |
| 212 |
public void executeMultiStepSingleOpWhileTargetStopped() throws Throwable { |
| 213 |
// The target is currently stopped. |
| 214 |
|
| 215 |
// Multiple steps that will set three temp breakpoints at three different lines |
| 216 |
// We then check that the target will stop three times |
| 217 |
final Step[] steps = new Step[] { |
| 218 |
new Step() { |
| 219 |
@Override |
| 220 |
public void execute(RequestMonitor rm) { |
| 221 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 222 |
|
| 223 |
fGDBCtrl.queueCommand( |
| 224 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 225 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 226 |
}}, |
| 227 |
new Step() { |
| 228 |
@Override |
| 229 |
public void execute(RequestMonitor rm) { |
| 230 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 231 |
|
| 232 |
fGDBCtrl.queueCommand( |
| 233 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHi", 0), |
| 234 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 235 |
}}, |
| 236 |
new Step() { |
| 237 |
@Override |
| 238 |
public void execute(RequestMonitor rm) { |
| 239 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 240 |
|
| 241 |
fGDBCtrl.queueCommand( |
| 242 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintBonjour", 0), |
| 243 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 244 |
}} |
| 245 |
}; |
| 246 |
|
| 247 |
Query<Boolean> query = new Query<Boolean>() { |
| 248 |
@Override |
| 249 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 250 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 251 |
} |
| 252 |
}; |
| 253 |
try { |
| 254 |
fRunCtrl.getExecutor().execute(query); |
| 255 |
query.get(500, TimeUnit.MILLISECONDS); |
| 256 |
} catch (InterruptedException e) { |
| 257 |
fail(e.getMessage()); |
| 258 |
} catch (ExecutionException e) { |
| 259 |
fail(e.getCause().getMessage()); |
| 260 |
} catch (TimeoutException e) { |
| 261 |
fail(TIMEOUT_MESSAGE); |
| 262 |
} |
| 263 |
|
| 264 |
// Now resume the target three times and check that we stop three times. |
| 265 |
for (int i=0; i<steps.length; i++) { |
| 266 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 267 |
getGDBLaunch().getSession(), |
| 268 |
ISuspendedDMEvent.class); |
| 269 |
|
| 270 |
SyncUtil.resume(); |
| 271 |
|
| 272 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 273 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
/** |
| 278 |
* Test that the executeWhileTargetAvailale interface works properly |
| 279 |
* for a single operation with multiple steps when the target is stopped |
| 280 |
* and one of the steps fails. |
| 281 |
*/ |
| 282 |
@Test |
| 283 |
public void executeMultiStepSingleOpWhileTargetStoppedWithError() throws Throwable { |
| 284 |
// The target is currently stopped. |
| 285 |
|
| 286 |
// Multiple steps that will set three temp breakpoints at three different lines |
| 287 |
// We then check that the target will stop three times |
| 288 |
final Step[] steps = new Step[] { |
| 289 |
new Step() { |
| 290 |
@Override |
| 291 |
public void execute(RequestMonitor rm) { |
| 292 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 293 |
|
| 294 |
fGDBCtrl.queueCommand( |
| 295 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 296 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 297 |
}}, |
| 298 |
new Step() { |
| 299 |
@Override |
| 300 |
public void execute(RequestMonitor rm) { |
| 301 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 302 |
|
| 303 |
fGDBCtrl.queueCommand( |
| 304 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, "invalid condition", 0, "PrintHi", 0), |
| 305 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 306 |
}}, |
| 307 |
new Step() { |
| 308 |
@Override |
| 309 |
public void execute(RequestMonitor rm) { |
| 310 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 311 |
|
| 312 |
fGDBCtrl.queueCommand( |
| 313 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintBonjour", 0), |
| 314 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 315 |
}} |
| 316 |
}; |
| 317 |
|
| 318 |
Query<Boolean> query = new Query<Boolean>() { |
| 319 |
@Override |
| 320 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 321 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 322 |
} |
| 323 |
}; |
| 324 |
try { |
| 325 |
fRunCtrl.getExecutor().execute(query); |
| 326 |
query.get(500, TimeUnit.MILLISECONDS); |
| 327 |
} catch (InterruptedException e) { |
| 328 |
fail(e.getMessage()); |
| 329 |
} catch (ExecutionException e) { |
| 330 |
// We want to detect the error, so this is success |
| 331 |
return; |
| 332 |
} catch (TimeoutException e) { |
| 333 |
fail(TIMEOUT_MESSAGE); |
| 334 |
} |
| 335 |
|
| 336 |
fail("Did not detect the error of the step"); |
| 337 |
} |
| 338 |
|
| 339 |
/** |
| 340 |
* Test that the executeWhileTargetAvailale interface works properly |
| 341 |
* for a single operation with multiple steps when the target is running. |
| 342 |
*/ |
| 343 |
@Test |
| 344 |
public void executeMultiStepSingleOpWhileTargetRunning() throws Throwable { |
| 345 |
// Multiple steps that will set three temp breakpoints at three different lines |
| 346 |
// We then check that the target will stop three times |
| 347 |
final Step[] steps = new Step[] { |
| 348 |
new Step() { |
| 349 |
@Override |
| 350 |
public void execute(RequestMonitor rm) { |
| 351 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 352 |
|
| 353 |
fGDBCtrl.queueCommand( |
| 354 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 355 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 356 |
}}, |
| 357 |
new Step() { |
| 358 |
@Override |
| 359 |
public void execute(RequestMonitor rm) { |
| 360 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 361 |
|
| 362 |
fGDBCtrl.queueCommand( |
| 363 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHi", 0), |
| 364 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 365 |
}}, |
| 366 |
new Step() { |
| 367 |
@Override |
| 368 |
public void execute(RequestMonitor rm) { |
| 369 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 370 |
|
| 371 |
fGDBCtrl.queueCommand( |
| 372 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintBonjour", 0), |
| 373 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 374 |
}} |
| 375 |
}; |
| 376 |
|
| 377 |
// The target is currently stopped so we resume it |
| 378 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 379 |
getGDBLaunch().getSession(), |
| 380 |
ISuspendedDMEvent.class); |
| 381 |
|
| 382 |
SyncUtil.resume(); |
| 383 |
|
| 384 |
Query<Boolean> query = new Query<Boolean>() { |
| 385 |
@Override |
| 386 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 387 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 388 |
} |
| 389 |
}; |
| 390 |
try { |
| 391 |
fRunCtrl.getExecutor().execute(query); |
| 392 |
query.get(500, TimeUnit.MILLISECONDS); |
| 393 |
} catch (InterruptedException e) { |
| 394 |
fail(e.getMessage()); |
| 395 |
} catch (ExecutionException e) { |
| 396 |
fail(e.getCause().getMessage()); |
| 397 |
} catch (TimeoutException e) { |
| 398 |
fail(TIMEOUT_MESSAGE); |
| 399 |
} |
| 400 |
|
| 401 |
// Now resume the target three times and check that we stop three times. |
| 402 |
for (int i=0; i<steps.length; i++) { |
| 403 |
// Wait up to 3 second for the target to suspend. Should happen within two seconds. |
| 404 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 405 |
|
| 406 |
suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 407 |
getGDBLaunch().getSession(), |
| 408 |
ISuspendedDMEvent.class); |
| 409 |
|
| 410 |
SyncUtil.resume(); |
| 411 |
|
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
/** |
| 416 |
* Test that the executeWhileTargetAvailale interface works properly |
| 417 |
* for a single operation with multiple steps when the target is running |
| 418 |
* and one of the steps fails. |
| 419 |
*/ |
| 420 |
@Test |
| 421 |
public void executeMultiStepSingleOpWhileTargetRunningWithError() throws Throwable { |
| 422 |
// Multiple steps that will set three temp breakpoints at three different lines |
| 423 |
// We then check that the target will stop three times |
| 424 |
final Step[] steps = new Step[] { |
| 425 |
new Step() { |
| 426 |
@Override |
| 427 |
public void execute(RequestMonitor rm) { |
| 428 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 429 |
|
| 430 |
fGDBCtrl.queueCommand( |
| 431 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintHello", 0), |
| 432 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 433 |
}}, |
| 434 |
new Step() { |
| 435 |
@Override |
| 436 |
public void execute(RequestMonitor rm) { |
| 437 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 438 |
|
| 439 |
fGDBCtrl.queueCommand( |
| 440 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, "invalid condition", 0, "PrintHi", 0), |
| 441 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 442 |
}}, |
| 443 |
new Step() { |
| 444 |
@Override |
| 445 |
public void execute(RequestMonitor rm) { |
| 446 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 447 |
|
| 448 |
fGDBCtrl.queueCommand( |
| 449 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, "PrintBonjour", 0), |
| 450 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 451 |
}} |
| 452 |
}; |
| 453 |
|
| 454 |
// The target is currently stopped so we resume it |
| 455 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 456 |
getGDBLaunch().getSession(), |
| 457 |
ISuspendedDMEvent.class); |
| 458 |
|
| 459 |
SyncUtil.resume(); |
| 460 |
|
| 461 |
Query<Boolean> query = new Query<Boolean>() { |
| 462 |
@Override |
| 463 |
protected void execute(DataRequestMonitor<Boolean> rm) { |
| 464 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 465 |
} |
| 466 |
}; |
| 467 |
|
| 468 |
boolean caughtError = false; |
| 469 |
try { |
| 470 |
fRunCtrl.getExecutor().execute(query); |
| 471 |
query.get(500, TimeUnit.MILLISECONDS); |
| 472 |
} catch (InterruptedException e) { |
| 473 |
fail(e.getMessage()); |
| 474 |
} catch (ExecutionException e) { |
| 475 |
caughtError = true; |
| 476 |
} catch (TimeoutException e) { |
| 477 |
fail(TIMEOUT_MESSAGE); |
| 478 |
} |
| 479 |
|
| 480 |
Assert.assertTrue("Did not catch the error of the step", caughtError); |
| 481 |
|
| 482 |
// Now make sure the target stop of the first breakpoint |
| 483 |
// Wait up to 3 second for the target to suspend. Should happen within two seconds. |
| 484 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 485 |
} |
| 486 |
|
| 487 |
/** |
| 488 |
* Test that the executeWhileTargetAvailale interface works properly |
| 489 |
* for concurrent operations with a single step when the target is stopped. |
| 490 |
*/ |
| 491 |
@Test |
| 492 |
public void executeSingleStepConcurrentOpWhileTargetStopped() throws Throwable { |
| 493 |
// The target is currently stopped. |
| 494 |
|
| 495 |
final int NUM_CONCURRENT = 3; |
| 496 |
|
| 497 |
String[] locations = { "PrintHello", "PrintHi", "PrintBonjour" }; |
| 498 |
final Step[][] steps = new Step[NUM_CONCURRENT][1]; // one step for each concurrent operation |
| 499 |
for (int i=0; i<steps.length; i++) { |
| 500 |
final String location = locations[i]; |
| 501 |
steps[i] = new Step[] { |
| 502 |
new Step() { |
| 503 |
@Override |
| 504 |
public void execute(RequestMonitor rm) { |
| 505 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 506 |
|
| 507 |
fGDBCtrl.queueCommand( |
| 508 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 509 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 510 |
}} |
| 511 |
}; |
| 512 |
} |
| 513 |
|
| 514 |
Query<Boolean> query = new Query<Boolean>() { |
| 515 |
@Override |
| 516 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 517 |
CountingRequestMonitor crm = new CountingRequestMonitor(fGDBCtrl.getExecutor(), null) { |
| 518 |
@Override |
| 519 |
protected void handleCompleted() { |
| 520 |
rm.done(); |
| 521 |
}; |
| 522 |
}; |
| 523 |
|
| 524 |
|
| 525 |
int index; |
| 526 |
for (index=0; index<steps.length; index++) { |
| 527 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps[index], crm); |
| 528 |
} |
| 529 |
|
| 530 |
crm.setDoneCount(index); |
| 531 |
} |
| 532 |
}; |
| 533 |
try { |
| 534 |
fRunCtrl.getExecutor().execute(query); |
| 535 |
query.get(500, TimeUnit.MILLISECONDS); |
| 536 |
} catch (InterruptedException e) { |
| 537 |
fail(e.getMessage()); |
| 538 |
} catch (ExecutionException e) { |
| 539 |
fail(e.getCause().getMessage()); |
| 540 |
} catch (TimeoutException e) { |
| 541 |
fail(TIMEOUT_MESSAGE); |
| 542 |
} |
| 543 |
|
| 544 |
for (int i=0; i<steps.length; i++) { |
| 545 |
// Now resume the target and check that we stop at all the breakpoints. |
| 546 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 547 |
getGDBLaunch().getSession(), |
| 548 |
ISuspendedDMEvent.class); |
| 549 |
|
| 550 |
SyncUtil.resume(); |
| 551 |
|
| 552 |
// Wait up to 3 second for the target to suspend. Should happen within 2 second. |
| 553 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
/** |
| 558 |
* Test that the executeWhileTargetAvailale interface works properly |
| 559 |
* for concurrent operations with a single step when the target is running. |
| 560 |
*/ |
| 561 |
@Test |
| 562 |
public void executeSingleStepConcurrentOpWhileTargetRunning() throws Throwable { |
| 563 |
final int NUM_CONCURRENT = 3; |
| 564 |
|
| 565 |
String[] locations = { "PrintHello", "PrintHi", "PrintBonjour" }; |
| 566 |
final Step[][] steps = new Step[NUM_CONCURRENT][1]; // one step for each concurrent operation |
| 567 |
for (int i=0; i<steps.length; i++) { |
| 568 |
final String location = locations[i]; |
| 569 |
steps[i] = new Step[] { |
| 570 |
new Step() { |
| 571 |
@Override |
| 572 |
public void execute(RequestMonitor rm) { |
| 573 |
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 574 |
|
| 575 |
fGDBCtrl.queueCommand( |
| 576 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 577 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm)); |
| 578 |
}} |
| 579 |
}; |
| 580 |
} |
| 581 |
|
| 582 |
// The target is currently stopped so we resume it |
| 583 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 584 |
getGDBLaunch().getSession(), |
| 585 |
ISuspendedDMEvent.class); |
| 586 |
|
| 587 |
SyncUtil.resume(); |
| 588 |
|
| 589 |
Query<Boolean> query = new Query<Boolean>() { |
| 590 |
@Override |
| 591 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 592 |
CountingRequestMonitor crm = new CountingRequestMonitor(fGDBCtrl.getExecutor(), null) { |
| 593 |
@Override |
| 594 |
protected void handleCompleted() { |
| 595 |
rm.done(); |
| 596 |
}; |
| 597 |
}; |
| 598 |
|
| 599 |
|
| 600 |
int index; |
| 601 |
for (index=0; index<steps.length; index++) { |
| 602 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps[index], crm); |
| 603 |
} |
| 604 |
|
| 605 |
crm.setDoneCount(index); |
| 606 |
} |
| 607 |
}; |
| 608 |
try { |
| 609 |
fRunCtrl.getExecutor().execute(query); |
| 610 |
query.get(500, TimeUnit.MILLISECONDS); |
| 611 |
} catch (InterruptedException e) { |
| 612 |
fail(e.getMessage()); |
| 613 |
} catch (ExecutionException e) { |
| 614 |
fail(e.getCause().getMessage()); |
| 615 |
} catch (TimeoutException e) { |
| 616 |
fail(TIMEOUT_MESSAGE); |
| 617 |
} |
| 618 |
|
| 619 |
for (int i=0; i<steps.length; i++) { |
| 620 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 621 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 622 |
|
| 623 |
// Now resume the target and check that we stop at all the breakpoints. |
| 624 |
suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 625 |
getGDBLaunch().getSession(), |
| 626 |
ISuspendedDMEvent.class); |
| 627 |
|
| 628 |
SyncUtil.resume(); |
| 629 |
} |
| 630 |
} |
| 631 |
|
| 632 |
/** |
| 633 |
* Test that the executeWhileTargetAvailale interface works properly |
| 634 |
* for concurrent operations with a single step when the target is stopped. |
| 635 |
* This tests verifies that we properly handle concurrent operations that are sent |
| 636 |
* while other operations are already being run. |
| 637 |
*/ |
| 638 |
@Test |
| 639 |
public void executeSingleStepConcurrentButDelayedOpWhileTargetStopped() throws Throwable { |
| 640 |
// The target is currently stopped. |
| 641 |
|
| 642 |
final String location = "PrintHello"; |
| 643 |
final String location2 = "PrintHi"; |
| 644 |
final Step[] steps = new Step[] { |
| 645 |
new Step() { |
| 646 |
@Override |
| 647 |
public void execute(final RequestMonitor rm) { |
| 648 |
final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 649 |
|
| 650 |
fGDBCtrl.queueCommand( |
| 651 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 652 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm) { |
| 653 |
@Override |
| 654 |
protected void handleSuccess() { |
| 655 |
// Now that time has elapsed, send another command |
| 656 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, new Step[] { |
| 657 |
new Step() { |
| 658 |
@Override |
| 659 |
public void execute(final RequestMonitor rm) { |
| 660 |
fGDBCtrl.queueCommand( |
| 661 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location2, 0), |
| 662 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), null)); |
| 663 |
}}}, new RequestMonitor(fGDBCtrl.getExecutor(), null)); |
| 664 |
|
| 665 |
// Complete the first operation because the two are supposed to be independent |
| 666 |
rm.done(); |
| 667 |
}}); |
| 668 |
}} |
| 669 |
}; |
| 670 |
|
| 671 |
Query<Boolean> query = new Query<Boolean>() { |
| 672 |
@Override |
| 673 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 674 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 675 |
} |
| 676 |
}; |
| 677 |
try { |
| 678 |
fRunCtrl.getExecutor().execute(query); |
| 679 |
query.get(500, TimeUnit.MILLISECONDS); |
| 680 |
} catch (InterruptedException e) { |
| 681 |
fail(e.getMessage()); |
| 682 |
} catch (ExecutionException e) { |
| 683 |
fail(e.getCause().getMessage()); |
| 684 |
} catch (TimeoutException e) { |
| 685 |
fail(TIMEOUT_MESSAGE); |
| 686 |
} |
| 687 |
|
| 688 |
for (int i=0; i<2; i++) { |
| 689 |
// The target is currently stopped so we resume it |
| 690 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 691 |
getGDBLaunch().getSession(), |
| 692 |
ISuspendedDMEvent.class); |
| 693 |
|
| 694 |
SyncUtil.resume(); |
| 695 |
|
| 696 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 697 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 698 |
} |
| 699 |
} |
| 700 |
|
| 701 |
/** |
| 702 |
* Test that the executeWhileTargetAvailale interface works properly |
| 703 |
* for concurrent operations with a single step when the target is running. |
| 704 |
* This tests verifies that we properly handle concurrent operations that are sent |
| 705 |
* while other operations are already being run. |
| 706 |
*/ |
| 707 |
@Test |
| 708 |
public void executeSingleStepConcurrentButDelayedOpWhileTargetRunning() throws Throwable { |
| 709 |
final String location = "PrintHello"; |
| 710 |
final String location2 = "PrintHi"; |
| 711 |
final Step[] steps = new Step[] { |
| 712 |
new Step() { |
| 713 |
@Override |
| 714 |
public void execute(final RequestMonitor rm) { |
| 715 |
final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 716 |
|
| 717 |
fGDBCtrl.queueCommand( |
| 718 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 719 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm) { |
| 720 |
@Override |
| 721 |
protected void handleSuccess() { |
| 722 |
// Now that time has elapsed, send another command |
| 723 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, new Step[] { |
| 724 |
new Step() { |
| 725 |
@Override |
| 726 |
public void execute(final RequestMonitor otherRm) { |
| 727 |
fGDBCtrl.queueCommand( |
| 728 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location2, 0), |
| 729 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), otherRm)); |
| 730 |
}}}, new RequestMonitor(fGDBCtrl.getExecutor(), null)); |
| 731 |
|
| 732 |
// Complete the first operation because the two are supposed to be independent |
| 733 |
rm.done(); |
| 734 |
}}); |
| 735 |
}} |
| 736 |
}; |
| 737 |
|
| 738 |
// The target is currently stopped so we resume it |
| 739 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 740 |
getGDBLaunch().getSession(), |
| 741 |
ISuspendedDMEvent.class); |
| 742 |
|
| 743 |
SyncUtil.resume(); |
| 744 |
|
| 745 |
Query<Boolean> query = new Query<Boolean>() { |
| 746 |
@Override |
| 747 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 748 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 749 |
} |
| 750 |
}; |
| 751 |
try { |
| 752 |
fRunCtrl.getExecutor().execute(query); |
| 753 |
query.get(500, TimeUnit.MILLISECONDS); |
| 754 |
} catch (InterruptedException e) { |
| 755 |
fail(e.getMessage()); |
| 756 |
} catch (ExecutionException e) { |
| 757 |
fail(e.getCause().getMessage()); |
| 758 |
} catch (TimeoutException e) { |
| 759 |
fail(TIMEOUT_MESSAGE); |
| 760 |
} |
| 761 |
|
| 762 |
for (int i=0; i<2; i++) { |
| 763 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 764 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 765 |
|
| 766 |
// Now resume the target and check that we stop at all the breakpoints. |
| 767 |
suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 768 |
getGDBLaunch().getSession(), |
| 769 |
ISuspendedDMEvent.class); |
| 770 |
|
| 771 |
SyncUtil.resume(); |
| 772 |
} |
| 773 |
} |
| 774 |
|
| 775 |
/** |
| 776 |
* Test that the executeWhileTargetAvailale interface works properly |
| 777 |
* for concurrent operations with a single step when the target is stopped. |
| 778 |
* This tests verifies that we properly handle concurrent operations that are |
| 779 |
* dependent on each other; this means that the second operation needs to complete |
| 780 |
* for the second one to complete. |
| 781 |
*/ |
| 782 |
@Test |
| 783 |
public void executeSingleStepConcurrentAndDependentOpWhileTargetStopped() throws Throwable { |
| 784 |
// The target is currently stopped. |
| 785 |
|
| 786 |
final String location = "PrintHello"; |
| 787 |
final String location2 = "PrintHi"; |
| 788 |
final Step[] steps = new Step[] { |
| 789 |
new Step() { |
| 790 |
@Override |
| 791 |
public void execute(final RequestMonitor rm) { |
| 792 |
final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 793 |
|
| 794 |
fGDBCtrl.queueCommand( |
| 795 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 796 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm) { |
| 797 |
@Override |
| 798 |
protected void handleSuccess() { |
| 799 |
// Send another such operation and wait for it to complete to mark the original one as completed |
| 800 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, new Step[] { |
| 801 |
new Step() { |
| 802 |
@Override |
| 803 |
public void execute(final RequestMonitor otherRm) { |
| 804 |
fGDBCtrl.queueCommand( |
| 805 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location2, 0), |
| 806 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), otherRm)); |
| 807 |
}}}, rm); |
| 808 |
}}); |
| 809 |
}} |
| 810 |
}; |
| 811 |
|
| 812 |
Query<Boolean> query = new Query<Boolean>() { |
| 813 |
@Override |
| 814 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 815 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 816 |
} |
| 817 |
}; |
| 818 |
try { |
| 819 |
fRunCtrl.getExecutor().execute(query); |
| 820 |
query.get(500, TimeUnit.MILLISECONDS); |
| 821 |
} catch (InterruptedException e) { |
| 822 |
fail(e.getMessage()); |
| 823 |
} catch (ExecutionException e) { |
| 824 |
fail(e.getCause().getMessage()); |
| 825 |
} catch (TimeoutException e) { |
| 826 |
fail(TIMEOUT_MESSAGE); |
| 827 |
} |
| 828 |
|
| 829 |
for (int i=0; i<2; i++) { |
| 830 |
// The target is currently stopped so we resume it |
| 831 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 832 |
getGDBLaunch().getSession(), |
| 833 |
ISuspendedDMEvent.class); |
| 834 |
|
| 835 |
SyncUtil.resume(); |
| 836 |
|
| 837 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 838 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
/** |
| 843 |
* Test that the executeWhileTargetAvailale interface works properly |
| 844 |
* for concurrent operations with a single step when the target is running. |
| 845 |
* This tests verifies that we properly handle concurrent operations that are |
| 846 |
* dependent on each other; this means that the second operation needs to complete |
| 847 |
* for the second one to complete. |
| 848 |
*/ |
| 849 |
@Test |
| 850 |
public void executeSingleStepConcurrentAndDependentOpWhileTargetRunning() throws Throwable { |
| 851 |
final String location = "PrintHello"; |
| 852 |
final String location2 = "PrintHi"; |
| 853 |
final Step[] steps = new Step[] { |
| 854 |
new Step() { |
| 855 |
@Override |
| 856 |
public void execute(final RequestMonitor rm) { |
| 857 |
final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(fContainerDmc, IBreakpointsTargetDMContext.class); |
| 858 |
|
| 859 |
fGDBCtrl.queueCommand( |
| 860 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location, 0), |
| 861 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), rm) { |
| 862 |
@Override |
| 863 |
protected void handleSuccess() { |
| 864 |
// Send another such operation and wait for it to complete to mark the original one as completed |
| 865 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, new Step[] { |
| 866 |
new Step() { |
| 867 |
@Override |
| 868 |
public void execute(final RequestMonitor otherRm) { |
| 869 |
fGDBCtrl.queueCommand( |
| 870 |
fGDBCtrl.getCommandFactory().createMIBreakInsert(bpTargetDmc, true, false, null, 0, location2, 0), |
| 871 |
new DataRequestMonitor<MIBreakInsertInfo> (fGDBCtrl.getExecutor(), otherRm)); |
| 872 |
}}}, rm); |
| 873 |
}}); |
| 874 |
}} |
| 875 |
}; |
| 876 |
|
| 877 |
// The target is currently stopped so we resume it |
| 878 |
ServiceEventWaitor<ISuspendedDMEvent> suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 879 |
getGDBLaunch().getSession(), |
| 880 |
ISuspendedDMEvent.class); |
| 881 |
|
| 882 |
SyncUtil.resume(); |
| 883 |
|
| 884 |
Query<Boolean> query = new Query<Boolean>() { |
| 885 |
@Override |
| 886 |
protected void execute(final DataRequestMonitor<Boolean> rm) { |
| 887 |
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); |
| 888 |
} |
| 889 |
}; |
| 890 |
try { |
| 891 |
fRunCtrl.getExecutor().execute(query); |
| 892 |
query.get(500, TimeUnit.MILLISECONDS); |
| 893 |
} catch (InterruptedException e) { |
| 894 |
fail(e.getMessage()); |
| 895 |
} catch (ExecutionException e) { |
| 896 |
fail(e.getCause().getMessage()); |
| 897 |
} catch (TimeoutException e) { |
| 898 |
fail(TIMEOUT_MESSAGE); |
| 899 |
} |
| 900 |
|
| 901 |
for (int i=0; i<2; i++) { |
| 902 |
// Wait up to 3 second for the target to suspend. Should happen within 2 seconds. |
| 903 |
suspendedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(3000)); |
| 904 |
|
| 905 |
// Now resume the target and check that we stop at all the breakpoints. |
| 906 |
suspendedEventWaitor = new ServiceEventWaitor<ISuspendedDMEvent>( |
| 907 |
getGDBLaunch().getSession(), |
| 908 |
ISuspendedDMEvent.class); |
| 909 |
|
| 910 |
SyncUtil.resume(); |
| 911 |
} |
| 912 |
} |
| 913 |
} |