mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 03:05:39 +02:00
2005-06-27 Alain Magloire
Base on a patch from Chris Wiebe. * cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
This commit is contained in:
parent
0e98d98601
commit
670002408b
3 changed files with 39 additions and 56 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-06-27 Alain Magloire
|
||||||
|
Base on a patch from Chris Wiebe.
|
||||||
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
|
||||||
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
|
||||||
|
|
||||||
2005-06-27 Alain Magloire
|
2005-06-27 Alain Magloire
|
||||||
Fix PR 100069
|
Fix PR 100069
|
||||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java
|
||||||
|
|
|
@ -142,18 +142,19 @@ public class BreakpointManager extends Manager {
|
||||||
boolean suspendInferior(Target target) throws CDIException {
|
boolean suspendInferior(Target target) throws CDIException {
|
||||||
boolean shouldRestart = false;
|
boolean shouldRestart = false;
|
||||||
// Stop the program
|
// Stop the program
|
||||||
if (allowInterrupt) {
|
if (allowInterrupt && target.isRunning()) {
|
||||||
// Disable events.
|
// Disable events.
|
||||||
if (target.isRunning()) {
|
((EventManager)getSession().getEventManager()).allowProcessingEvents(false);
|
||||||
target.suspend();
|
target.suspend();
|
||||||
shouldRestart = true;
|
shouldRestart = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return shouldRestart;
|
return shouldRestart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resumeInferior(Target target, boolean shouldRestart) throws CDIException {
|
void resumeInferior(Target target, boolean shouldRestart) throws CDIException {
|
||||||
if (shouldRestart) {
|
if (shouldRestart) {
|
||||||
|
// Enable events again.
|
||||||
|
((EventManager)getSession().getEventManager()).allowProcessingEvents(true);
|
||||||
target.resume();
|
target.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,11 +224,13 @@ public class BreakpointManager extends Manager {
|
||||||
for (int i = 0; i < miBreakpoints.length; i++) {
|
for (int i = 0; i < miBreakpoints.length; i++) {
|
||||||
numbers[i] = miBreakpoints[i].getNumber();
|
numbers[i] = miBreakpoints[i].getNumber();
|
||||||
}
|
}
|
||||||
boolean state = suspendInferior(target);
|
|
||||||
|
boolean restart = false;
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
MIBreakEnable breakEnable = factory.createMIBreakEnable(numbers);
|
MIBreakEnable breakEnable = factory.createMIBreakEnable(numbers);
|
||||||
try {
|
try {
|
||||||
|
restart = suspendInferior(target);
|
||||||
miSession.postCommand(breakEnable);
|
miSession.postCommand(breakEnable);
|
||||||
MIInfo info = breakEnable.getMIInfo();
|
MIInfo info = breakEnable.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
@ -237,7 +240,7 @@ public class BreakpointManager extends Manager {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
// Resume the program and enable events.
|
// Resume the program and enable events.
|
||||||
resumeInferior(target, state);
|
resumeInferior(target, restart);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < miBreakpoints.length; i++) {
|
for (int i = 0; i < miBreakpoints.length; i++) {
|
||||||
miBreakpoints[i].setEnabled(true);
|
miBreakpoints[i].setEnabled(true);
|
||||||
|
@ -282,11 +285,12 @@ public class BreakpointManager extends Manager {
|
||||||
numbers[i] = miBreakpoints[i].getNumber();
|
numbers[i] = miBreakpoints[i].getNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean state = suspendInferior(target);
|
boolean restart = false;
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
MIBreakDisable breakDisable = factory.createMIBreakDisable(numbers);
|
MIBreakDisable breakDisable = factory.createMIBreakDisable(numbers);
|
||||||
try {
|
try {
|
||||||
|
restart = suspendInferior(target);
|
||||||
miSession.postCommand(breakDisable);
|
miSession.postCommand(breakDisable);
|
||||||
MIInfo info = breakDisable.getMIInfo();
|
MIInfo info = breakDisable.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
@ -295,7 +299,7 @@ public class BreakpointManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
resumeInferior(target, state);
|
resumeInferior(target, restart);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < miBreakpoints.length; i++) {
|
for (int i = 0; i < miBreakpoints.length; i++) {
|
||||||
miBreakpoints[i].setEnabled(false);
|
miBreakpoints[i].setEnabled(false);
|
||||||
|
@ -548,11 +552,12 @@ public class BreakpointManager extends Manager {
|
||||||
for (int i = 0; i < miBreakpoints.length; ++i) {
|
for (int i = 0; i < miBreakpoints.length; ++i) {
|
||||||
numbers[i] = miBreakpoints[i].getNumber();
|
numbers[i] = miBreakpoints[i].getNumber();
|
||||||
}
|
}
|
||||||
boolean state = suspendInferior(target);
|
boolean restart = false;
|
||||||
try {
|
try {
|
||||||
|
restart = suspendInferior(target);
|
||||||
deleteMIBreakpoints(miSession, numbers);
|
deleteMIBreakpoints(miSession, numbers);
|
||||||
} finally {
|
} finally {
|
||||||
resumeInferior(target, state);
|
resumeInferior(target, restart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,10 +687,11 @@ public class BreakpointManager extends Manager {
|
||||||
public void setLocationBreakpoint (LocationBreakpoint bkpt) throws CDIException {
|
public void setLocationBreakpoint (LocationBreakpoint bkpt) throws CDIException {
|
||||||
Target target = (Target)bkpt.getTarget();
|
Target target = (Target)bkpt.getTarget();
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
boolean state = suspendInferior(target);
|
|
||||||
MIBreakInsert[] breakInserts = createMIBreakInsert(bkpt);
|
MIBreakInsert[] breakInserts = createMIBreakInsert(bkpt);
|
||||||
List pointList = new ArrayList();
|
List pointList = new ArrayList();
|
||||||
|
boolean restart = false;
|
||||||
try {
|
try {
|
||||||
|
restart = suspendInferior(target);
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
boolean enable = bkpt.isEnabled();
|
boolean enable = bkpt.isEnabled();
|
||||||
for (int i = 0; i < breakInserts.length; i++) {
|
for (int i = 0; i < breakInserts.length; i++) {
|
||||||
|
@ -730,7 +736,7 @@ public class BreakpointManager extends Manager {
|
||||||
}
|
}
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
resumeInferior(target, state);
|
resumeInferior(target, restart);
|
||||||
}
|
}
|
||||||
MIBreakpoint[] allPoints = (MIBreakpoint[]) pointList.toArray(new MIBreakpoint[pointList.size()]);
|
MIBreakpoint[] allPoints = (MIBreakpoint[]) pointList.toArray(new MIBreakpoint[pointList.size()]);
|
||||||
bkpt.setMIBreakpoints(allPoints);
|
bkpt.setMIBreakpoints(allPoints);
|
||||||
|
@ -743,12 +749,13 @@ public class BreakpointManager extends Manager {
|
||||||
String expression = watchpoint.getWatchExpression();
|
String expression = watchpoint.getWatchExpression();
|
||||||
|
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
boolean state = suspendInferior(target);
|
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
MIBreakWatch breakWatch =
|
MIBreakWatch breakWatch =
|
||||||
factory.createMIBreakWatch(access, read, expression);
|
factory.createMIBreakWatch(access, read, expression);
|
||||||
MIBreakpoint[] points = null;
|
MIBreakpoint[] points = null;
|
||||||
|
boolean restart = false;
|
||||||
try {
|
try {
|
||||||
|
restart = suspendInferior(target);
|
||||||
miSession.postCommand(breakWatch);
|
miSession.postCommand(breakWatch);
|
||||||
MIBreakWatchInfo winfo = breakWatch.getMIBreakWatchInfo();
|
MIBreakWatchInfo winfo = breakWatch.getMIBreakWatchInfo();
|
||||||
if (winfo == null) {
|
if (winfo == null) {
|
||||||
|
@ -793,7 +800,7 @@ public class BreakpointManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
resumeInferior(target, state);
|
resumeInferior(target, restart);
|
||||||
}
|
}
|
||||||
watchpoint.setMIBreakpoints(points);
|
watchpoint.setMIBreakpoints(points);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,15 +78,20 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackInfoDepthInfo;
|
||||||
public class EventManager extends SessionObject implements ICDIEventManager, Observer {
|
public class EventManager extends SessionObject implements ICDIEventManager, Observer {
|
||||||
|
|
||||||
List list = Collections.synchronizedList(new ArrayList(1));
|
List list = Collections.synchronizedList(new ArrayList(1));
|
||||||
List tokenList = new ArrayList(1);
|
|
||||||
MIRunningEvent lastRunningEvent;
|
MIRunningEvent lastRunningEvent;
|
||||||
Command lastUserCommand = null;
|
Command lastUserCommand = null;
|
||||||
|
boolean fAllowProcessingEvents = true;
|
||||||
/**
|
/**
|
||||||
* Process the event from MI, do any state work on the CDI,
|
* Process the event from MI, do any state work on the CDI,
|
||||||
* and fire the corresponding CDI event.
|
* and fire the corresponding CDI event.
|
||||||
*/
|
*/
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
|
|
||||||
|
// Bailout early if we do not want to process any events.
|
||||||
|
if (!isAllowingProcessingEvents()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MIEvent miEvent = (MIEvent)arg;
|
MIEvent miEvent = (MIEvent)arg;
|
||||||
Session session = (Session)getSession();
|
Session session = (Session)getSession();
|
||||||
Target currentTarget = session.getTarget(miEvent.getMISession());
|
Target currentTarget = session.getTarget(miEvent.getMISession());
|
||||||
|
@ -95,9 +100,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
}
|
}
|
||||||
List cdiList = new ArrayList(1);
|
List cdiList = new ArrayList(1);
|
||||||
|
|
||||||
if (ignoreEventToken(miEvent.getToken())) {
|
if (miEvent instanceof MIStoppedEvent) {
|
||||||
// Ignore the event if it is on the ignore list.
|
|
||||||
} else if (miEvent instanceof MIStoppedEvent) {
|
|
||||||
if (processSuspendedEvent((MIStoppedEvent)miEvent)) {
|
if (processSuspendedEvent((MIStoppedEvent)miEvent)) {
|
||||||
cdiList.add(new SuspendedEvent(session, miEvent));
|
cdiList.add(new SuspendedEvent(session, miEvent));
|
||||||
}
|
}
|
||||||
|
@ -506,43 +509,11 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAllowingProcessingEvents() {
|
||||||
/**
|
return fAllowProcessingEvents;
|
||||||
* Ignore Event with token id.
|
|
||||||
*/
|
|
||||||
void disableEventToken(int token) {
|
|
||||||
tokenList.add(new Integer(token));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void allowProcessingEvents(boolean allowed) {
|
||||||
* Ignore events with token ids.
|
fAllowProcessingEvents = allowed;
|
||||||
*/
|
|
||||||
void disableEventTokens(int [] tokens) {
|
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
|
||||||
disableEventToken(tokens[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reenable sending events with this token.
|
|
||||||
*/
|
|
||||||
void enableEventToken(int token) {
|
|
||||||
Integer t = new Integer(token);
|
|
||||||
if (tokenList.contains(t)) {
|
|
||||||
tokenList.remove(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reenable sending events with this token.
|
|
||||||
*/
|
|
||||||
void enableEventTokens(int [] tokens) {
|
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
|
||||||
enableEventToken(tokens[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean ignoreEventToken(int token) {
|
|
||||||
return tokenList.contains(new Integer(token));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue