synchronized void disposeBreakpoint(Breakpoint breakpoint) { breakpoints.remove(breakpoint); if (Debugger.TRACE) { trace("disposed session breakpoint %s", breakpoint); } }
synchronized void disposeBreakpoint(Breakpoint breakpoint) { breakpoints.remove(breakpoint); if (Debugger.TRACE) { trace("disposed session breakpoint %s", breakpoint); } }
private void removeBindings() { assert Thread.holdsLock(this); if (syntaxElementsBinding != null) { allBindings.remove(syntaxElementsBinding); syntaxElementsBinding.dispose(); syntaxElementsBinding = null; if (Debugger.TRACE) { trace("disabled stepping"); } } }
/** * Resumes all suspended executions that have not yet been notified. * * @since 0.17 */ public synchronized void resumeAll() { if (Debugger.TRACE) { trace("resume all threads"); } if (closed) { throw new IllegalStateException("session closed"); } clearStrategies(); }
/** * Resumes all suspended executions that have not yet been notified. * * @since 0.17 */ public synchronized void resumeAll() { if (Debugger.TRACE) { trace("resume all threads"); } if (closed) { throw new IllegalStateException("session closed"); } clearStrategies(); }
private synchronized void setSteppingStrategy(Thread thread, SteppingStrategy strategy, boolean updateStepping) { if (closed) { return; } assert strategy != null; SteppingStrategy oldStrategy = this.strategyMap.put(thread, strategy); if (oldStrategy != strategy) { if (Debugger.TRACE) { trace("set stepping for thread: %s with strategy: %s", thread, strategy); } if (updateStepping) { updateStepping(); } } }
private synchronized void setSteppingStrategy(Thread thread, SteppingStrategy strategy, boolean updateStepping) { if (closed) { return; } assert strategy != null; SteppingStrategy oldStrategy = this.strategyMap.put(thread, strategy); if (oldStrategy != strategy) { if (Debugger.TRACE) { trace("set stepping for thread: %s with strategy: %s", thread, strategy); } if (updateStepping) { updateStepping(); } } }
synchronized void install(Breakpoint breakpoint, boolean global) { if (closed) { if (!global) { throw new IllegalStateException("Debugger session is already closed. Cannot install new breakpoints."); } else { return; } } if (!breakpoint.install(this, !global)) { return; } if (!global) { // Do not keep global breakpoints in the list this.breakpoints.add(breakpoint); } if (Debugger.TRACE) { trace("installed session breakpoint %s", breakpoint); } }
/** * Suspends the next execution on the first thread that is encountered. After the first thread * was suspended no further executions are suspended unless {@link #suspendNextExecution()} is * called again. If multiple threads are executing at the same time then there are no guarantees * on which thread is going to be suspended. Will throw an {@link IllegalStateException} if the * session is already closed. * * @since 0.17 */ public synchronized void suspendNextExecution() { if (Debugger.TRACE) { trace("suspend next execution"); } if (closed) { throw new IllegalStateException("session closed"); } suspendNext = true; updateStepping(); }
synchronized void install(Breakpoint breakpoint, boolean global) { if (closed) { if (!global) { throw new IllegalStateException("Debugger session is already closed. Cannot install new breakpoints."); } else { return; } } if (!breakpoint.install(this, !global)) { return; } if (!global) { // Do not keep global breakpoints in the list this.breakpoints.add(breakpoint); } if (Debugger.TRACE) { trace("installed session breakpoint %s", breakpoint); } }
/** * Suspends the next execution on the first thread that is encountered. After the first thread * was suspended no further executions are suspended unless {@link #suspendNextExecution()} is * called again. If multiple threads are executing at the same time then there are no guarantees * on which thread is going to be suspended. Will throw an {@link IllegalStateException} if the * session is already closed. * * @since 0.17 */ public synchronized void suspendNextExecution() { if (Debugger.TRACE) { trace("suspend next execution"); } if (closed) { throw new IllegalStateException("session closed"); } suspendNext = true; updateStepping(); }
/** * Suspends the current or the next execution of a given thread. Will throw an * {@link IllegalStateException} if the session is already closed. */ // TODO make part of public API as soon as PolyglotEngine is thread-safe void suspend(Thread t) { if (Debugger.TRACE) { trace("suspend thread %s ", t); } if (closed) { throw new IllegalStateException("session closed"); } setSteppingStrategy(t, SteppingStrategy.createAlwaysHalt(), true); }
/** * Resumes the execution on a given thread if it has not been suspended yet. * * @param t the thread to resume */ // TODO make part of public API as soon as PolyglotEngine is thread-safe synchronized void resume(Thread t) { if (Debugger.TRACE) { trace("resume threads", t); } if (closed) { throw new IllegalStateException("session closed"); } setSteppingStrategy(t, SteppingStrategy.createContinue(), true); }
/** * Suspends the current or the next execution of a given thread. Will throw an * {@link IllegalStateException} if the session is already closed. */ // TODO make part of public API as soon as PolyglotEngine is thread-safe void suspend(Thread t) { if (Debugger.TRACE) { trace("suspend thread %s ", t); } if (closed) { throw new IllegalStateException("session closed"); } setSteppingStrategy(t, SteppingStrategy.createAlwaysHalt(), true); }
DebuggerSession(Debugger debugger, SuspendedCallback callback, SourceElement... sourceElements) { this.sessionId = SESSIONS.incrementAndGet(); this.debugger = debugger; this.callback = callback; switch (sourceElements.length) { case 0: this.sourceElements = Collections.emptySet(); break; case 1: this.sourceElements = Collections.singleton(sourceElements[0]); break; default: this.sourceElements = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(sourceElements))); break; } this.hasExpressionElement = this.sourceElements.contains(SourceElement.EXPRESSION); if (Debugger.TRACE) { trace("open with callback %s", callback); } addBindings(includeInternal, sourceFilter); executionLifecycle = new DebuggerExecutionLifecycle(debugger); }
/** * Resumes the execution on a given thread if it has not been suspended yet. * * @param t the thread to resume */ // TODO make part of public API as soon as PolyglotEngine is thread-safe synchronized void resume(Thread t) { if (Debugger.TRACE) { trace("resume threads", t); } if (closed) { throw new IllegalStateException("session closed"); } setSteppingStrategy(t, SteppingStrategy.createContinue(), true); }
private void removeBindings() { assert Thread.holdsLock(this); if (syntaxElementsBinding != null) { callBinding.dispose(); syntaxElementsBinding.dispose(); callBinding = null; rootBinding.dispose(); rootBinding = null; syntaxElementsBinding = null; if (Debugger.TRACE) { trace("disabled stepping"); } } }
/** * Closes the current debugging session and disposes all installed breakpoints. * * @since 0.17 */ public synchronized void close() { if (Debugger.TRACE) { trace("close session"); } if (closed) { throw new IllegalStateException("session already closed"); } clearStrategies(); removeBindings(); for (Breakpoint breakpoint : this.breakpoints) { breakpoint.sessionClosed(this); } currentSuspendedEventMap.clear(); allBindings.clear(); debugger.disposedSession(this); closed = true; }
/** * Closes the current debugging session and disposes all installed breakpoints. * * @since 0.17 */ public synchronized void close() { if (Debugger.TRACE) { trace("close session"); } if (closed) { throw new IllegalStateException("session already closed"); } clearStrategies(); removeBindings(); for (Breakpoint breakpoint : this.breakpoints) { breakpoint.sessionClosed(this); } currentSuspendedEventMap.clear(); debugger.disposedSession(this); closed = true; }
/** * Suspends the current or the next execution on all threads. All new executing threads will * start suspended until {@link #resumeAll()} is called or the session is closed. Will throw an * {@link IllegalStateException} if the session is already closed. */ // TODO make part of public API as soon as PolyglotEngine is thread-safe synchronized void suspendAll() { if (Debugger.TRACE) { trace("suspend all threads"); } if (closed) { throw new IllegalStateException("session closed"); } suspendAll = true; // iterating concurrent hashmap should be save for (Thread t : strategyMap.keySet()) { SteppingStrategy s = strategyMap.get(t); assert s != null; if (s.isDone() || s.isConsumed()) { setSteppingStrategy(t, SteppingStrategy.createAlwaysHalt(), false); } } updateStepping(); }