1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 239028

This change to MIRunControlEventProcessor does the same thing as before, but it avoids me having to deprecate an old method and create a new one.
This commit is contained in:
Marc Khouzam 2008-07-23 19:13:58 +00:00
parent c1f6612245
commit a0ce9be8f4

View file

@ -106,6 +106,7 @@ public class MIRunControlEventProcessor
public void eventReceived(Object output) {
for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) {
List<MIEvent<?>> events = new LinkedList<MIEvent<?>>();
if (oobr instanceof MIExecAsyncOutput) {
MIExecAsyncOutput exec = (MIExecAsyncOutput) oobr;
// Change of state.
@ -116,66 +117,35 @@ public class MIRunControlEventProcessor
fCommandControl.resetCurrentThreadLevel();
fCommandControl.resetCurrentStackLevel();
String threadId = null;
// For now, since GDB does not support thread-groups, fake an empty one
String groupId = "";//null; //$NON-NLS-1$
// I'm putting support for multiple reasons because it was
// there before, but I'm not sure this can actually happen
List<String> reasons = new LinkedList<String>();
MIResult[] results = exec.getMIResults();
for (int i = 0; i < results.length; i++) {
String var = results[i].getVariable();
MIValue val = results[i].getMIValue();
if (var.equals("reason")) { //$NON-NLS-1$
if (val instanceof MIConst) {
reasons.add(((MIConst) val).getString());
}
} else if (var.equals("thread-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
threadId = ((MIConst)val).getString();
}
} else if (var.equals("group-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
groupId = ((MIConst)val).getString();
String reason = ((MIConst) val).getString();
MIEvent<?> e = createEvent(reason, exec);
if (e != null) {
events.add(e);
continue;
}
}
}
}
// We were stopped for some unknown reason, for example
// GDB for temporary breakpoints will not send the
// "reason" ??? still fire a stopped event.
if (events.isEmpty()) {
MIEvent<?> e = createEvent(STOPPED_REASON, exec);
events.add(e);
}
// We were stopped for some unknown reason, for example
// GDB for temporary breakpoints will not send the
// "reason" ??? still fire a stopped event.
if (reasons.isEmpty()) {
reasons.add(STOPPED_REASON);
}
for (String reason : reasons) {
MIEvent<?> event = createEvent(reason, exec, threadId, groupId);
if (event != null) {
fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties());
}
}
for (MIEvent<?> event : events) {
fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties());
}
}
else if ("running".equals(state)) { //$NON-NLS-1$
String threadId = null;
// For now, since GDB does not support thread-groups, fake an empty one
String groupId = "";//null; //$NON-NLS-1$
MIResult[] results = exec.getMIResults();
for (int i = 0; i < results.length; i++) {
String var = results[i].getVariable();
MIValue val = results[i].getMIValue();
if (var.equals("thread-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
threadId = ((MIConst) val).getString();
}
} else if (var.equals("group-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
groupId = ((MIConst)val).getString();
}
}
}
MIEvent<?> event = createEvent(RUNNING_REASON, exec, threadId, groupId);
MIEvent<?> event = createEvent(RUNNING_REASON, exec);
if (event != null) {
fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties());
}
@ -221,36 +191,28 @@ public class MIRunControlEventProcessor
}
}
@Deprecated
protected MIEvent<?> createEvent(String reason, MIExecAsyncOutput exec) {
IMIRunControl runControl = fServicesTracker.getService(IMIRunControl.class);
MIEvent<?> event = null;
if ("breakpoint-hit".equals(reason)) { //$NON-NLS-1$
event = MIBreakpointHitEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if (
"watchpoint-trigger".equals(reason) //$NON-NLS-1$
|| "read-watchpoint-trigger".equals(reason) //$NON-NLS-1$
|| "access-watchpoint-trigger".equals(reason)) { //$NON-NLS-1$
event = MIWatchpointTriggerEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("watchpoint-scope".equals(reason)) { //$NON-NLS-1$
event = MIWatchpointScopeEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("end-stepping-range".equals(reason)) { //$NON-NLS-1$
event = MISteppingRangeEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("signal-received".equals(reason)) { //$NON-NLS-1$
event = MISignalEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("location-reached".equals(reason)) { //$NON-NLS-1$
event = MILocationReachedEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("function-finished".equals(reason)) { //$NON-NLS-1$
event = MIFunctionFinishedEvent.parse(runControl, fContainerDmc, exec.getToken(), exec.getMIResults());
} else if ("exited-normally".equals(reason) || "exited".equals(reason)) { //$NON-NLS-1$ //$NON-NLS-2$
event = MIInferiorExitEvent.parse(fCommandControl.getControlDMContext(), exec.getToken(), exec.getMIResults());
} else if ("exited-signalled".equals(reason)) { //$NON-NLS-1$
event = MIInferiorSignalExitEvent.parse(fCommandControl.getControlDMContext(), exec.getToken(), exec.getMIResults());
}
return event;
}
String threadId = null;
// For now, since GDB does not support thread-groups, fake an empty one
String groupId = "";//null; //$NON-NLS-1$
MIResult[] results = exec.getMIResults();
for (int i = 0; i < results.length; i++) {
String var = results[i].getVariable();
MIValue val = results[i].getMIValue();
if (var.equals("thread-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
threadId = ((MIConst)val).getString();
}
} else if (var.equals("group-id")) { //$NON-NLS-1$
if (val instanceof MIConst) {
groupId = ((MIConst)val).getString();
}
}
}
protected MIEvent<?> createEvent(String reason, MIExecAsyncOutput exec, String threadId, String groupId) {
IMIRunControl runControl = fServicesTracker.getService(IMIRunControl.class);
MIProcesses procService = fServicesTracker.getService(MIProcesses.class);
@ -301,7 +263,6 @@ public class MIRunControlEventProcessor
return event;
}
public void commandQueued(ICommandToken token) {
// Do nothing.
}