fix: detach debugger after close

This commit is contained in:
TopchetoEU 2024-03-30 10:22:12 +02:00
parent 7cb267b0d9
commit c291328cc3
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 11 additions and 3 deletions

View File

@ -36,6 +36,10 @@ public class DebugContext {
this.debugger = debugger; this.debugger = debugger;
return true; return true;
} }
public boolean detachDebugger(DebugHandler debugger) {
if (this.debugger != debugger) return false;
return detachDebugger();
}
public boolean detachDebugger() { public boolean detachDebugger() {
this.debugger = null; this.debugger = null;
return true; return true;

View File

@ -205,6 +205,7 @@ public class SimpleDebugger implements Debugger {
private ObjectValue emptyObject = new ObjectValue(); private ObjectValue emptyObject = new ObjectValue();
private WeakHashMap<DebugContext, DebugContext> contexts = new WeakHashMap<>();
private WeakHashMap<FunctionBody, FunctionMap> mappings = new WeakHashMap<>(); private WeakHashMap<FunctionBody, FunctionMap> mappings = new WeakHashMap<>();
private WeakHashMap<FunctionBody, HashMap<Location, Breakpoint>> bpLocs = new WeakHashMap<>(); private WeakHashMap<FunctionBody, HashMap<Location, Breakpoint>> bpLocs = new WeakHashMap<>();
@ -642,11 +643,10 @@ public class SimpleDebugger implements Debugger {
execptionType = CatchType.NONE; execptionType = CatchType.NONE;
state = State.RESUMED; state = State.RESUMED;
// idToBptCand.clear(); mappings.clear();
bpLocs.clear();
idToBreakpoint.clear(); idToBreakpoint.clear();
// locToBreakpoint.clear();
// tmpBreakpts.clear();
filenameToId.clear(); filenameToId.clear();
idToSource.clear(); idToSource.clear();
@ -664,6 +664,9 @@ public class SimpleDebugger implements Debugger {
stepOutFrame = currFrame = null; stepOutFrame = currFrame = null;
stepOutPtr = 0; stepOutPtr = 0;
for (var ctx : contexts.keySet()) ctx.detachDebugger(this);
contexts.clear();
updateNotifier.next(); updateNotifier.next();
} }
@ -1041,6 +1044,7 @@ public class SimpleDebugger implements Debugger {
public SimpleDebugger attach(DebugContext ctx) { public SimpleDebugger attach(DebugContext ctx) {
ctx.attachDebugger(this); ctx.attachDebugger(this);
contexts.put(ctx, ctx);
return this; return this;
} }