mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 23:45:23 +02:00
Propogate fix from CDT 4.0 which from CDT 3.1.
This commit is contained in:
parent
fdc1f3a72f
commit
ee51245443
1 changed files with 54 additions and 76 deletions
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIBoolType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIEnumType;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatType;
|
||||
|
@ -228,7 +227,6 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
|||
* allow the override of the timeout.
|
||||
*/
|
||||
public ICDIVariable[] getChildren(int timeout) throws CDIException {
|
||||
children = NO_CHILDREN;
|
||||
MISession mi = ((Target)getTarget()).getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIVarListChildren var = factory.createMIVarListChildren(getMIVar().getVarName());
|
||||
|
@ -244,105 +242,85 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
|||
}
|
||||
MIVar[] vars = info.getMIVars();
|
||||
List childrenList = new ArrayList(vars.length);
|
||||
// children = new Variable[vars.length];
|
||||
// For C++ in GDB the children of the
|
||||
// the structure are the scope and the inherited classes.
|
||||
// For example:
|
||||
// class foo: public bar {
|
||||
// int x;
|
||||
// public: int y;
|
||||
// } foobar;
|
||||
// This will map to
|
||||
// - foobar
|
||||
// + bar
|
||||
// - private
|
||||
// - x
|
||||
// - public
|
||||
// - y
|
||||
// So we choose to ignore the first set of children
|
||||
// but carry over to those "fake" variables the typename and the qualified name
|
||||
boolean cppFakeLayer = isCPPLanguage() && (!isFake() || (isFake() && !isAccessQualifier(fName)));
|
||||
ICDIType t = getType();
|
||||
boolean container = isStructureProvider(t);
|
||||
for (int i = 0; i < vars.length; i++) {
|
||||
// parent qualified name
|
||||
String prefix = '(' + getFullName() + ')';
|
||||
// child simple name
|
||||
String childName = vars[i].getExp();
|
||||
// fallback full name
|
||||
String childFullName = prefix + '.' + childName;
|
||||
String fn = getQualifiedName();
|
||||
String childName = vars[i].getExp();
|
||||
ICDIType childType = null;
|
||||
boolean childFake = false;
|
||||
if (cppFakeLayer && container) {
|
||||
childFake = true;
|
||||
childType = t;
|
||||
if (!isAccessQualifier(childName)) {
|
||||
// if field is not access modifier and fake - it is a basetype
|
||||
// cast to it to see reduced structure as value
|
||||
childFullName = '(' + childName + ')' + prefix;
|
||||
ICDIType t = getType();
|
||||
if (t instanceof ICDIArrayType) {
|
||||
// For Array gdb varobj only return the index, override here.
|
||||
int index = castingIndex + i;
|
||||
fn = "(" + fn + ")[" + index + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
childName = getName() + "[" + index + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if (t instanceof ICDIPointerType) {
|
||||
ICDIType subType = ((ICDIPointerType)t).getComponentType();
|
||||
if (subType instanceof ICDIStructType || t instanceof IncompleteType) {
|
||||
if (isCPPLanguage()) {
|
||||
if (!isFake() || (isFake() && !isAccessQualifier(fName))) {
|
||||
childFake = true;
|
||||
childType = t;
|
||||
} else {
|
||||
fn = "(" + fn + ")->" + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else { // If not C++ language
|
||||
fn = "(" + fn + ")->" + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
childFullName = prefix;
|
||||
fn = "*(" + fn + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
if (t instanceof ICDIArrayType) {
|
||||
// For Array gdb varobj only return the index, override here.
|
||||
int index = castingIndex + i;
|
||||
childFullName = prefix + "[" + index + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
childName = getName() + "[" + index + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if (t instanceof ICDIPointerType) {
|
||||
if (container) {
|
||||
childFullName = prefix + "->" + childName; //$NON-NLS-1$
|
||||
} else {
|
||||
childFullName = "*" + prefix; //$NON-NLS-1$
|
||||
} else if (t instanceof ICDIReferenceType) {
|
||||
ICDIType subType = ((ICDIReferenceType)t).getComponentType();
|
||||
if (subType instanceof ICDIStructType || t instanceof IncompleteType) {
|
||||
if (isCPPLanguage()) {
|
||||
if (!isFake() || (isFake() && !isAccessQualifier(fName))) {
|
||||
childFake = true;
|
||||
childType = t;
|
||||
} else {
|
||||
fn = "(" + fn + ")." + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else { // If not C++ language
|
||||
fn = "(" + fn + ")." + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if (t instanceof ICDIReferenceType) {
|
||||
if (container) {
|
||||
childFullName = prefix + "." + childName; //$NON-NLS-1$
|
||||
} else {
|
||||
fn = "(" + fn + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if (t instanceof ICDIStructType || t instanceof IncompleteType) {
|
||||
if (isCPPLanguage()) {
|
||||
if (!isFake() || (isFake() && !isAccessQualifier(fName))) {
|
||||
childFake = true;
|
||||
childType = t;
|
||||
} else {
|
||||
childFullName = prefix;
|
||||
fn = "(" + fn + ")." + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if (t instanceof ICDIStructType) {
|
||||
// already correct name
|
||||
} else { // If not C++ language
|
||||
fn = "(" + fn + ")." + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
Variable v = createVariable((Target) getTarget(), (Thread) getThread(), (StackFrame) getStackFrame(), childName,
|
||||
childFullName, getPosition(), getStackDepth(), vars[i]);
|
||||
Variable v = createVariable((Target)getTarget(), (Thread)getThread(), (StackFrame)getStackFrame(),
|
||||
childName, fn, getPosition(), getStackDepth(), vars[i]);
|
||||
if (childType != null) {
|
||||
// Hack to reset the typename to a known value
|
||||
v.fType = childType;
|
||||
}
|
||||
v.setIsFake(childFake);
|
||||
if (childFake && isAccessQualifier(childName)) {
|
||||
// Replace a fake variable representing an access qualifier with its children.
|
||||
ICDIVariable[] grandchildren = v.getChildren(timeout);
|
||||
for (int j = 0; j < grandchildren.length; j++) {
|
||||
// don't add these, add their kids
|
||||
ICDIVariable[] grandchildren = v.getChildren();
|
||||
for (int j = 0; j < grandchildren.length; ++j)
|
||||
childrenList.add(grandchildren[j]);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
childrenList.add(v);
|
||||
}
|
||||
}
|
||||
if (!childrenList.isEmpty())
|
||||
children = (ICDIVariable[]) childrenList.toArray(new Variable[childrenList.size()]);
|
||||
|
||||
children = (ICDIVariable[])childrenList.toArray(new ICDIVariable[childrenList.size()]);
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
private boolean isStructureProvider(ICDIType t) {
|
||||
// IncompleteType can be only struct or class, so same rules apply
|
||||
if (t instanceof ICDIStructType || t instanceof IncompleteType)
|
||||
return true;
|
||||
if (t instanceof ICDIPointerType || t instanceof ICDIReferenceType) {
|
||||
ICDIType type = ((ICDIDerivedType)t).getComponentType();
|
||||
return (type instanceof ICDIStructType || type instanceof IncompleteType);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
boolean isAccessQualifier(String foo) {
|
||||
boolean isAccessQualifier(String foo) {
|
||||
return foo.equals("private") || foo.equals("public") || foo.equals("protected"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue