You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+32-8Lines changed: 32 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,13 @@ To start the debug session, press `F5` or click on associated **Run and Debug**
41
41
42
42
<imgwidth="1290"alt="Screen Shot 2021-10-23 at 9 40 02 PM"src="https://user-images.githubusercontent.com/50580/138579566-4171e37a-1e95-49ef-b5da-36e208a10cde.png">
43
43
44
-
Note that the `bazel build //:buildifier --experimental_skylark_debug` has been started in an integrated VSCode terminal. You should keep an eye on this terminal.
44
+
Note that the `bazel build //:buildifier --experimental_skylark_debug` has been
45
+
started in an integrated VSCode terminal. You should keep an eye on this
46
+
terminal.
45
47
46
-
For example, one reason that a debug session is immediately terminating is that the build files have already been parsed and remain cached by bazel's incrementality model.
48
+
For example, one reason that a debug session is immediately terminating is that
49
+
the build files have already been parsed and remain cached by bazel's
50
+
incrementality model.
47
51
48
52
You will likely want to make manual changes to the `.bzl` file of interest while
49
53
debugging to force bazel to re-evaluate that file and allow the debugger to
@@ -85,27 +89,47 @@ To run an `attach` debug session, create a corresponding attach configuration:
85
89
},
86
90
```
87
91
88
-
The `"debugServer": 4711` part is the default so it's not explicitly required. This is the TCP port VSCode will use to communicate with the debug adapter.
92
+
The `"debugServer": 4711` part is the default so it's not explicitly required.
93
+
This is the TCP port VSCode will use to communicate with the debug adapter.
89
94
90
-
To launch the adapter, run `bzl debug adapter`, or launch it from the component activity panel:
95
+
To launch the adapter, run `bzl debug adapter`, or launch it from the component
96
+
activity panel:
91
97
92
98
<imgwidth="1290"alt="Screen Shot 2021-10-23 at 10 01 56 PM"src="https://user-images.githubusercontent.com/50580/138580187-5e68a8ce-c61c-4908-9d89-4fc5d8253494.png">
93
99
94
100
This will start the debug adapter in an integrated terminal.
95
101
96
102
<imgwidth="1290"alt="Screen Shot 2021-10-23 at 10 02 06 PM"src="https://user-images.githubusercontent.com/50580/138580191-6488cd46-20fa-47d2-8fea-188020aeeb3c.png">
97
103
98
-
At this point, you'll need to manually run a `bazel build //something --experimental_skylark_debug` in the terminal of your choice.
104
+
At this point, you'll need to manually run a `bazel build //something
105
+
--experimental_skylark_debug` in the terminal of your choice.
99
106
100
107
Then, `F5` and start a debug session using the selected debug configuration.
101
108
109
+
> NOTE: see below regarding the `DEFAULT.WORKSPACE` file. Since the debug
110
+
> adapter will run a `bazel query` upon startup, you should always start the
111
+
> adapter before `--experimental_skylark_debug` (the server will be holding the
112
+
> workspace LOCK waiting for a client to attach; while the client is waiting for
113
+
> the LOCK to be released for the bazel query).
114
+
102
115
## DEFAULT.WORKSPACE
103
116
104
-
When a debug session starts from a clean slate, the starlark interpreter starts by parsing your `WORKSPACE` file.
117
+
When a debug session starts from a clean slate, the starlark interpreter starts
118
+
by parsing your `WORKSPACE` file.
105
119
106
120
Internally, bazel adds extra content to the front and back of your workspace
107
121
before actually slicing it into chunks (delimited by `load()` statements).
108
122
109
-
While the `/DEFAULT.WORKSPACE` and `/DEFAULT.WORKSPACE.SUFFIX` files only really exist in memory, for the sake of the debug experience, we can "fake" it by writing a mocks of these onto disk.
123
+
While the `/DEFAULT.WORKSPACE` and `/DEFAULT.WORKSPACE.SUFFIX` files only really
124
+
exist in memory, for the sake of the debug experience, we can "fake" it by
125
+
writing a mocks of these onto disk.
126
+
127
+
The files will be prepared automatically at `${bazel-bin}/DEFAULT.WORKSPACE` and
128
+
`${bazel-bin}/DEFAULT.WORKSPACE.SUFFIX`. The files are prepared via running
129
+
`bazel query //external:* --output build` and shifting the rules into their
130
+
corresponding line locations.
131
+
132
+
The issue that might trip you up is
110
133
111
-
To prepare these files, run `bzl debug default_workspace_content`. They are hardcoded to reside at `${workspace}/.bazel-out/DEFAULT.WORKSPACE`. If you don't have the `.bazel-out/` symlinks, it might not work.
0 commit comments