fix: concurrency issues with debug server
This commit is contained in:
parent
c971fde0e2
commit
afe4542682
@ -63,8 +63,6 @@ public class DebugServer {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(msg);
|
||||
|
||||
switch (msg.name) {
|
||||
case "Debugger.enable":
|
||||
synchronized (connNotifier) {
|
||||
@ -140,10 +138,7 @@ public class DebugServer {
|
||||
}
|
||||
|
||||
runAsync(() -> {
|
||||
var handle = new Thread(() -> {
|
||||
System.out.println("test");
|
||||
debugger.close();
|
||||
});
|
||||
var handle = new Thread(debugger::close);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(handle);
|
||||
|
||||
|
@ -955,6 +955,7 @@ public class SimpleDebugger implements Debugger {
|
||||
|
||||
obj = proto;
|
||||
own = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,7 +1016,7 @@ public class SimpleDebugger implements Debugger {
|
||||
ws.send(msg.respond());
|
||||
}
|
||||
|
||||
@Override public void onSourceLoad(Filename filename, String source) {
|
||||
@Override public synchronized void onSourceLoad(Filename filename, String source) {
|
||||
int id = nextId();
|
||||
var src = new DebugSource(id, filename, source);
|
||||
|
||||
@ -1025,7 +1026,7 @@ public class SimpleDebugger implements Debugger {
|
||||
if (!enabled) pendingSources.add(src);
|
||||
else sendSource(src);
|
||||
}
|
||||
@Override public void onFunctionLoad(FunctionBody body, FunctionMap map) {
|
||||
@Override public synchronized void onFunctionLoad(FunctionBody body, FunctionMap map) {
|
||||
for (var bpt : idToBreakpoint.values()) {
|
||||
bpt.addFunc(body, map);
|
||||
}
|
||||
@ -1120,7 +1121,7 @@ public class SimpleDebugger implements Debugger {
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override public void onFramePush(Environment env, Frame frame) {
|
||||
@Override public synchronized void onFramePush(Environment env, Frame frame) {
|
||||
var prevFrame = currFrame;
|
||||
updateFrames(env, 0);
|
||||
|
||||
@ -1128,7 +1129,7 @@ public class SimpleDebugger implements Debugger {
|
||||
stepOutFrame = currFrame;
|
||||
}
|
||||
}
|
||||
@Override public void onFramePop(Environment env, Frame frame) {
|
||||
@Override public synchronized void onFramePop(Environment env, Frame frame) {
|
||||
updateFrames(env, 1);
|
||||
|
||||
try { idToFrame.remove(codeFrameToFrame.remove(frame).id); }
|
||||
|
@ -23,7 +23,7 @@ public class DebugContext {
|
||||
private WeakHashMap<FunctionBody, FunctionMap> maps;
|
||||
private DebugHandler debugger;
|
||||
|
||||
public boolean attachDebugger(DebugHandler debugger) {
|
||||
public synchronized boolean attachDebugger(DebugHandler debugger) {
|
||||
if (this.debugger != null) return false;
|
||||
|
||||
if (sources != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user