1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

2004-11-12 Alain Magloire

Fix for PR 78488
	* mi/org/eclipse/cdt/debug/mi/core/command/MICommand.java
This commit is contained in:
Alain Magloire 2004-11-12 18:35:40 +00:00
parent 7b7e3de2d2
commit 78118d0486
3 changed files with 55 additions and 5 deletions

View file

@ -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

View file

@ -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()));
}
}

View file

@ -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);
}
}
}