Skip to content

Commit 92452a3

Browse files
committed
Mention gotcha on Elixir v1.15, closes #1712
1 parent e874d49 commit 92452a3

File tree

1 file changed

+12
-45
lines changed

1 file changed

+12
-45
lines changed

getting-started/debugging.markdown

+12-45
Original file line numberDiff line numberDiff line change
@@ -118,50 +118,6 @@ When code calling `dbg` is executed via `iex`, IEx will ask you to "stop" the co
118118

119119
Similar to `dbg`, once a breakpoint is reached code execution stops until `continue` or `next` are invoked. However, `break!/2` does not have access to aliases and imports from the debugged code as it works on the compiled artifact rather than on source code.
120120

121-
## Debugger
122-
123-
For those who enjoy breakpoints but are rather interested in a visual debugger, Erlang/OTP ships with a graphical debugger conveniently named `:debugger`. Let's define a module in a file named `example.ex`:
124-
125-
```elixir
126-
defmodule Example do
127-
def double_sum(x, y) do
128-
hard_work(x, y)
129-
end
130-
131-
defp hard_work(x, y) do
132-
x = 2 * x
133-
y = 2 * y
134-
135-
x + y
136-
end
137-
end
138-
```
139-
140-
Now let's compile the file and run an IEx session:
141-
142-
```console
143-
$ elixirc example.ex
144-
$ iex
145-
```
146-
147-
Then start the debugger:
148-
149-
```elixir
150-
iex> :debugger.start()
151-
{:ok, #PID<0.87.0>}
152-
iex> :int.ni(Example)
153-
{:module, Example}
154-
iex> :int.break(Example, 3)
155-
:ok
156-
iex> Example.double_sum(1, 2)
157-
```
158-
159-
> If the `debugger` does not start, here is what may have happened: some package managers default to installing a minimized Erlang without WX bindings for GUI support. In some package managers, you may be able to replace the headless Erlang with a more complete package (look for packages named `erlang` vs `erlang-nox` on Debian/Ubuntu/Arch). In others managers, you may need to install a separate `erlang-wx` (or similarly named) package.
160-
161-
When you start the debugger, a Graphical User Interface will open on your machine. We call `:int.ni(Example)` to prepare our module for debugging and then add a breakpoint to line 3 with `:int.break(Example, 3)`. After we call our function, we can see our process with break status in the debugger:
162-
163-
<img src="/images/contents/debugger-elixir.gif" width="640" alt="Debugger GUI GIF" />
164-
165121
## Observer
166122

167123
For debugging complex systems, jumping at the code is not enough. It is necessary to have an understanding of the whole virtual machine, processes, applications, as well as set up tracing mechanisms. Luckily this can be achieved in Erlang with `:observer`. In your application:
@@ -171,7 +127,18 @@ $ iex
171127
iex> :observer.start()
172128
```
173129

174-
> Similar to the `debugger` note above, your package manager may require a separate installation in order to run Observer.
130+
> When running `iex` inside a project with `iex -S mix`, `observer` won't be available as a dependency. To do so, you will need to call the following functions before:
131+
>
132+
> ```elixir
133+
> iex> Mix.ensure_application!(:wx)
134+
> iex> Mix.ensure_application!(:runtime_tools)
135+
> iex> Mix.ensure_application!(:observer)
136+
> iex> :observer.start()
137+
> ```
138+
>
139+
> If any of the calls above fail, here is what may have happened: some package managers default to installing a minimized Erlang without WX bindings for GUI support. In some package managers, you may be able to replace the headless Erlang with a more complete package (look for packages named `erlang` vs `erlang-nox` on Debian/Ubuntu/Arch). In others managers, you may need to install a separate `erlang-wx` (or similarly named) package.
140+
>
141+
> There are conversations to improve this experience in future releases.
175142
176143
The above will open another Graphical User Interface that provides many panes to fully understand and navigate the runtime and your project:
177144

0 commit comments

Comments
 (0)