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