From c6eacff9481405f98714056ec5c974a0f2cba902 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 9 Oct 2002 01:59:24 +0000 Subject: [PATCH] Remove confusing ATTACHED variable and use the session type on MISession to decide on the right thing to do for destroy(). Renambe setAttached() etc.. for setConnected() and setDisconnected() to reduce confusion. --- .../eclipse/cdt/debug/mi/core/MIInferior.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java index 742cf54e2f8..972988b974e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java @@ -28,9 +28,8 @@ public class MIInferior extends Process { final static int SUSPENDED = 1; final static int RUNNING = 2; final static int TERMINATED = 4; - final static int ATTACHED = 8; - boolean attached = false; + boolean connected = false; int exitCode = 0; int state = 0; @@ -154,7 +153,16 @@ public class MIInferior extends Process { * @see java.lang.Process#destroy() */ public void destroy() { - if (isAttached() || (((state & ATTACHED) != ATTACHED) && !isTerminated())) { + // An inferior will be destroy():interrupt and kill if + // - For attach session: + // the inferior was not disconnected yet (no need to try + // to kill a disconnected program). + // - For Program session: + // if the inferior was not terminated. + // - For PostMortem(Core): noop + if ((session.isAttachSession() && isConnected()) || + (session.isProgramSession() && !isTerminated())) { + CommandFactory factory = session.getCommandFactory(); MIExecAbort abort = factory.createMIExecAbort(); try { @@ -198,17 +206,16 @@ public class MIInferior extends Process { return state == TERMINATED; } - public boolean isAttached() { - return attached; + public synchronized boolean isConnected() { + return connected; } - public synchronized void setAttached() { - attached = true; - state |= ATTACHED; + public synchronized void setConnected() { + connected = true; } - public synchronized void setDetached() { - attached = false; + public synchronized void setDisconnected() { + connected = false; } public synchronized void setSuspended() {