Googler | 29eafdf | 2018-05-23 12:32:07 -0700 | [diff] [blame] | 1 | // Copyright 2018 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.devtools.build.lib.syntax; |
| 16 | |
| 17 | import com.google.auto.value.AutoValue; |
| 18 | import com.google.common.collect.ImmutableMap; |
| 19 | import com.google.devtools.build.lib.events.Location; |
| 20 | import javax.annotation.Nullable; |
| 21 | |
| 22 | /** The information about a single frame in a thread's stack trace relevant to the debugger. */ |
| 23 | @AutoValue |
| 24 | public abstract class DebugFrame { |
| 25 | /** The source location where the frame is currently paused. */ |
| 26 | @Nullable |
| 27 | public abstract Location location(); |
| 28 | |
| 29 | /** The name of the function that this frame represents. */ |
| 30 | public abstract String functionName(); |
| 31 | |
| 32 | /** |
| 33 | * The local bindings associated with the current lexical frame. For the outer-most scope this |
| 34 | * will be empty. |
| 35 | */ |
| 36 | public abstract ImmutableMap<String, Object> lexicalFrameBindings(); |
| 37 | |
| 38 | /** The global vars and builtins for this frame. May be shadowed by the lexical frame bindings. */ |
| 39 | public abstract ImmutableMap<String, Object> globalBindings(); |
| 40 | |
| 41 | public static Builder builder() { |
| 42 | return new AutoValue_DebugFrame.Builder().setLexicalFrameBindings(ImmutableMap.of()); |
| 43 | } |
| 44 | |
| 45 | /** Builder class for {@link DebugFrame}. */ |
| 46 | @AutoValue.Builder |
| 47 | public abstract static class Builder { |
| 48 | public abstract Builder setLocation(@Nullable Location location); |
| 49 | |
| 50 | public abstract Builder setFunctionName(String functionName); |
| 51 | |
| 52 | public abstract Builder setLexicalFrameBindings(ImmutableMap<String, Object> bindings); |
| 53 | |
| 54 | public abstract Builder setGlobalBindings(ImmutableMap<String, Object> bindings); |
| 55 | |
| 56 | public abstract DebugFrame build(); |
| 57 | } |
| 58 | } |