1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 15:25:49 +02:00

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.
This commit is contained in:
Alain Magloire 2002-10-09 01:59:24 +00:00
parent 2d34891d15
commit c6eacff948

View file

@ -28,9 +28,8 @@ public class MIInferior extends Process {
final static int SUSPENDED = 1; final static int SUSPENDED = 1;
final static int RUNNING = 2; final static int RUNNING = 2;
final static int TERMINATED = 4; final static int TERMINATED = 4;
final static int ATTACHED = 8;
boolean attached = false; boolean connected = false;
int exitCode = 0; int exitCode = 0;
int state = 0; int state = 0;
@ -154,7 +153,16 @@ public class MIInferior extends Process {
* @see java.lang.Process#destroy() * @see java.lang.Process#destroy()
*/ */
public void 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(); CommandFactory factory = session.getCommandFactory();
MIExecAbort abort = factory.createMIExecAbort(); MIExecAbort abort = factory.createMIExecAbort();
try { try {
@ -198,17 +206,16 @@ public class MIInferior extends Process {
return state == TERMINATED; return state == TERMINATED;
} }
public boolean isAttached() { public synchronized boolean isConnected() {
return attached; return connected;
} }
public synchronized void setAttached() { public synchronized void setConnected() {
attached = true; connected = true;
state |= ATTACHED;
} }
public synchronized void setDetached() { public synchronized void setDisconnected() {
attached = false; connected = false;
} }
public synchronized void setSuspended() { public synchronized void setSuspended() {