Skip to content

Commit

Permalink
Conditional Breakpoint got error code in reply:504 (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
testforstephen committed Oct 31, 2022
1 parent a6ca87a commit ec39583
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Microsoft Corporation and others.
* Copyright (c) 2017-2022 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -32,6 +32,15 @@ public interface IStackFrameManager {
*/
StackFrame[] reloadStackFrames(ThreadReference thread);

/**
* Refresh all stackframes from jdi thread.
*
* @param thread the jdi thread
* @param force Whether to load the whole frames if the thread's stackframes haven't been cached.
* @return all the stackframes in the specified thread
*/
StackFrame[] reloadStackFrames(ThreadReference thread, boolean force);

/**
* Refersh the stackframes starting from the specified depth and length.
*
Expand All @@ -48,4 +57,9 @@ public interface IStackFrameManager {
* @param thread the jdi thread
*/
void clearStackFrames(ThreadReference thread);

/**
* Clear the whole stackframes cache.
*/
void clearStackFrames();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ public synchronized StackFrame getStackFrame(StackFrameReference ref) {

@Override
public synchronized StackFrame[] reloadStackFrames(ThreadReference thread) {
return reloadStackFrames(thread, true);
}

@Override
public synchronized StackFrame[] reloadStackFrames(ThreadReference thread, boolean force) {
return threadStackFrameMap.compute(thread.uniqueID(), (key, old) -> {
try {
if (old == null || old.length == 0) {
return thread.frames().toArray(new StackFrame[0]);
if (force) {
return thread.frames().toArray(new StackFrame[0]);
} else {
return new StackFrame[0];
}
} else {
return thread.frames(0, old.length).toArray(new StackFrame[0]);
}
Expand Down Expand Up @@ -71,4 +80,9 @@ public synchronized StackFrame[] reloadStackFrames(ThreadReference thread, int s
public synchronized void clearStackFrames(ThreadReference thread) {
threadStackFrameMap.remove(thread.uniqueID());
}

@Override
public synchronized void clearStackFrames() {
threadStackFrameMap.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ private CompletableFuture<Response> resume(Requests.ContinueArguments arguments,
context.getExceptionManager().removeException(arguments.threadId);
allThreadsContinued = false;
DebugUtility.resumeThread(thread);
context.getStackFrameManager().clearStackFrames(thread);
checkThreadRunningAndRecycleIds(thread, context);
} else {
context.getStepResultManager().removeAllMethodResults();
context.getExceptionManager().removeAllExceptions();
resumeVM(context);
context.getStackFrameManager().clearStackFrames();
context.getRecyclableIdPool().removeAllObjects();
}
response.body = new Responses.ContinueResponseBody(allThreadsContinued);
Expand All @@ -175,6 +177,7 @@ private CompletableFuture<Response> resumeAll(Requests.ThreadOperationArguments
context.getExceptionManager().removeAllExceptions();
resumeVM(context);
context.getProtocolServer().sendEvent(new Events.ContinuedEvent(arguments.threadId, true));
context.getStackFrameManager().clearStackFrames();
context.getRecyclableIdPool().removeAllObjects();
return CompletableFuture.completedFuture(response);
}
Expand Down Expand Up @@ -280,6 +283,7 @@ private void resumeThread(ThreadReference thread, IDebugAdapterContext context)
context.getExceptionManager().removeException(threadId);
DebugUtility.resumeThread(thread, suspends);
context.getProtocolServer().sendEvent(new Events.ContinuedEvent(threadId));
context.getStackFrameManager().clearStackFrames(thread);
checkThreadRunningAndRecycleIds(thread, context);
}
} catch (ObjectCollectedException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private JDIThread getMockJDIThread(ThreadReference thread) {
@Override
protected synchronized void invokeComplete(int restoreTimeout) {
super.invokeComplete(restoreTimeout);
context.getStackFrameManager().reloadStackFrames(thread);
context.getStackFrameManager().reloadStackFrames(thread, false);
}
});
}
Expand Down

0 comments on commit ec39583

Please sign in to comment.