mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 09:45:39 +02:00
2004-09-12 Alain Magloire
Since MISession is attach to the Target, the way we fire termination events must change also. * cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java * src/org/eclipse/cdt/debug/mi/core/MISession.java
This commit is contained in:
parent
057edb19f3
commit
7c28610f55
6 changed files with 45 additions and 9 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-09-12 Alain Magloire
|
||||
Since MISession is attach to the Target, the
|
||||
way we fire termination events must change also.
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
|
||||
* src/org/eclipse/cdt/debug/mi/core/MISession.java
|
||||
|
||||
2004-09-09 Alain Magloire
|
||||
Introduction of new classes in the CDI interface
|
||||
ICDIExecuteStep
|
||||
|
|
|
@ -162,7 +162,11 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
} else if (miEvent instanceof MIInferiorExitEvent) {
|
||||
cdiList.add(new ExitedEvent(session, (MIInferiorExitEvent)miEvent));
|
||||
} else if (miEvent instanceof MIGDBExitEvent) {
|
||||
cdiList.add(new DestroyedEvent(session));
|
||||
// Remove the target from the list.
|
||||
Target target = session.getTarget(miEvent.getMISession());
|
||||
if (target != null) {
|
||||
session.removeTargets(new Target[] { target });
|
||||
}
|
||||
} else if (miEvent instanceof MIDetachedEvent) {
|
||||
cdiList.add(new DisconnectedEvent(session, (MIDetachedEvent)miEvent));
|
||||
} else if (miEvent instanceof MIBreakpointDeletedEvent) {
|
||||
|
@ -233,11 +237,14 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
list.remove(listener);
|
||||
}
|
||||
|
||||
public void removeEventListeners() {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send ICDIEvent to the listeners.
|
||||
*/
|
||||
private void fireEvents(ICDIEvent[] cdiEvents) {
|
||||
public void fireEvents(ICDIEvent[] cdiEvents) {
|
||||
if (cdiEvents != null && cdiEvents.length > 0) {
|
||||
ICDIEventListener[] listeners = (ICDIEventListener[])list.toArray(new ICDIEventListener[0]);
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
|
|
|
@ -63,7 +63,6 @@ public class ProcessManager extends Manager {
|
|||
Target target = targets[i];
|
||||
MISession miSession = target.getMISession();
|
||||
if (miSession != null) {
|
||||
miSession.notifyObservers(new MIInferiorExitEvent(miSession, 0));
|
||||
miSession.deleteObserver(eventManager);
|
||||
}
|
||||
if (currentTarget != null && currentTarget.equals(target)) {
|
||||
|
|
|
@ -26,9 +26,11 @@ import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
|
|||
import org.eclipse.cdt.debug.core.cdi.ICDISignalManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.event.DestroyedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory;
|
||||
|
@ -245,12 +247,30 @@ public class Session implements ICDISession, ICDISessionObject {
|
|||
ProcessManager pMgr = getProcessManager();
|
||||
Target[] targets = pMgr.getTargets();
|
||||
for (int i = 0; i < targets.length; ++i) {
|
||||
if (!targets[i].isTerminated()) {
|
||||
targets[i].terminate();
|
||||
if (!targets[i].getMISession().isTerminated()) {
|
||||
targets[i].getMISession().terminate();
|
||||
}
|
||||
}
|
||||
//TODO: the ExitEvent is sent by MISession.terminate()
|
||||
// We nee move it here.
|
||||
// Do not do the removeTargets(), Target.getMISession().terminate() will do it
|
||||
// via an event, MIGDBExitEvent of the mi session
|
||||
//removeTargets(targets);
|
||||
|
||||
// wait ~2 seconds for the targets to be terminated.
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
targets = pMgr.getTargets();
|
||||
if (targets.length == 0) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
// send our goodbyes.
|
||||
EventManager eMgr = (EventManager)getEventManager();
|
||||
eMgr.fireEvents(new ICDIEvent[] { new DestroyedEvent(this) });
|
||||
eMgr.removeEventListeners();
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
|
|
|
@ -653,8 +653,6 @@ public class Target implements ICDITarget {
|
|||
miSession.getMIInferior().terminate();
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
miSession.terminate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -482,6 +482,9 @@ public class MISession extends Observable {
|
|||
|
||||
// Tell the observers that the session is terminated
|
||||
notifyObservers(new MIGDBExitEvent(this, 0));
|
||||
|
||||
// Should not be necessary but just to be safe.
|
||||
deleteObservers();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue