1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Implement setCondition.

This commit is contained in:
Alain Magloire 2002-08-26 05:18:01 +00:00
parent acb50164f2
commit 76dd984256
2 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,7 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -68,6 +72,7 @@ public class Breakpoint extends SessionObject implements ICDILocationBreakpoint
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#setCondition(ICDICondition)
*/
public void setCondition(ICDICondition condition) throws CDIException {
mgr.setCondition(this, condition);
this.condition = condition;
}

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIBreakCondition;
import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete;
import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable;
import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable;
@ -160,6 +161,34 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(false);
}
public void setCondition(ICDIBreakpoint breakpoint, ICDICondition condition) throws CDIException {
int number = 0;
if (breakpoint instanceof Breakpoint
&& breakList.contains(breakpoint)) {
number = ((Breakpoint) breakpoint).getMIBreakPoint().getNumber();
} else {
throw new CDIException("Not a CDT breakpoint");
}
// We only suppor expression not ignore count reset.
String exprCond = condition.getExpression();
if (exprCond == null) {
throw new CDIException("ignore count not supported");
}
CSession s = getCSession();
CommandFactory factory = s.getMISession().getCommandFactory();
MIBreakCondition breakCondition =
factory.createMIBreakCondition(number, exprCond);
try {
s.getMISession().postCommand(breakCondition);
MIInfo info = breakCondition.getMIInfo();
if (info == null) {
throw new CDIException("No answer");
}
} catch (MIException e) {
throw new CDIException(e.toString());
}
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#getBreakpoints()
*/