mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 438934 - Failure in MIMemoryTest.asynchronousReadWrite because of a
concurency issue where the AsyncCompletionWaitor was being accessed by more than one thread but was not properly synchronized. Change-Id: I5c6f063ca519787a0cc45281c0632fcf07b763d5 Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/30089 Tested-by: Hudson CI
This commit is contained in:
parent
b9764a20a4
commit
935e88036d
2 changed files with 7 additions and 41 deletions
|
@ -89,7 +89,7 @@ public class AsyncCompletionWaitor {
|
||||||
fNumWaiting = 0;
|
fNumWaiting = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOK() {
|
public synchronized boolean isOK() {
|
||||||
if ( fStatus == null ) {
|
if ( fStatus == null ) {
|
||||||
// We timed out
|
// We timed out
|
||||||
return false;
|
return false;
|
||||||
|
@ -98,7 +98,7 @@ public class AsyncCompletionWaitor {
|
||||||
return fStatus.isOK();
|
return fStatus.isOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public synchronized String getMessage() {
|
||||||
if ( fStatus == null ) {
|
if ( fStatus == null ) {
|
||||||
return "Timed out"; //$NON-NLS-1$
|
return "Timed out"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -115,15 +115,15 @@ public class AsyncCompletionWaitor {
|
||||||
return fullMessage.length() <= 2 ? fullMessage : fullMessage.substring(0, fullMessage.length() - 2);
|
return fullMessage.length() <= 2 ? fullMessage : fullMessage.substring(0, fullMessage.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReturnInfo(Object info) {
|
public synchronized void setReturnInfo(Object info) {
|
||||||
fReturnInfo = info ;
|
fReturnInfo = info ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getReturnInfo() {
|
public synchronized Object getReturnInfo() {
|
||||||
return fReturnInfo;
|
return fReturnInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increment() {
|
public synchronized void increment() {
|
||||||
if (fWaitFinished) {
|
if (fWaitFinished) {
|
||||||
((MultiStatus)fStatus).merge(
|
((MultiStatus)fStatus).merge(
|
||||||
new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID,
|
new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID,
|
||||||
|
|
|
@ -22,8 +22,6 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
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;
|
||||||
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.IMemory;
|
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.IMemoryChangedEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
||||||
|
@ -217,40 +215,8 @@ public class MIMemoryTest extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
private IAddress evaluateExpression(IDMContext ctx, String expression) throws Throwable
|
private IAddress evaluateExpression(IDMContext ctx, String expression) throws Throwable
|
||||||
{
|
{
|
||||||
// Create the expression and format contexts
|
IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
||||||
final IExpressionDMContext expressionDMC = SyncUtil.createExpression(ctx, expression);
|
return new Addr64(SyncUtil.getExpressionValue(expressionDMC, IFormattedValues.HEX_FORMAT));
|
||||||
final FormattedValueDMContext formattedValueDMC = SyncUtil.getFormattedValue(fExpressionService, expressionDMC, IFormattedValues.HEX_FORMAT);
|
|
||||||
|
|
||||||
// Create the DataRequestMonitor which will store the operation result in the wait object
|
|
||||||
final DataRequestMonitor<FormattedValueDMData> drm =
|
|
||||||
new DataRequestMonitor<FormattedValueDMData>(fSession.getExecutor(), null) {
|
|
||||||
@Override
|
|
||||||
protected void handleCompleted() {
|
|
||||||
if (isSuccess()) {
|
|
||||||
fWait.setReturnInfo(getData());
|
|
||||||
}
|
|
||||||
fWait.waitFinished(getStatus());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Evaluate the expression (asynchronously)
|
|
||||||
fSession.getExecutor().submit(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
fExpressionService.getFormattedExpressionValue(formattedValueDMC, drm);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Wait for completion
|
|
||||||
fWait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
|
|
||||||
assertTrue(fWait.getMessage(), fWait.isOK());
|
|
||||||
|
|
||||||
// Return the string formatted by the back-end
|
|
||||||
String result = "";
|
|
||||||
Object returnInfo = fWait.getReturnInfo();
|
|
||||||
if (returnInfo instanceof FormattedValueDMData)
|
|
||||||
result = ((FormattedValueDMData) returnInfo).getFormattedValue();
|
|
||||||
return new Addr64(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue