diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc index b61a2492043..54b4fec8425 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc @@ -53,11 +53,19 @@ public: }; // For bug 320277 -class Base {}; +class Base { +public: + int nested; + int* pNested; +}; class BaseTest: public Base { public: BaseTest() {} - void test() { return; } + void test() { + nested = 8; + return; + } + Base Base; // make sure we don't get confused by the same name }; // End bug 320277 diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java index e36dfd431eb..54ff65b8142 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java @@ -424,7 +424,7 @@ public class MIExpressionsTest extends BaseTestCase { // First we get 'this' and its children final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "this"); - final IExpressionDMContext[] children = getChildren(exprDmc, new String[] {"Base"}); + final IExpressionDMContext[] children = getChildren(exprDmc, new String[] {"Base", "Base"}); fExpService.getExecutor().submit(new Runnable() { public void run() { @@ -441,6 +441,100 @@ public class MIExpressionsTest extends BaseTestCase { wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(wait.getMessage(), wait.isOK()); + + wait.waitReset(); + + // This second child is testing the fact that we could have the child named + // the same as its type and we still want to be able to get the details without error. + fExpService.getExecutor().submit(new Runnable() { + public void run() { + fExpService.getFormattedExpressionValue( + fExpService.getFormattedValueContext(children[1], MIExpressions.DETAILS_FORMAT), + new DataRequestMonitor(fExpService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); + + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); + + } + + /** + * This test makes sure we properly deal with a GDB display bug + * and nested children. + * See bug 320277. + */ + @Test + public void testNestedBaseChildrenBug() throws Throwable { + + MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("BaseTest::test"); + + final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + + // First we get 'this' and its children + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "this"); + IExpressionDMContext[] children1 = getChildren(exprDmc, new String[] {"Base", "Base"}); + final IExpressionDMContext[] children = getChildren(children1[0], new String[] {"nested", "pNested"}); + final IExpressionDMContext[] childOfPointer = getChildren(children[1], new String[] {"*pNested"}); + + fExpService.getExecutor().submit(new Runnable() { + public void run() { + fExpService.getFormattedExpressionValue( + fExpService.getFormattedValueContext(children[0], MIExpressions.DETAILS_FORMAT), + new DataRequestMonitor(fExpService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); + + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); + + wait.waitReset(); + + fExpService.getExecutor().submit(new Runnable() { + public void run() { + fExpService.getFormattedExpressionValue( + fExpService.getFormattedValueContext(children[1], MIExpressions.DETAILS_FORMAT), + new DataRequestMonitor(fExpService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); + + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); + + wait.waitReset(); + + fExpService.getExecutor().submit(new Runnable() { + public void run() { + fExpService.getFormattedExpressionValue( + fExpService.getFormattedValueContext(childOfPointer[0], MIExpressions.DETAILS_FORMAT), + new DataRequestMonitor(fExpService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); + + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); } /**