diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java index fb078685198..c6b5f0c0e84 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions; 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.FormattedValueDMData; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; @@ -432,6 +433,26 @@ public class SyncUtil { return fSession.getExecutor().submit(callable).get(); } + public static String getExpressionValue(final IExpressionDMContext exprDmc, final String format) + throws Throwable { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + FormattedValueDMContext valueDmc = fExpressions.getFormattedValueContext(exprDmc, format); + fExpressions.getFormattedExpressionValue(valueDmc, + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().getFormattedValue()); + } + }); + } + }; + + fSession.getExecutor().execute(query); + return query.get(); + } + public static FormattedValueDMContext getFormattedValue( final IFormattedValues service, final IFormattedDataDMContext dmc, final String formatId) throws Throwable { diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleSynchronizingTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleSynchronizingTest_7_6.java index c8299d57783..015ebae46bb 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleSynchronizingTest_7_6.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleSynchronizingTest_7_6.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.dsf.datamodel.IDMEvent; import org.eclipse.cdt.dsf.debug.service.IExpressions; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IMemory; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; @@ -147,14 +148,24 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase { IExpressionDMAddress data = query.get(); IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class); - readMemory(memoryDmc, data.getAddress(), data.getSize()); + readMemory(memoryDmc, data.getAddress(), 1); fEventsReceived.clear(); - queueConsoleCommand("set variable i=100"); + + final String newValue = "100"; + queueConsoleCommand("set variable i=" + newValue); IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class); assertEquals(1, memoryEvent.getAddresses().length); assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]); + + // Now verify the memory service knows the new memory value + MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1); + assertEquals(newValue, Byte.toString(memory[0].getValue())); + + // Now verify the expressions service knows the new value + String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT); + assertEquals(newValue, exprValue); } /** @@ -181,11 +192,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase { IExpressionDMAddress data = query.get(); fEventsReceived.clear(); - queueConsoleCommand("set variable i=100"); + + final String newValue = "100"; + queueConsoleCommand("set variable i=" + newValue); IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class); assertEquals(1, memoryEvent.getAddresses().length); assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]); + + // Now verify the memory service knows the new memory value + IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class); + MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1); + assertEquals(newValue, Byte.toString(memory[0].getValue())); + + // Now verify the expressions service knows the new value + String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT); + assertEquals(newValue, exprValue); } /** @@ -212,11 +234,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase { IExpressionDMAddress data = query.get(); fEventsReceived.clear(); - queueConsoleCommand("print i=100"); + + final String newValue = "100"; + queueConsoleCommand("print i=" + newValue); IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class); assertEquals(1, memoryEvent.getAddresses().length); assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]); + + // Now verify the memory service knows the new memory value + IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class); + MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1); + assertEquals(newValue, Byte.toString(memory[0].getValue())); + + // Now verify the expressions service knows the new value + String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT); + assertEquals(newValue, exprValue); } /** @@ -242,11 +275,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase { IExpressionDMAddress data = query.get(); fEventsReceived.clear(); - queueConsoleCommand("set {int}&i=100"); - + + final String newValue = "100"; + queueConsoleCommand("set {int}&i=" + newValue); + IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class); assertEquals(1, memoryEvent.getAddresses().length); assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]); + + // Now verify the memory service knows the new memory value + IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class); + MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1); + assertEquals(newValue, Byte.toString(memory[0].getValue())); + + // Now verify the expressions service knows the new value + String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT); + assertEquals(newValue, exprValue); } //////////////////////////////////////////////////////////////////////////////////////