Skip to content

Commit ec39583

Browse files
Conditional Breakpoint got error code in reply:504 (#453)
1 parent a6ca87a commit ec39583

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/IStackFrameManager.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017 Microsoft Corporation and others.
2+
* Copyright (c) 2017-2022 Microsoft Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -32,6 +32,15 @@ public interface IStackFrameManager {
3232
*/
3333
StackFrame[] reloadStackFrames(ThreadReference thread);
3434

35+
/**
36+
* Refresh all stackframes from jdi thread.
37+
*
38+
* @param thread the jdi thread
39+
* @param force Whether to load the whole frames if the thread's stackframes haven't been cached.
40+
* @return all the stackframes in the specified thread
41+
*/
42+
StackFrame[] reloadStackFrames(ThreadReference thread, boolean force);
43+
3544
/**
3645
* Refersh the stackframes starting from the specified depth and length.
3746
*
@@ -48,4 +57,9 @@ public interface IStackFrameManager {
4857
* @param thread the jdi thread
4958
*/
5059
void clearStackFrames(ThreadReference thread);
60+
61+
/**
62+
* Clear the whole stackframes cache.
63+
*/
64+
void clearStackFrames();
5165
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/StackFrameManager.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@ public synchronized StackFrame getStackFrame(StackFrameReference ref) {
3232

3333
@Override
3434
public synchronized StackFrame[] reloadStackFrames(ThreadReference thread) {
35+
return reloadStackFrames(thread, true);
36+
}
37+
38+
@Override
39+
public synchronized StackFrame[] reloadStackFrames(ThreadReference thread, boolean force) {
3540
return threadStackFrameMap.compute(thread.uniqueID(), (key, old) -> {
3641
try {
3742
if (old == null || old.length == 0) {
38-
return thread.frames().toArray(new StackFrame[0]);
43+
if (force) {
44+
return thread.frames().toArray(new StackFrame[0]);
45+
} else {
46+
return new StackFrame[0];
47+
}
3948
} else {
4049
return thread.frames(0, old.length).toArray(new StackFrame[0]);
4150
}
@@ -71,4 +80,9 @@ public synchronized StackFrame[] reloadStackFrames(ThreadReference thread, int s
7180
public synchronized void clearStackFrames(ThreadReference thread) {
7281
threadStackFrameMap.remove(thread.uniqueID());
7382
}
83+
84+
@Override
85+
public synchronized void clearStackFrames() {
86+
threadStackFrameMap.clear();
87+
}
7488
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ThreadsRequestHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ private CompletableFuture<Response> resume(Requests.ContinueArguments arguments,
159159
context.getExceptionManager().removeException(arguments.threadId);
160160
allThreadsContinued = false;
161161
DebugUtility.resumeThread(thread);
162+
context.getStackFrameManager().clearStackFrames(thread);
162163
checkThreadRunningAndRecycleIds(thread, context);
163164
} else {
164165
context.getStepResultManager().removeAllMethodResults();
165166
context.getExceptionManager().removeAllExceptions();
166167
resumeVM(context);
168+
context.getStackFrameManager().clearStackFrames();
167169
context.getRecyclableIdPool().removeAllObjects();
168170
}
169171
response.body = new Responses.ContinueResponseBody(allThreadsContinued);
@@ -175,6 +177,7 @@ private CompletableFuture<Response> resumeAll(Requests.ThreadOperationArguments
175177
context.getExceptionManager().removeAllExceptions();
176178
resumeVM(context);
177179
context.getProtocolServer().sendEvent(new Events.ContinuedEvent(arguments.threadId, true));
180+
context.getStackFrameManager().clearStackFrames();
178181
context.getRecyclableIdPool().removeAllObjects();
179182
return CompletableFuture.completedFuture(response);
180183
}
@@ -280,6 +283,7 @@ private void resumeThread(ThreadReference thread, IDebugAdapterContext context)
280283
context.getExceptionManager().removeException(threadId);
281284
DebugUtility.resumeThread(thread, suspends);
282285
context.getProtocolServer().sendEvent(new Events.ContinuedEvent(threadId));
286+
context.getStackFrameManager().clearStackFrames(thread);
283287
checkThreadRunningAndRecycleIds(thread, context);
284288
}
285289
} catch (ObjectCollectedException ex) {

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/eval/JdtEvaluationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private JDIThread getMockJDIThread(ThreadReference thread) {
317317
@Override
318318
protected synchronized void invokeComplete(int restoreTimeout) {
319319
super.invokeComplete(restoreTimeout);
320-
context.getStackFrameManager().reloadStackFrames(thread);
320+
context.getStackFrameManager().reloadStackFrames(thread, false);
321321
}
322322
});
323323
}

0 commit comments

Comments
 (0)