GP-5016: upping the number of states

This commit is contained in:
d-millar 2024-10-16 16:00:40 +00:00
parent 082cc1746e
commit 73ce6cf068
2 changed files with 30 additions and 10 deletions

View File

@ -334,13 +334,13 @@ public class TraceRmiTarget extends AbstractTarget {
ActionName.STEP_OUT.equals(name) || ActionName.STEP_OUT.equals(name) ||
ActionName.STEP_OVER.equals(name) || ActionName.STEP_OVER.equals(name) ||
ActionName.STEP_SKIP.equals(name)) { ActionName.STEP_SKIP.equals(name)) {
return () -> whenState(obj, state -> state != null && state.isStopped()); return () -> whenState(obj, state -> state != null && (state.isStopped() || state.isUnknown()));
} }
else if (ActionName.INTERRUPT.equals(name)) { else if (ActionName.INTERRUPT.equals(name)) {
return () -> whenState(obj, state -> state == null || state.isRunning()); return () -> whenState(obj, state -> state == null || state.isRunning() || state.isUnknown());
} }
else if (ActionName.KILL.equals(name)) { else if (ActionName.KILL.equals(name)) {
return () -> whenState(obj, state -> state == null || state.isAlive()); return () -> whenState(obj, state -> state == null || !state.isTerminated());
} }
return () -> true; return () -> true;
} }

View File

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -40,7 +40,7 @@ public interface TargetExecutionStateful extends TargetObject {
* This may apply, e.g., to a GDB "Inferior," which has no yet been used to launch or attach * This may apply, e.g., to a GDB "Inferior," which has no yet been used to launch or attach
* to a process. * to a process.
*/ */
INACTIVE(false, false, false), INACTIVE(false, false, false, false),
/** /**
* The object is alive, but its execution state is unspecified * The object is alive, but its execution state is unspecified
@ -52,12 +52,12 @@ public interface TargetExecutionStateful extends TargetObject {
* when <em>all</em> of its threads are stopped. For the clients' sakes, all models should * when <em>all</em> of its threads are stopped. For the clients' sakes, all models should
* implement these conventions internally. * implement these conventions internally.
*/ */
ALIVE(true, false, false), ALIVE(true, false, false, false),
/** /**
* The object is alive, but not executing * The object is alive, but not executing
*/ */
STOPPED(true, false, true), STOPPED(true, false, true, false),
/** /**
* The object is alive and executing * The object is alive and executing
@ -67,7 +67,7 @@ public interface TargetExecutionStateful extends TargetObject {
* thread is currently executing, waiting on an event, or scheduled for execution. It does * thread is currently executing, waiting on an event, or scheduled for execution. It does
* not necessarily mean it is executing on a CPU at this exact moment. * not necessarily mean it is executing on a CPU at this exact moment.
*/ */
RUNNING(true, true, false), RUNNING(true, true, false, false),
/** /**
* The object is no longer alive * The object is no longer alive
@ -77,16 +77,18 @@ public interface TargetExecutionStateful extends TargetObject {
* stale handles to objects which may still be queried (e.g., for a process exit code), or * stale handles to objects which may still be queried (e.g., for a process exit code), or
* e.g., a GDB "Inferior," which could be re-used to launch or attach to another process. * e.g., a GDB "Inferior," which could be re-used to launch or attach to another process.
*/ */
TERMINATED(false, false, false); TERMINATED(false, false, false, true);
private final boolean alive; private final boolean alive;
private final boolean running; private final boolean running;
private final boolean stopped; private final boolean stopped;
private final boolean terminated;
private TargetExecutionState(boolean alive, boolean running, boolean stopped) { private TargetExecutionState(boolean alive, boolean running, boolean stopped, boolean terminated) {
this.alive = alive; this.alive = alive;
this.running = running; this.running = running;
this.stopped = stopped; this.stopped = stopped;
this.terminated = terminated;
} }
/** /**
@ -115,6 +117,24 @@ public interface TargetExecutionStateful extends TargetObject {
public boolean isStopped() { public boolean isStopped() {
return stopped; return stopped;
} }
/**
* Check if this state implies the object was terminated
*
* @return true if terminated
*/
public boolean isTerminated() {
return terminated;
}
/**
* Check if this state is ambiguous
*
* @return true if terminated
*/
public boolean isUnknown() {
return !stopped && !running && !terminated;
}
} }
/** /**