1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Create ArrayValue ReferenceValue PointerValue

and StructValue.
This commit is contained in:
Alain Magloire 2003-07-16 19:09:11 +00:00
parent 51cc929af3
commit 4d77a59658
9 changed files with 144 additions and 15 deletions

View file

@ -19,7 +19,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo;
*/
public class Value extends CObject implements ICDIValue {
Variable variable;
protected Variable variable;
public Value(Variable v) {
super(v.getTarget());
@ -86,6 +86,7 @@ public class Value extends CObject implements ICDIValue {
*/
return (getChildrenNumber() > 0);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
*/

View file

@ -35,11 +35,13 @@ import org.eclipse.cdt.debug.mi.core.cdi.Format;
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.cdi.SourceManager;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ArrayValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.CharValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.DoubleValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.EnumValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.FloatValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.FunctionValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.IncompleteType;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.IntValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.LongLongValue;
@ -47,6 +49,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.type.LongValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.PointerValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ReferenceValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ShortValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.StructValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.Type;
import org.eclipse.cdt.debug.mi.core.cdi.model.type.WCharValue;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
@ -101,13 +104,22 @@ public class Variable extends CObject implements ICDIVariable {
}
public ICDIVariable[] getChildren() throws CDIException {
// Use the default timeout.
return getChildren(-1);
}
public ICDIVariable[] getChildren(int timeout) throws CDIException {
Session session = (Session)(getTarget().getSession());
MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory();
MIVarListChildren var =
factory.createMIVarListChildren(getMIVar().getVarName());
try {
mi.postCommand(var);
if (timeout >= 0) {
mi.postCommand(var, timeout);
} else {
mi.postCommand(var);
}
MIVarListChildrenInfo info = var.getMIVarListChildrenInfo();
if (info == null) {
throw new CDIException("No answer");
@ -172,21 +184,15 @@ public class Variable extends CObject implements ICDIVariable {
} else if (t instanceof ICDIDoubleType) {
value = new DoubleValue(this);
} else if (t instanceof ICDIFunctionType) {
//value = new FunctionValue(this);
value = new Value(this);
value = new FunctionValue(this);
} else if (t instanceof ICDIPointerType) {
//((ICDIPointerType)t).getComponentType();
value = new PointerValue(this);
//value = new Value(this);
} else if (t instanceof ICDIReferenceType) {
value = new ReferenceValue(this);
} else if (t instanceof ICDIArrayType) {
//((ICDIArrayType)t).getComponentType();
//value = new ArrayValue(this);
value = new Value(this);
value = new ArrayValue(this);
} else if (t instanceof ICDIStructType) {
//value = new StructValue(this);
value = new Value(this);
value = new StructValue(this);
} else {
value = new Value(this);
}

View file

@ -0,0 +1,19 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIAggregateValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
*/
public abstract class AggregateValue extends Value implements ICDIAggregateValue {
public AggregateValue(Variable v) {
super(v);
}
}

View file

@ -0,0 +1,41 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
* Enter type comment.
*
* @since Jun 3, 2003
*/
public class ArrayValue extends DerivedValue implements ICDIArrayValue {
public ArrayValue(Variable v) {
super(v);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
*/
public ICDIVariable[] getVariables() throws CDIException {
/* GDB is appallingly slow on array fetches. As as slow as 128 entries
* per second on NT gdbs with slow processors. We need to set a timeout
* that's appropraitely scaled by number of children to give the slave
* GDB time to respond. In the end perhaps we want a UI for this. As it
* is, let's just make up a number that's 5 seconds for us plus one
* second for every 128 entries. */
int timeout = variable.getMIVar().getNumChild() * 8 + 5000;
return variable.getChildren(timeout);
}
}

View file

@ -0,0 +1,20 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
*/
public abstract class DerivedValue extends Value implements ICDIDerivedValue {
public DerivedValue(Variable v) {
super(v);
}
}

View file

@ -0,0 +1,22 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFunctionValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
* Enter type comment.
*
* @since Jun 3, 2003
*/
public class FunctionValue extends DerivedValue implements ICDIFunctionValue {
public FunctionValue(Variable v) {
super(v);
}
}

View file

@ -8,7 +8,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
@ -16,7 +15,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
*
* @since Jun 3, 2003
*/
public class PointerValue extends Value implements ICDIPointerValue {
public class PointerValue extends DerivedValue implements ICDIPointerValue {
public PointerValue(Variable v) {
super(v);

View file

@ -8,7 +8,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
@ -16,7 +15,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
*
* @since Jun 3, 2003
*/
public class ReferenceValue extends Value implements ICDIReferenceValue {
public class ReferenceValue extends DerivedValue implements ICDIReferenceValue {
/**
* @param v

View file

@ -0,0 +1,22 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
* Enter type comment.
*
* @since Jun 3, 2003
*/
public class StructValue extends AggregateValue implements ICDIStructValue {
public StructValue(Variable v) {
super(v);
}
}