Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] MI implementation fixes.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.150
diff -u -r1.150 ChangeLog
--- ChangeLog	28 Jul 2003 21:39:55 -0000	1.150
+++ ChangeLog	6 Aug 2003 19:36:05 -0000
@@ -1,3 +1,22 @@
+2003-08-06 Alain Magloire
+
+	First framework to deal with breaking the arrays in ranges.
+
+	*  src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java:
+	Remove unused getArgumentObject().
+	* src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java:
+	Remove unuse getRegisterObject().
+	* src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java:
+	Move methods to VariableObject to comply with the interface.
+	* src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java:
+	Implement new methods of ICDIVariableObject.java
+	Save the castin information.
+	* src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java:
+	New method getVariables(int, int).
+	* src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java:
+	New method encodeVariable(), to get the encode specific string
+	for gdb casting of arrays.
+
 2003-07-28 Mikhail Khodjaiants
 
 	Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
Index: src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java,v
retrieving revision 1.13
diff -u -r1.13 RegisterManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java	19 Jun 2003 03:39:14 -0000	1.13
+++ src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java	6 Aug 2003 19:36:05 -0000
@@ -79,8 +79,6 @@
 		RegisterObject regObj = null;
 		if (regObject instanceof RegisterObject) {
 			regObj = (RegisterObject)regObject;
-		} else if (regObject instanceof Register) {
-			regObj = ((Register)regObject).getRegisterObject();
 		}
 		if (regObj != null) {
 			Register reg = getRegister(regObject);
@@ -160,7 +158,7 @@
 	public Register getRegister(int regno) {
 		Register[] regs = getRegisters();
 		for (int i = 0; i < regs.length; i++) {
-			if (regs[i].getVariableObject().getPosition() == regno) {
+			if (regs[i].getPosition() == regno) {
 				return regs[i];
 			}
 		}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java,v
retrieving revision 1.34
diff -u -r1.34 VariableManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java	19 Jun 2003 03:39:01 -0000	1.34
+++ src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java	6 Aug 2003 19:36:05 -0000
@@ -92,13 +92,17 @@
 		int depth = v.getStackDepth();
 		Variable[] vars = getVariables();
 		for (int i = 0; i < vars.length; i++) {
-			if (vars[i].getName().equals(name)) {
+			if (vars[i].getName().equals(name) &&
+			    vars[i].casting_index == v.casting_index &&
+			    vars[i].casting_length == v.casting_length &&
+			    ((vars[i].casting_type == null && v.casting_type == null) ||
+			     (vars[i].casting_type != null && v.casting_type != null && vars[i].casting_type.equals(v.casting_type)))) {
 				ICDIStackFrame frame = vars[i].getStackFrame();
 				if (stack == null && frame == null) {
 					return vars[i];
 				} else if (frame != null && stack != null && frame.equals(stack)) {
-					if (vars[i].getVariableObject().getPosition() == position) {
-						if (vars[i].getVariableObject().getStackDepth() == depth) {
+					if (vars[i].getPosition() == position) {
+						if (vars[i].getStackDepth() == depth) {
 							return vars[i];
 						}
 					}
@@ -133,23 +137,23 @@
 		}
 	}
 
-	public String createStringEncoding(VariableObject varObj) {
+	public static String encodeVariable(VariableObject varObj) {
 		StringBuffer buffer = new StringBuffer();
-		if (varObj.length > 0) {
+		if (varObj.casting_length > 0 || varObj.casting_index > 0) {
 			buffer.append("*(");
 			buffer.append('(');
-			if (varObj.type != null && varObj.type.length() > 0) {
-				buffer.append('(').append(varObj.type).append(')');
+			if (varObj.casting_type != null && varObj.casting_type.length() > 0) {
+				buffer.append('(').append(varObj.casting_type).append(')');
 			}
 			buffer.append(varObj.getName());
 			buffer.append(')');
-			if (varObj.index != 0) {
-					buffer.append('+').append(varObj.index);
+			if (varObj.casting_index != 0) {
+					buffer.append('+').append(varObj.casting_index);
 			}
 			buffer.append(')');
-			buffer.append('@').append(varObj.length - varObj.index);
-		} else if (varObj.type != null && varObj.type.length() > 0) {
-			buffer.append('(').append(varObj.type).append(')');
+			buffer.append('@').append(varObj.casting_length - varObj.casting_index);
+		} else if (varObj.casting_type != null && varObj.casting_type.length() > 0) {
+			buffer.append('(').append(varObj.casting_type).append(')');
 			buffer.append('(').append(varObj.getName()).append(')');
 		} else {
 			buffer.append(varObj.getName());
@@ -195,8 +199,6 @@
 		ArgumentObject argObj = null;
 		if (a instanceof ArgumentObject) {
 			argObj = (ArgumentObject)a;
-		} else if (a instanceof Argument) {
-			argObj = ((Argument)a).getArgumentObject();
 		}
 		if (argObj != null) {
 			Variable variable = findVariable(argObj);
@@ -205,7 +207,7 @@
 				argument = (Argument)variable;
 			}
 			if (argument == null) {
-				String name = argObj.getName();
+				String name = encodeVariable(argObj);
 				ICDIStackFrame stack = argObj.getStackFrame();
 				Session session = (Session)getSession();
 				ICDIThread currentThread = null;
@@ -344,15 +346,10 @@
 		VariableObject obj = null;
 		if (object instanceof VariableObject) {
 			obj = (VariableObject)object;
-		} else if (object instanceof Variable) {
-			obj = ((Variable)object).getVariableObject();
 		}
 		if (obj != null) {
-			StringBuffer buffer = new StringBuffer();
-			buffer.append("*(");
-			buffer.append('(');
+			// Check if the type is valid.
 			if (type != null && type.length() > 0) {
-				// Check if the type is valid.
 				try {
 					MISession mi = ((Session)getSession()).getMISession();
 					CommandFactory factory = mi.getCommandFactory();
@@ -365,20 +362,32 @@
 				} catch (MIException e) {
 					throw new MI2CDIException(e);
 				}
-				buffer.append('(').append(type).append(')');
 			}
+
+			// Should we provide a getRegisterObjectAsArray ?
+			StringBuffer buffer = new StringBuffer();
 			if (obj instanceof ICDIRegisterObject) {
 				buffer.append("$" + obj.getName());
 			} else {
 				buffer.append(obj.getName());
 			}
-			buffer.append(')');
-			if (start != 0) {
-				buffer.append('+').append(start);
+			VariableObject vo = new VariableObject(obj, buffer.toString());
+
+			// Carry the the old casting type over
+			buffer.setLength(0);
+			if (obj.casting_type != null && obj.casting_type.length() > 0) {
+				buffer.append("(").append(obj.casting_type).append(")");
 			}
-			buffer.append(')');
-			buffer.append('@').append(length - start);
-			return new VariableObject(obj, buffer.toString());
+			if (type != null && type.length() > 0) {
+				buffer.append(type);
+			}
+			vo.casting_type = buffer.toString();
+
+			// Carry any other info to the new VariableObject
+			vo.casting_index = obj.casting_index + start;
+			vo.casting_length = obj.casting_length + length;
+
+			return vo;
 		}
 		throw new CDIException("Unknown variable object");
 	}
@@ -390,8 +399,6 @@
 		VariableObject obj = null;
 		if (object instanceof VariableObject) {
 			obj = (VariableObject)object;
-		} else if (object instanceof Variable) {
-			obj = ((Variable)object).getVariableObject();
 		}
 		if (obj != null) {
 			StringBuffer buffer = new StringBuffer();
@@ -481,13 +488,10 @@
 		if (v instanceof VariableObject) {
 			varObj = (VariableObject)v;
 		}
-		if (v instanceof Variable) {
-			varObj = ((Variable)v).getVariableObject();
-		}
 		if (varObj != null) {
 			Variable variable = findVariable(varObj);
 			if (variable == null) {
-				String name = varObj.getName();
+				String name = encodeVariable(varObj);
 				Session session = (Session)getSession();
 				ICDIStackFrame stack = varObj.getStackFrame();
 				ICDIThread currentThread = null;
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java,v
retrieving revision 1.4
diff -u -r1.4 Argument.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java	14 Mar 2003 16:22:07 -0000	1.4
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java	6 Aug 2003 19:36:05 -0000
@@ -15,7 +15,4 @@
 		super(obj, var);
 	}
 
-	public ArgumentObject getArgumentObject() {
-		return (ArgumentObject)super.getVariableObject();
-	}
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java,v
retrieving revision 1.9
diff -u -r1.9 Register.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java	19 Jun 2003 03:38:37 -0000	1.9
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java	6 Aug 2003 19:36:05 -0000
@@ -25,13 +25,6 @@
 		super(obj, var);
 	}
 
-	public RegisterObject getRegisterObject() {
-		return (RegisterObject)super.getVariableObject();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.debug.mi.core.cdi.model.Variable#getChildren()
-	 */
 	public ICDIVariable[] getChildren() throws CDIException {
 			Session session = (Session)(getTarget().getSession());
 			MISession mi = session.getMISession();
@@ -49,7 +42,7 @@
 				children = new Register[vars.length];
 				for (int i = 0; i < vars.length; i++) {
 					RegisterObject regObj = new RegisterObject(getTarget(),
-					 vars[i].getExp(), getVariableObject().getPosition());
+					 vars[i].getExp(), getPosition());
 					children[i] = mgr.createRegister(regObj, vars[i]);
 				}
 			} catch (MIException e) {
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java,v
retrieving revision 1.14
diff -u -r1.14 Variable.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java	16 Jul 2003 19:09:11 -0000	1.14
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java	6 Aug 2003 19:36:05 -0000
@@ -9,8 +9,6 @@
 import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
 import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager;
 import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
 import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
@@ -34,7 +32,6 @@
 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;
@@ -42,7 +39,6 @@
 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;
 import org.eclipse.cdt.debug.mi.core.cdi.model.type.LongValue;
@@ -65,16 +61,17 @@
 
 /**
  */
-public class Variable extends CObject implements ICDIVariable {
+public class Variable extends VariableObject implements ICDIVariable {
 
 	MIVar miVar;
 	Value value;
 	VariableObject varObj;
 	ICDIVariable[] children = new ICDIVariable[0];
 	Type type;
+	String editable = null;
 
 	public Variable(VariableObject obj, MIVar v) {
-		super(obj.getTarget());
+		super(obj, obj.getName());
 		miVar = v;
 		varObj = obj;
 	}
@@ -83,10 +80,6 @@
 		return miVar;
 	}
 
-	public VariableObject getVariableObject() {
-		return varObj;
-	}
-
 	public Variable getChild(String name) {
 		for (int i = 0; i < children.length; i++) {
 			Variable variable = (Variable)children[i];
@@ -108,6 +101,10 @@
 		return getChildren(-1);
 	}
 
+	/**
+	 * This can be a potentially long operation for GDB.
+	 * allow the override of the timeout.
+	 */
 	public ICDIVariable[] getChildren(int timeout) throws CDIException {
 		Session session = (Session)(getTarget().getSession());
 		MISession mi = session.getMISession();
@@ -129,8 +126,7 @@
 			for (int i = 0; i < vars.length; i++) {
 				VariableObject varObj = new VariableObject(getTarget(),
 				 vars[i].getExp(), getStackFrame(),
-				 getVariableObject().getPosition(),
-				 getVariableObject().getStackDepth());
+				 getPosition(),getStackDepth());
 				children[i] = new Variable(varObj, vars[i]);
 			}
 		} catch (MIException e) {
@@ -144,16 +140,13 @@
 	}
 
 	/**
-	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
-	 */
-	public String getName() {
-		return varObj.getName();
-	}
-
-	/**
-	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
+	 * We overload the VariableObject since the gdb-varobject already knows
+	 * the type and its probably more accurate.
+	 * 
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#getTypeName()
 	 */
 	public String getTypeName() throws CDIException {
+		// We overload here not to use the whatis command.
 		return miVar.getType();
 	}
 
@@ -260,19 +253,22 @@
 	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#isEditable()
 	 */
 	public boolean isEditable() throws CDIException {
-		MISession mi = ((Session)(getTarget().getSession())).getMISession();
-		CommandFactory factory = mi.getCommandFactory();
-		MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName());
-		try {
-			mi.postCommand(var);
-			MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo();
-			if (info == null) {
-				throw new CDIException("No answer");
+		if (editable == null) {
+			MISession mi = ((Session)(getTarget().getSession())).getMISession();
+			CommandFactory factory = mi.getCommandFactory();
+			MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName());
+			try {
+				mi.postCommand(var);
+				MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo();
+				if (info == null) {
+					throw new CDIException("No answer");
+				}
+				editable = String.valueOf(info.isEditable());
+			} catch (MIException e) {
+				throw new MI2CDIException(e);
 			}
-			return info.isEditable();
-		} catch (MIException e) {
-			throw new MI2CDIException(e);
 		}
+		return (editable == null) ? false : Boolean.getBoolean(editable);
 	}
 
 	/**
@@ -305,37 +301,4 @@
 		return super.equals(var);
 	}
 
-	/**
-	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getStackFrame()
-	 */
-	public ICDIStackFrame getStackFrame() throws CDIException {
-		return varObj.getStackFrame();
-	}
-
-	/**
-	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType()
-	 */
-	public ICDIType getType() throws CDIException {
-		if (type == null) {
-			ICDITarget target = getTarget();
-			Session session = (Session)(target.getSession());
-			SourceManager sourceMgr = (SourceManager)session.getSourceManager();
-			String typename = getTypeName();
-			try {
-				type = sourceMgr.getType(target, typename);
-			} catch (CDIException e) {
-				// Try with ptype.
-				try {
-					String ptype = sourceMgr.getDetailTypeName(typename);
-					type = sourceMgr.getType(target, ptype);
-				} catch (CDIException ex) {
-				}
-			}
-			if (type == null) {
-				type = new IncompleteType(target, typename);
-			}
-		}
-		return type;
-	}
-	
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java,v
retrieving revision 1.4
diff -u -r1.4 VariableObject.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java	23 May 2003 15:49:46 -0000	1.4
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java	6 Aug 2003 19:36:05 -0000
@@ -5,18 +5,36 @@
  */
 package org.eclipse.cdt.debug.mi.core.cdi.model;
 
+import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
+import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.MISession;
+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.IncompleteType;
+import org.eclipse.cdt.debug.mi.core.cdi.model.type.Type;
+import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIDataEvaluateExpression;
+import org.eclipse.cdt.debug.mi.core.command.MIWhatis;
+import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
 
 /**
  */
 public class VariableObject extends CObject implements ICDIVariableObject {
 
 	// Casting info.
-	public String type;
-	public int index;
-	public int length;
+	public String casting_type;
+	public int casting_index;
+	public int casting_length;
+
+	Type type = null;
+	String typename = null;
+	String sizeof = null;
 
 	String name;
 	int position;
@@ -24,28 +42,22 @@
 	int stackdepth;
 
 	public VariableObject(VariableObject obj, String n) {
-		this(obj.getTarget(), n, obj.getStackFrame(),
-			obj.getPosition(), obj.getStackDepth());
+		super(obj.getTarget());
+		name = n;
+		try {
+			frame = obj.getStackFrame();
+		} catch (CDIException e) {
+		}
+		position = obj.getPosition();
+		stackdepth = obj.getStackDepth();
 	}
 
-	public VariableObject(ICDITarget target, String n, ICDIStackFrame stack,
-		int pos, int depth) {
+	public VariableObject(ICDITarget target, String n, ICDIStackFrame stack, int pos, int depth) {
 		super(target);
 		name = n;
 		frame = stack;
 		position = pos;
 		stackdepth = depth;
-		type = new String();
-		index = 0;
-		length = 0;
-	}
-
-	public ICDITarget getTarget() {
-		return target;
-	}
-
-	public ICDIStackFrame getStackFrame() {
-		return frame;
 	}
 
 	public int getPosition() {
@@ -61,6 +73,96 @@
 	 */
 	public String getName() {
 		return name;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType()
+	 */
+	public ICDIType getType() throws CDIException {
+		if (type == null) {
+			ICDITarget target = getTarget();
+			Session session = (Session) (target.getSession());
+			SourceManager sourceMgr = (SourceManager) session.getSourceManager();
+			String typename = getTypeName();
+			try {
+				type = sourceMgr.getType(target, typename);
+			} catch (CDIException e) {
+				// Try with ptype.
+				try {
+					String ptype = sourceMgr.getDetailTypeName(typename);
+					type = sourceMgr.getType(target, ptype);
+				} catch (CDIException ex) {
+				}
+			}
+			if (type == null) {
+				type = new IncompleteType(target, typename);
+			}
+		}
+		return type;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#sizeof()
+	 */
+	public int sizeof() throws CDIException {
+		if (sizeof == null) {
+			ICDITarget target = getTarget();
+			Session session = (Session) (target.getSession());
+			MISession mi = session.getMISession();
+			CommandFactory factory = mi.getCommandFactory();
+			String exp = "sizeof(" + getTypeName() + ")";
+			MIDataEvaluateExpression evaluate = factory.createMIDataEvaluateExpression("sizeof(" + getName());
+			try {
+				mi.postCommand(evaluate);
+				MIDataEvaluateExpressionInfo info = evaluate.getMIDataEvaluateExpressionInfo();
+				if (info == null) {
+					throw new CDIException("Target is not responding");
+				}
+				sizeof = info.getExpression();
+			} catch (MIException e) {
+				throw new MI2CDIException(e);
+			}
+		}
+
+		if (sizeof != null) {
+			try {
+				return Integer.parseInt(sizeof);
+			} catch (NumberFormatException e) {
+				throw new CDIException(e.getMessage());
+			}
+		}
+		return 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#getStackFrame()
+	 */
+	public ICDIStackFrame getStackFrame() throws CDIException {
+		return frame;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#getTypeName()
+	 */
+	public String getTypeName() throws CDIException {
+		if (typename == null) {
+			try {
+				ICDITarget target = getTarget();
+				Session session = (Session) (target.getSession());
+				MISession mi = session.getMISession();
+				CommandFactory factory = mi.getCommandFactory();
+				MIWhatis whatis = factory.createMIWhatis(getName());
+				mi.postCommand(whatis);
+				MIWhatisInfo info = whatis.getMIWhatisInfo();
+				if (info == null) {
+					throw new CDIException("No answer");
+				}
+				typename = info.getType();
+			} catch (MIException e) {
+				throw new MI2CDIException(e);
+			}
+		}
+		return typename;
 	}
 
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java,v
retrieving revision 1.1
diff -u -r1.1 ArrayValue.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java	16 Jul 2003 19:09:04 -0000	1.1
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java	6 Aug 2003 19:36:05 -0000
@@ -7,8 +7,12 @@
 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.ICDIVariableManager;
+import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
 import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
+import org.eclipse.cdt.debug.mi.core.cdi.Session;
 import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
 
 /**
@@ -38,4 +42,21 @@
 		return variable.getChildren(timeout);
 	}
 
+	/**
+	 * 
+	 * an Array of range[index, index + length - 1]
+	 */
+	public ICDIVariable[] getVariables(int index, int length) throws CDIException {
+		int children = getChildrenNumber();
+		//if (index >= children || index + length >= children) {
+		//	throw new CDIException("Index out of bound");
+		//}
+
+		//String subarray = "*(" + variable.getName() + "+" + index + ")@" + length;
+		ICDITarget target = getTarget();
+		Session session = (Session) (target.getSession());
+		ICDIVariableManager mgr = session.getVariableManager();
+		ICDIVariableObject vo = mgr.getVariableObjectAsArray(variable, null, index, length);
+		return mgr.createVariable(vo).getValue().getVariables();
+	}
 }



Back to the top