diff --git a/src/main/java/me/topchetoeu/jscript/repl/debug/DebugServer.java b/src/main/java/me/topchetoeu/jscript/repl/debug/DebugServer.java index 92fa9a2..718b00b 100644 --- a/src/main/java/me/topchetoeu/jscript/repl/debug/DebugServer.java +++ b/src/main/java/me/topchetoeu/jscript/repl/debug/DebugServer.java @@ -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); diff --git a/src/main/java/me/topchetoeu/jscript/repl/debug/SimpleDebugger.java b/src/main/java/me/topchetoeu/jscript/repl/debug/SimpleDebugger.java index d1dca69..7b34330 100644 --- a/src/main/java/me/topchetoeu/jscript/repl/debug/SimpleDebugger.java +++ b/src/main/java/me/topchetoeu/jscript/repl/debug/SimpleDebugger.java @@ -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); } diff --git a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java index 0431cff..860f8bb 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java @@ -23,7 +23,7 @@ public class DebugContext { private WeakHashMap maps; private DebugHandler debugger; - public boolean attachDebugger(DebugHandler debugger) { + public synchronized boolean attachDebugger(DebugHandler debugger) { if (this.debugger != null) return false; if (sources != null) {