mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Bug 328573: Variables view has problems with duplicate debug info for local variable
This commit is contained in:
parent
1e2b8c24bb
commit
2e2e49d1a3
1 changed files with 25 additions and 12 deletions
|
@ -15,7 +15,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
|
@ -506,7 +508,7 @@ public class MIStack extends AbstractDsfService
|
||||||
fCachedStoppedEvent.getFrame().getArgs() != null)
|
fCachedStoppedEvent.getFrame().getArgs() != null)
|
||||||
{
|
{
|
||||||
rm.setData(makeVariableDMCs(
|
rm.setData(makeVariableDMCs(
|
||||||
frameDmc, MIVariableDMC.Type.ARGUMENT, fCachedStoppedEvent.getFrame().getArgs().length));
|
frameDmc, MIVariableDMC.Type.ARGUMENT, fCachedStoppedEvent.getFrame().getArgs()));
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -545,7 +547,7 @@ public class MIStack extends AbstractDsfService
|
||||||
// Create the variable array out of MIArg array.
|
// Create the variable array out of MIArg array.
|
||||||
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
||||||
if (args == null) args = new MIArg[0];
|
if (args == null) args = new MIArg[0];
|
||||||
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args.length));
|
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -572,7 +574,7 @@ public class MIStack extends AbstractDsfService
|
||||||
// Create the variable array out of MIArg array.
|
// Create the variable array out of MIArg array.
|
||||||
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
||||||
if (args == null) args = new MIArg[0];
|
if (args == null) args = new MIArg[0];
|
||||||
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args.length));
|
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -609,7 +611,7 @@ public class MIStack extends AbstractDsfService
|
||||||
// Create the variable array out of MIArg array.
|
// Create the variable array out of MIArg array.
|
||||||
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
MIArg[] args = getData().getMIFrames()[idx].getArgs();
|
||||||
if (args == null) args = new MIArg[0];
|
if (args == null) args = new MIArg[0];
|
||||||
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args.length));
|
rm.setData(makeVariableDMCs(frameDmc, MIVariableDMC.Type.ARGUMENT, args));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -813,12 +815,23 @@ public class MIStack extends AbstractDsfService
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private MIVariableDMC[] makeVariableDMCs(IFrameDMContext frame, MIVariableDMC.Type type, int count) {
|
private MIVariableDMC[] makeVariableDMCs(IFrameDMContext frame, MIVariableDMC.Type type, MIArg[] miArgs) {
|
||||||
MIVariableDMC[] variables = new MIVariableDMC[count];
|
// Use LinkedHashMap in order to keep the original ordering.
|
||||||
for (int i = 0; i < count; i++) {
|
// We don't currently support variables with the same name in the same frame,
|
||||||
variables[i]= new MIVariableDMC(this, frame, type, i);
|
// so we only keep the first one.
|
||||||
|
// Bug 327621 and 328573
|
||||||
|
Map<String, MIVariableDMC> variableNames = new LinkedHashMap<String, MIVariableDMC>();
|
||||||
|
|
||||||
|
for (int i = 0; i < miArgs.length; i++) {
|
||||||
|
String name = miArgs[i].getName();
|
||||||
|
MIVariableDMC var = variableNames.get(name);
|
||||||
|
|
||||||
|
if (var == null) {
|
||||||
|
variableNames.put(name, new MIVariableDMC(this, frame, type, i));
|
||||||
}
|
}
|
||||||
return variables;
|
}
|
||||||
|
|
||||||
|
return variableNames.values().toArray(new MIVariableDMC[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findFrameIndex(MIFrame[] frames, int level) {
|
private int findFrameIndex(MIFrame[] frames, int level) {
|
||||||
|
@ -866,7 +879,7 @@ public class MIStack extends AbstractDsfService
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
localsList.addAll( Arrays.asList(
|
localsList.addAll( Arrays.asList(
|
||||||
makeVariableDMCs(frameDmc, MIVariableDMC.Type.LOCAL, getData().getLocals().length)) );
|
makeVariableDMCs(frameDmc, MIVariableDMC.Type.LOCAL, getData().getLocals())) );
|
||||||
countingRm.done();
|
countingRm.done();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -881,7 +894,7 @@ public class MIStack extends AbstractDsfService
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
localsList.addAll( Arrays.asList(
|
localsList.addAll( Arrays.asList(
|
||||||
makeVariableDMCs(frameDmc, MIVariableDMC.Type.LOCAL, getData().getLocals().length)) );
|
makeVariableDMCs(frameDmc, MIVariableDMC.Type.LOCAL, getData().getLocals())) );
|
||||||
countingRm.done();
|
countingRm.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue