diff options
author | brendandouglas <brendandouglas@google.com> | 2018-06-21 08:57:19 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-21 08:58:30 -0700 |
commit | 62f5bdc9074bbe4a6a85ff6bf4bdb313950e938c (patch) | |
tree | 9ec2cc33bb2b9dd0d150ebd6dcf31d1e17b0d1cb /src/main/java/com/google/devtools/build/lib/syntax | |
parent | 2b945323d2b4cf7dfdf988b9b04c4fb75e416206 (diff) |
Skylark debugging protocol: only track paused or stepping threads.
- remove blaze-side thread creation/destruction hooks
- remove ListThreads, ThreadStarted, ThreadEnded events from protocol
- don't track unpaused, not stepping threads in ThreadHandler
The threading model didn't provide useful information -- in practice,
users never want to list currently-running threads, and the debug
client doesn't need to list currently-paused threads, since it receives
each ThreadPaused and ThreadContinued event, so its model is always up to date.
Not tracking thread creation/destruction greatly simplifies the API, and
reduces the blaze-side hooks -- it was also only semi-implemented, as
plenty (/most?) skylark threads were never registered.
The biggest cost to removing this is lack of nice thread names. In
practice, I think the benefits greatly outweigh this cost. If it ever
becomes a problem, there are other lighter-weight ways of communicating
thread names.
TAG_CHANGE_OK=This proto has never yet been used
TYPE_CHANGE_OK=This proto has never yet been used
PiperOrigin-RevId: 201532462
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
3 files changed, 0 insertions, 47 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java index 801013b207..b584c5dc34 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java @@ -198,18 +198,6 @@ public class BuildFileAST extends ASTNode { * @return true if no error occurred during execution. */ public boolean exec(Environment env, EventHandler eventHandler) throws InterruptedException { - try { - // Handles debugging BUILD file evaluation - // TODO(bazel-team): add support for debugging skylark file evaluation - return DebugServerUtils.runWithDebuggingIfEnabled( - env, () -> Thread.currentThread().getName(), () -> doExec(env, eventHandler)); - } catch (EvalException e) { - // runWithDebuggingIfEnabled() shouldn't throw EvalException, since doExec() does not - throw new AssertionError("Unexpected EvalException", e); - } - } - - private boolean doExec(Environment env, EventHandler eventHandler) throws InterruptedException { boolean ok = true; for (Statement stmt : statements) { if (!execTopLevelStatement(stmt, env, eventHandler)) { diff --git a/src/main/java/com/google/devtools/build/lib/syntax/DebugServer.java b/src/main/java/com/google/devtools/build/lib/syntax/DebugServer.java index 6fe17238cd..ab2823cc46 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/DebugServer.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/DebugServer.java @@ -20,19 +20,6 @@ import java.util.function.Function; public interface DebugServer { /** - * Executes the given callable and returns its result, while making any skylark evaluation visible - * to the debugger. This method should be used to evaluate all debuggable Skylark code. - * - * @param env the Skylark execution environment - * @param threadName the descriptive name of the thread - * @param callable the callable object whose execution will be tracked - * @param <T> the result type of the callable - * @return the value returned by the callable - */ - <T> T runWithDebugging(Environment env, String threadName, DebugCallable<T> callable) - throws EvalException, InterruptedException; - - /** * Shuts down the debug server, closing any open sockets, etc. This can be safely called multiple * times. */ diff --git a/src/main/java/com/google/devtools/build/lib/syntax/DebugServerUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/DebugServerUtils.java index 808d10704a..aba83272db 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/DebugServerUtils.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/DebugServerUtils.java @@ -14,9 +14,7 @@ package com.google.devtools.build.lib.syntax; -import com.google.devtools.build.lib.syntax.DebugServer.DebugCallable; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; /** * A helper class for enabling/disabling skylark debugging. @@ -50,24 +48,4 @@ public final class DebugServerUtils { } Eval.removeCustomEval(); } - - /** - * Tracks the execution of the given callable object in the debug server. - * - * <p>If the skylark debugger is not enabled, runs {@code callable} directly. - * - * @param env the Skylark execution environment - * @param threadName the descriptive name of the thread - * @param callable the callable object whose execution will be tracked - * @param <T> the result type of the callable - * @return the value returned by the callable - */ - public static <T> T runWithDebuggingIfEnabled( - Environment env, Supplier<String> threadName, DebugCallable<T> callable) - throws EvalException, InterruptedException { - DebugServer server = instance.get(); - return server != null - ? server.runWithDebugging(env, threadName.get(), callable) - : callable.call(); - } } |