From 1bc4e43764c658029fa8aa0d0f0e5c7858494cb7 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 6 Aug 2003 19:52:27 +0000 Subject: [PATCH] Remove unneeded method --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 19 +++ .../debug/mi/core/cdi/RegisterManager.java | 4 +- .../debug/mi/core/cdi/VariableManager.java | 72 ++++----- .../cdt/debug/mi/core/cdi/model/Argument.java | 3 - .../cdt/debug/mi/core/cdi/model/Register.java | 9 +- .../cdt/debug/mi/core/cdi/model/Variable.java | 91 ++++-------- .../mi/core/cdi/model/VariableObject.java | 138 +++++++++++++++--- .../mi/core/cdi/model/type/ArrayValue.java | 21 +++ 8 files changed, 227 insertions(+), 130 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index d7ba0bf16c2..e51e5dcfe23 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -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. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java index 47020f7a97a..d3d3a435906 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java @@ -79,8 +79,6 @@ public class RegisterManager extends SessionObject implements ICDIRegisterManage 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 class RegisterManager extends SessionObject implements ICDIRegisterManage 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]; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java index c83b65303a9..81c7f2f97b4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java @@ -92,13 +92,17 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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 class VariableManager extends SessionObject implements ICDIVariableManage } } - 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage } 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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 @@ public class VariableManager extends SessionObject implements ICDIVariableManage 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; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java index 629ee23e6c7..926786e50a3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Argument.java @@ -15,7 +15,4 @@ public class Argument extends Variable implements ICDIArgument { super(obj, var); } - public ArgumentObject getArgumentObject() { - return (ArgumentObject)super.getVariableObject(); - } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java index 9bac57e3c3f..d082b059221 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java @@ -25,13 +25,6 @@ public class Register extends Variable implements ICDIRegister { 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 @@ public class Register extends Variable implements ICDIRegister { 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) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java index 187b326b2a7..046428c80fa 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java @@ -9,8 +9,6 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; 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.MISession; 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.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; import org.eclipse.cdt.debug.mi.core.cdi.model.type.LongValue; @@ -65,16 +61,17 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo; /** */ -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 @@ public class Variable extends CObject implements ICDIVariable { 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 @@ public class Variable extends CObject implements ICDIVariable { 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 @@ public class Variable extends CObject implements ICDIVariable { 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 @@ public class Variable extends CObject implements ICDIVariable { } /** - * @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 @@ public class Variable extends CObject implements ICDIVariable { * @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 @@ public class Variable extends CObject implements ICDIVariable { 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; - } - } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java index 2f8ebe3f1ba..6b4f0f54555 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java @@ -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 @@ public class VariableObject extends CObject implements ICDIVariableObject { 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() { @@ -63,4 +75,94 @@ public class VariableObject extends CObject implements ICDIVariableObject { 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; + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java index a3ae915ef8c..a95fe962fa5 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayValue.java @@ -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 @@ public class ArrayValue extends DerivedValue implements ICDIArrayValue { 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(); + } }