diff options
author | brendandouglas <brendandouglas@google.com> | 2018-06-08 16:00:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-08 16:02:01 -0700 |
commit | d53d72e2841cd7e2c007751415679f9ff8a73062 (patch) | |
tree | 24f6405196c21ab7e33c5af611b85e4b51f9491f /src/main/java/com/google/devtools/build | |
parent | 9c68c3a1bd50ee56b5b7592a5f2ff918b16a2bab (diff) |
Skylark debugging protocol: include frames information in ThreadPausedEvents.
This is almost always desirable -- if a thread is paused, the IDE expects
to know the context.
PiperOrigin-RevId: 199865078
Diffstat (limited to 'src/main/java/com/google/devtools/build')
3 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkdebug/proto/skylark_debugging.proto b/src/main/java/com/google/devtools/build/lib/skylarkdebug/proto/skylark_debugging.proto index ed398e70fa..649f2936e2 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkdebug/proto/skylark_debugging.proto +++ b/src/main/java/com/google/devtools/build/lib/skylarkdebug/proto/skylark_debugging.proto @@ -184,6 +184,11 @@ message ThreadEndedEvent { message ThreadPausedEvent { // The thread that was paused. Thread thread = 1; + + // The list of stack frames for the paused thread. The first element in the + // list represents the topmost frame (that is, the current innermost + // function). + repeated Frame frame = 2; } // An event indicating that a thread has continued execution after being paused. diff --git a/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/DebugEventHelper.java b/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/DebugEventHelper.java index 0254484062..aa2279f97d 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/DebugEventHelper.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/DebugEventHelper.java @@ -130,9 +130,9 @@ final class DebugEventHelper { .build(); } - static DebugEvent threadPausedEvent(Thread thread) { + static DebugEvent threadPausedEvent(Thread thread, Collection<Frame> frames) { return DebugEvent.newBuilder() - .setThreadPaused(ThreadPausedEvent.newBuilder().setThread(thread)) + .setThreadPaused(ThreadPausedEvent.newBuilder().setThread(thread).addAllFrame(frames)) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/ThreadHandler.java b/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/ThreadHandler.java index fd30c64e01..e1f74f9dd6 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/ThreadHandler.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkdebug/server/ThreadHandler.java @@ -225,6 +225,11 @@ final class ThreadHandler { } // no need to list frames within the synchronize block: threads can only be resumed in response // to a client request, and requests are handled serially + return listFrames(debuggable, pausedState); + } + + private static ImmutableList<SkylarkDebuggingProtos.Frame> listFrames( + Debuggable debuggable, PausedThreadState pausedState) { return debuggable .listFrames(pausedState.location) .stream() @@ -265,6 +270,7 @@ final class ThreadHandler { SkylarkDebuggingProtos.Thread threadProto; PausedThreadState pausedState; + Debuggable debuggable; synchronized (threads) { ThreadState thread = threads.get(threadId); if (thread == null) { @@ -276,13 +282,15 @@ final class ThreadHandler { transport.postEvent(DebugEventHelper.threadStartedEvent(threadId, fallbackThreadName)); thread = doRegisterThread(threadId, fallbackThreadName, env); } + debuggable = thread.debuggable; pausedState = new PausedThreadState(location); thread.pausedState = pausedState; // get proto after setting the paused state, so that it's up to date threadProto = getThreadProto(thread); } - transport.postEvent(DebugEventHelper.threadPausedEvent(threadProto)); + transport.postEvent( + DebugEventHelper.threadPausedEvent(threadProto, listFrames(debuggable, pausedState))); pausedState.semaphore.acquireUninterruptibly(); transport.postEvent( DebugEventHelper.threadContinuedEvent( |