mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
Suspend the target if running when trying to set breakpoints
This commit is contained in:
parent
c95bdf8998
commit
930ddb92fb
1 changed files with 46 additions and 2 deletions
|
@ -72,6 +72,29 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
new Breakpoint[breakList.size()]);
|
new Breakpoint[breakList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean suspendInferior() throws CDIException {
|
||||||
|
boolean shouldRestart = false;
|
||||||
|
CSession s = getCSession();
|
||||||
|
CTarget target = s.getCTarget();
|
||||||
|
// Stop the program and disable events.
|
||||||
|
if (target.isRunning()) {
|
||||||
|
shouldRestart = true;
|
||||||
|
((EventManager)s.getEventManager()).disableEvents();
|
||||||
|
target.suspend();
|
||||||
|
}
|
||||||
|
return shouldRestart;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resumeInferior(boolean shouldRestart) throws CDIException {
|
||||||
|
if (shouldRestart) {
|
||||||
|
CSession s = getCSession();
|
||||||
|
CTarget target = s.getCTarget();
|
||||||
|
target.resume();
|
||||||
|
((EventManager)s.getEventManager()).enableEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteAllBreakpoints()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteAllBreakpoints()
|
||||||
*/
|
*/
|
||||||
|
@ -101,6 +124,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
throw new CDIException("Not a CDT breakpoint");
|
throw new CDIException("Not a CDT breakpoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakDelete breakDelete = factory.createMIBreakDelete(numbers);
|
MIBreakDelete breakDelete = factory.createMIBreakDelete(numbers);
|
||||||
|
@ -112,6 +136,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < breakpoints.length; i++) {
|
for (int i = 0; i < breakpoints.length; i++) {
|
||||||
breakList.remove(breakpoints[i]);
|
breakList.remove(breakpoints[i]);
|
||||||
|
@ -126,6 +152,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
} else {
|
} else {
|
||||||
throw new CDIException("Not a CDT breakpoint");
|
throw new CDIException("Not a CDT breakpoint");
|
||||||
}
|
}
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakEnable breakEnable =
|
MIBreakEnable breakEnable =
|
||||||
|
@ -138,6 +165,9 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
// Resume the program and enable events.
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(true);
|
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +180,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
} else {
|
} else {
|
||||||
throw new CDIException("Not a CDT breakpoint");
|
throw new CDIException("Not a CDT breakpoint");
|
||||||
}
|
}
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakDisable breakDisable =
|
MIBreakDisable breakDisable =
|
||||||
|
@ -162,6 +193,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(false);
|
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -178,6 +211,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
// We only suppor expression not ignore count reset.
|
// We only suppor expression not ignore count reset.
|
||||||
String exprCond = condition.getExpression();
|
String exprCond = condition.getExpression();
|
||||||
if (exprCond != null) {
|
if (exprCond != null) {
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakCondition breakCondition =
|
MIBreakCondition breakCondition =
|
||||||
|
@ -190,9 +224,12 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int ignoreCount = condition.getIgnoreCount();
|
int ignoreCount = condition.getIgnoreCount();
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakAfter breakAfter =
|
MIBreakAfter breakAfter =
|
||||||
|
@ -205,6 +242,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,6 +316,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakInsert breakInsert =
|
MIBreakInsert breakInsert =
|
||||||
|
@ -295,8 +335,9 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Breakpoint bkpt = new Breakpoint(this, points[0]);
|
Breakpoint bkpt = new Breakpoint(this, points[0]);
|
||||||
breakList.add(bkpt);
|
breakList.add(bkpt);
|
||||||
return bkpt;
|
return bkpt;
|
||||||
|
@ -309,6 +350,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
ICDICondition condition) throws CDIException {
|
ICDICondition condition) throws CDIException {
|
||||||
boolean access = (type == ICDIWatchpoint.WRITE);
|
boolean access = (type == ICDIWatchpoint.WRITE);
|
||||||
boolean read = (type == ICDIWatchpoint.READ);
|
boolean read = (type == ICDIWatchpoint.READ);
|
||||||
|
|
||||||
|
boolean state = suspendInferior();
|
||||||
CSession s = getCSession();
|
CSession s = getCSession();
|
||||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
MIBreakWatch breakWatch =
|
MIBreakWatch breakWatch =
|
||||||
|
@ -326,8 +369,9 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
resumeInferior(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Watchpoint bkpt = new Watchpoint(this, points[0]);
|
Watchpoint bkpt = new Watchpoint(this, points[0]);
|
||||||
breakList.add(bkpt);
|
breakList.add(bkpt);
|
||||||
return bkpt;
|
return bkpt;
|
||||||
|
|
Loading…
Add table
Reference in a new issue