mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[297798] ClassCastExcetion fix and more detailed checks.
This commit is contained in:
parent
370ef8a824
commit
d15ff47ef8
1 changed files with 36 additions and 10 deletions
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.mi.service;
|
package org.eclipse.cdt.dsf.mi.service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -755,15 +754,42 @@ public class MIExpressions extends AbstractDsfService implements IExpressions, I
|
||||||
*/
|
*/
|
||||||
public void getSubExpressions(IExpressionDMContext exprCtx, final int startIndex,
|
public void getSubExpressions(IExpressionDMContext exprCtx, final int startIndex,
|
||||||
final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
|
final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
|
||||||
|
|
||||||
|
if (startIndex < 0 || length < 0) {
|
||||||
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exprCtx instanceof MIExpressionDMC) {
|
||||||
getSubExpressions(
|
getSubExpressions(
|
||||||
exprCtx,
|
exprCtx,
|
||||||
new DataRequestMonitor<IExpressionDMContext[]>(getExecutor(), rm) {
|
new DataRequestMonitor<IExpressionDMContext[]>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
rm.setData((IExpressionDMContext[])Arrays.asList(getData()).subList(startIndex, startIndex + length).toArray());
|
IExpressionDMContext[] subExpressions = getData();
|
||||||
|
|
||||||
|
if (startIndex >= subExpressions.length || startIndex + length > subExpressions.length) {
|
||||||
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IExpressionDMContext[] subRange = new IExpressionDMContext[length];
|
||||||
|
for (int i=0; i<subRange.length; i++) {
|
||||||
|
subRange[i] = subExpressions[i+startIndex];
|
||||||
|
}
|
||||||
|
rm.setData(subRange);
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (exprCtx instanceof InvalidContextExpressionDMC) {
|
||||||
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
|
} else {
|
||||||
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid expression context.", null)); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue