1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 432888 - Missing rm.done() for a fetched child of an expression

Change-Id: Ia5b43d57d2bc0354786c5d276e091749fa64a87b
Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/25108
This commit is contained in:
Marc Khouzam 2014-04-15 13:54:47 -04:00
parent e907795125
commit 90648530f8
3 changed files with 94 additions and 2 deletions

View file

@ -1540,6 +1540,17 @@ public class MIVariableManager implements ICommandControl {
else if (childVar.getRootToUpdate().isOutOfScope()) {
childVar.deleteInGdb();
childVar = null;
} else {
childVar.hasCastToBaseClassWorkaround = childHasCastToBaseClassWorkaround;
if (fakeChild) {
// I don't think this should happen, but we put it just in case
addRealChildrenOfFake(childVar, exprDmc, realChildren,
arrayPosition, countingRm);
} else {
// This is a real child
realChildren[arrayPosition] = new ExpressionInfo[] { childVar.exprInfo };
countingRm.done();
}
}
}

View file

@ -384,9 +384,15 @@ void testReturn() {
testSimpleReturn(6);
testComplexReturn();
a = 0;;
a = 0;
}
void testExistingChild() {
bar b;
int a = 10;
return;
}
int main() {
printf("Running ExpressionTest App\n");
@ -415,6 +421,7 @@ int main() {
testRTTI();
testCasting();
testReturn();
testExistingChild();
// For bug 320277
BaseTest b; b.test();

View file

@ -4104,6 +4104,80 @@ public class MIExpressionsTest extends BaseTestCase {
assertEquals("b", result[0].getName());
}
/**
* This tests verifies that we can obtain a child even though
* is was already created directly.
*/
@Test
public void testExistingChild() throws Throwable {
SyncUtil.runToLocation("testExistingChild");
MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final String PARENT_EXPR = "b";
final String CHILD_EXPR = "((b).d)";
// Fetch the child directly
final IExpressionDMContext childDmc = SyncUtil.createExpression(frameDmc, CHILD_EXPR);
Query<String> query = new Query<String>() {
@Override
protected void execute(final DataRequestMonitor<String> rm) {
fExpService.getFormattedExpressionValue(
fExpService.getFormattedValueContext(childDmc, IFormattedValues.NATURAL_FORMAT),
new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().getFormattedValue());
}
});
}
};
fSession.getExecutor().execute(query);
String value = query.get(500, TimeUnit.MILLISECONDS);
assertEquals("8", value);
// Now fetch the child through its parent
final IExpressionDMContext parentDmc = SyncUtil.createExpression(frameDmc, PARENT_EXPR);
query = new Query<String>() {
@Override
protected void execute(final DataRequestMonitor<String> rm) {
fExpService.getSubExpressions(
parentDmc,
new ImmediateDataRequestMonitor<IExpressionDMContext[]>(rm) {
@Override
protected void handleSuccess() {
if (getData().length != 2) {
rm.done(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID,
"Wrong number for children. Expecting 2 but got " + getData().length, null));
return;
}
IExpressionDMContext firstChildContext = getData()[0];
if (firstChildContext.getExpression().equals(CHILD_EXPR) == false) {
rm.done(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID,
"Got wrong first child. Expected " + CHILD_EXPR + " but got " + firstChildContext.getExpression(), null));
return;
}
fExpService.getFormattedExpressionValue(
fExpService.getFormattedValueContext(firstChildContext, IFormattedValues.NATURAL_FORMAT),
new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().getFormattedValue());
}
});
}
});
}
};
fSession.getExecutor().execute(query);
value = query.get(500, TimeUnit.MILLISECONDS);
assertEquals("8", value);
}
protected int getChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable {
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();