diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 336b813d68b..25bc3e9f08b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,7 @@ +2004-11-12 Alain Magloire + Fix for PR 78488 + * mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java + 2004-11-11 Alain Magloire Fix for PR 75000, from PalmSource * cdi/org/eclipse/cdt/debug/core/cdi/model/Variable.java diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java index 373d0b302da..5cb5914f68e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java @@ -18,6 +18,7 @@ import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.Expression; @@ -108,6 +109,7 @@ public class ExpressionManager extends Manager { } public void update(Target target) throws CDIException { +// deleteAllVariables(target); List eventList = new ArrayList(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); @@ -192,6 +194,23 @@ public class ExpressionManager extends Manager { } } + /** + * Remove variable form the maintained cache list. + * @param miSession + * @param varName + * @return + */ + public Variable removeVariableFromList(MISession miSession, String varName) { + Variable var = getVariable(miSession, varName); + if (var != null) { + Target target = ((Session)getSession()).getTarget(miSession); + List varList = getVariableList(target); + varList.remove(var); + return var; + } + return null; + } + public void deleteAllVariables(Target target) throws CDIException { List varList = getVariableList(target); Variable[] variables = (Variable[]) varList.toArray(new Variable[varList.size()]); @@ -215,8 +234,21 @@ public class ExpressionManager extends Manager { } catch (MIException e) { //throw new MI2CDIException(e); } - List varList = getVariableList(target); - varList.remove(variable); + //List varList = getVariableList(target); + //varList.remove(variable); + + // remove any children + ICDIVariable[] children = variable.children; + if (children != null) { + for (int i = 0; i < children.length; ++i) { + if (children[0] instanceof Variable) { + Variable child = (Variable)children[i]; + MIVarDeletedEvent event = new MIVarDeletedEvent(miSession, child.getMIVar().getVarName()); + miSession.fireEvent(event); + } + } + } + miSession.fireEvent(new MIVarDeletedEvent(miSession, variable.getMIVar().getVarName())); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java index 6ef2d848193..bf8b7222677 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java @@ -81,12 +81,26 @@ public class MICommand extends Command { StringBuffer sb = new StringBuffer(); if (options != null && options.length > 0) { for (int i = 0; i < options.length; i++) { + String option = options[i]; + // If the option argument contains " or \ it must be escaped + if (option.indexOf('"') != -1 || option.indexOf('\\') != -1) { + StringBuffer buf = new StringBuffer(); + for (int j = 0; j < option.length(); j++) { + char c = option.charAt(j); + if (c == '"' || c == '\\') { + buf.append('\\'); + } + buf.append(c); + } + option = buf.toString(); + } + // If the option contains a space according to // GDB/MI spec we must surround it with double quotes. - if (options[i].indexOf('\t') != -1 || options[i].indexOf(' ') != -1) { - sb.append(' ').append('"').append(options[i]).append('"'); + if (option.indexOf('\t') != -1 || option.indexOf(' ') != -1) { + sb.append(' ').append('"').append(option).append('"'); } else { - sb.append(' ').append(options[i]); + sb.append(' ').append(option); } } }