private String getModelDataForRegisterDataValue( IFrameDMContext frameDmc, String format, int regNo) throws Throwable { final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); final IRegisterDMContext[] regDMCs = getRegisters(frameDmc); final FormattedValueDMContext valueDmc = fRegService.getFormattedValueContext(regDMCs[regNo], format); final DataRequestMonitor<FormattedValueDMData> regRm = new DataRequestMonitor<FormattedValueDMData>(fRegService.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { wait.setReturnInfo(getData()); } wait.waitFinished(getStatus()); } }; fRegService .getExecutor() .submit( new Runnable() { public void run() { fRegService.getFormattedExpressionValue(valueDmc, regRm); } }); wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(wait.getMessage(), wait.isOK()); FormattedValueDMData data = (FormattedValueDMData) wait.getReturnInfo(); return data.getFormattedValue(); }
/* * This is a common support method which gets the Register Group Information * and verifies it. */ private IRegisterGroupDMContext getRegisterGroup() throws Throwable { final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor(); final DataRequestMonitor<IRegisterGroupDMContext[]> regGroupDone = new DataRequestMonitor<IRegisterGroupDMContext[]>(fRegService.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { fWait.setReturnInfo(getData()); } fWait.waitFinished(getStatus()); } }; fRegService .getExecutor() .submit( new Runnable() { public void run() { fRegService.getRegisterGroups(fContainerDmc, regGroupDone); } }); fWait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(fWait.getMessage(), fWait.isOK()); IRegisterGroupDMContext[] regGroupsDMCs = (IRegisterGroupDMContext[]) fWait.getReturnInfo(); assertTrue( "There was more than one register group (" + regGroupsDMCs.length + ")", // $NON-NLS-1$ regGroupsDMCs.length == 1); fWait.waitReset(); return (regGroupsDMCs[0]); }
private void writeRegister( IFrameDMContext frameDmc, final int regIndex, final String regValue, final String formatId) throws Throwable { final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor(); final IRegisterDMContext[] regDMCs = getRegisters(frameDmc); fRegService .getExecutor() .submit( new Runnable() { public void run() { fRegService.writeRegister( regDMCs[regIndex], regValue, formatId, new RequestMonitor(fRegService.getExecutor(), null) { @Override protected void handleCompleted() { fWait.waitFinished(getStatus()); } }); } }); fWait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); fWait.waitReset(); }
private IRegisterDMContext[] getRegisters(final IFrameDMContext frameDmc) throws Throwable { final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor(); final IRegisterGroupDMContext regGroupsDMC = getRegisterGroup(); fRegService .getExecutor() .submit( new Runnable() { public void run() { fRegService.getRegisters( new CompositeDMContext(new IDMContext[] {regGroupsDMC, frameDmc}), new DataRequestMonitor<IRegisterDMContext[]>(fRegService.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { fWait.setReturnInfo(getData()); } fWait.waitFinished(getStatus()); } }); } }); fWait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(fWait.getMessage(), fWait.isOK()); IRegisterDMContext[] regContexts = (IRegisterDMContext[]) fWait.getReturnInfo(); fWait.waitReset(); assertEquals("Wrong number of registers", get_X86_REGS().size(), regContexts.length); return (regContexts); }
@Override protected void doExecute(IRegisters service, final DataRequestMonitor<String> rm) { /* * Convert to the proper formatting DMC then go get the formatted * value. */ FormattedValueDMContext formDmc = service.getFormattedValueContext(fDmc, fFormatId); service.getFormattedExpressionValue( formDmc, new DataRequestMonitor<FormattedValueDMData>(ImmediateExecutor.getInstance(), rm) { @Override protected void handleSuccess() { /* * All good set return value. */ rm.setData(getData().getFormattedValue()); rm.done(); } }); }
@Override protected void doExecute(IRegisters service, final DataRequestMonitor<IRegisterDMData> rm) { service.getRegisterData( fDmc, new DataRequestMonitor<IRegisterDMData>(ImmediateExecutor.getInstance(), rm) { @Override protected void handleSuccess() { /* * All good set return value. */ rm.setData(getData()); rm.done(); } }); }
@Override protected void doExecute(IRegisters service, final DataRequestMonitor<Object> rm) { // Write the bit field using the mnemonic style. service.writeBitField( fDmc, fMnemonic, new DataRequestMonitor<IBitFieldDMData>(ImmediateExecutor.getInstance(), rm) { @Override protected void handleSuccess() { /* * All good set return value. */ rm.setData(new Object()); rm.done(); } }); }
@Override protected void doExecute(IRegisters service, final DataRequestMonitor<IBitFieldDMData> rm) { service.getBitFieldData(fDmc, rm); }
@Override protected void doExecute(IRegisters service, final DataRequestMonitor<String[]> rm) { service.getAvailableFormats(fDmc, rm); }
@Test public void compareRegisterForMultipleExecutionContexts() throws Throwable { // Run past the line that creates a thread and past the sleep that // follows it. This is a bit tricky because the code that creates the // thread is conditional depending on environment. Run to the printf // before it (which is common), then do step operations over the // non-common code (but same number of lines) SyncUtil.runToLine(SRC_NAME, Integer.toString(MIRunControlTest.LINE_MAIN_PRINTF)); SyncUtil.step(StepType.STEP_OVER); // over the printf SyncUtil.step(StepType.STEP_OVER); // over the create-thread call MIStoppedEvent stoppedEvent = SyncUtil.step( StepType.STEP_OVER, TestsPlugin.massageTimeout(2000)); // over the one second sleep // Get the thread IDs final IContainerDMContext containerDmc = DMContexts.getAncestorOfType(stoppedEvent.getDMContext(), IContainerDMContext.class); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); final DataRequestMonitor<IExecutionDMContext[]> drm = new DataRequestMonitor<IExecutionDMContext[]>(fRegService.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { wait.setReturnInfo(getData()); } wait.waitFinished(getStatus()); } }; fRegService .getExecutor() .submit( new Runnable() { public void run() { fRunControl.getExecutionContexts(containerDmc, drm); } }); wait.waitUntilDone(TestsPlugin.massageTimeout(5000)); Assert.assertTrue(wait.getMessage(), wait.isOK()); IExecutionDMContext[] ctxts = (IExecutionDMContext[]) wait.getReturnInfo(); wait.waitReset(); Assert.assertNotNull(ctxts); Assert.assertTrue(ctxts.length > 1); int tid1 = ((IMIExecutionDMContext) ctxts[0]).getThreadId(); int tid2 = ((IMIExecutionDMContext) ctxts[1]).getThreadId(); // Get execution context to thread 2 IExecutionDMContext execDmc = SyncUtil.createExecutionContext(containerDmc, tid2); IFrameDMContext frameDmc2 = SyncUtil.getStackFrame(execDmc, 0); String thread2RegVal0 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 0); String thread2RegVal1 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 1); String thread2RegVal2 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 2); String thread2RegVal3 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 3); String thread2RegVal4 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 4); String thread2RegVal5 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 5); // Get execution context to thread 1 execDmc = SyncUtil.createExecutionContext(containerDmc, tid1); IFrameDMContext frameDmc1 = SyncUtil.getStackFrame(execDmc, 0); getModelDataForRegisterDataValue(frameDmc1, IFormattedValues.NATURAL_FORMAT, 0); // Re-set the execution context to 2 and Fetch from the Cache String dupliThread2RegVal0 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 0); String dupliThread2RegVal1 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 1); String dupliThread2RegVal2 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 2); String dupliThread2RegVal3 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 3); String dupliThread2RegVal4 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 4); String dupliThread2RegVal5 = getModelDataForRegisterDataValue(frameDmc2, IFormattedValues.NATURAL_FORMAT, 5); // If Values not equal , then context haven't been re-set properly assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal0.equals(dupliThread2RegVal0)); assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal1.equals(dupliThread2RegVal1)); assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal2.equals(dupliThread2RegVal2)); assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal3.equals(dupliThread2RegVal3)); assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal4.equals(dupliThread2RegVal4)); assertTrue( "Multiple context not working. Execution Context is not reset to 2", thread2RegVal5.equals(dupliThread2RegVal5)); }