GP-908: Proper reporting of thread states in GDB.

This commit is contained in:
Dan 2021-04-30 12:36:04 -04:00
parent b150c557fc
commit 36d2f6dc99
2 changed files with 19 additions and 14 deletions

View File

@ -70,6 +70,7 @@ public class GdbModelTargetThread
protected String display;
protected String shortDisplay;
protected GdbThreadInfo info;
protected TargetExecutionState state = TargetExecutionState.INACTIVE;
private Integer base = 10;
protected final GdbModelTargetStack stack;
@ -85,7 +86,7 @@ public class GdbModelTargetThread
this.stack = new GdbModelTargetStack(this, inferior);
changeAttributes(List.of(), List.of(stack), Map.of( //
STATE_ATTRIBUTE_NAME, convertState(thread.getState()), //
STATE_ATTRIBUTE_NAME, state = convertState(thread.getState()), //
SUPPORTED_STEP_KINDS_ATTRIBUTE_NAME, SUPPORTED_KINDS, //
SHORT_DISPLAY_ATTRIBUTE_NAME, shortDisplay = computeShortDisplay(), //
DISPLAY_ATTRIBUTE_NAME, display = computeDisplay() //
@ -119,7 +120,7 @@ public class GdbModelTargetThread
sb.append(" ");
sb.append(info.getInferiorName());
sb.append(" ");
sb.append(info.getState());
sb.append(state.name().toLowerCase());
sb.append(" ");
List<GdbFrameInfo> frames = info.getFrames();
if (!frames.isEmpty()) {
@ -237,15 +238,15 @@ public class GdbModelTargetThread
}
public CompletableFuture<Void> stateChanged(GdbStateChangeRecord sco) {
GdbState state = sco.getState();
GdbState gdbState = sco.getState();
CompletableFuture<Void> result = AsyncUtils.NIL;
if (state == GdbState.STOPPED) {
if (gdbState == GdbState.STOPPED) {
Msg.debug(this, "Updating stack for " + this);
result = CompletableFuture.allOf(updateInfo(), stack.stateChanged(sco));
}
TargetExecutionState targetState = convertState(state);
changeAttributes(List.of(), Map.of( //
STATE_ATTRIBUTE_NAME, targetState //
STATE_ATTRIBUTE_NAME, state = convertState(gdbState), //
DISPLAY_ATTRIBUTE_NAME, display = computeDisplay() //
), sco.getReason().desc());
return result;
}

View File

@ -128,22 +128,26 @@ public class GdbModelTargetThreadContainer
* =thread-exited, we will wind up invalidating that thread early.
*/
if (sco.getState() != GdbState.STOPPED) {
return AsyncUtils.NIL;
return updateThreadStates(sco);
}
return requestElements(false).thenCompose(__ -> {
AsyncFence fence = new AsyncFence();
for (GdbThread thread : inferior.getKnownThreads().values()) {
GdbModelTargetThread targetThread =
(GdbModelTargetThread) impl.getModelObject(thread);
fence.include(targetThread.stateChanged(sco));
}
return fence.ready();
return updateThreadStates(sco);
}).exceptionally(__ -> {
Msg.error(this, "Could not update threads " + this + " on STOPPED");
return null;
});
}
protected CompletableFuture<Void> updateThreadStates(GdbStateChangeRecord sco) {
AsyncFence fence = new AsyncFence();
for (GdbThread thread : inferior.getKnownThreads().values()) {
GdbModelTargetThread targetThread =
(GdbModelTargetThread) impl.getModelObject(thread);
fence.include(targetThread.stateChanged(sco));
}
return fence.ready();
}
public GdbModelTargetBreakpointLocation breakpointHit(GdbBreakpointHitReason reason) {
GdbThread thread = impl.gdb.getThread(reason.getThreadId());
return getTargetThread(thread).breakpointHit(reason);