summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/elixir2
-rw-r--r--bin/elixir.bat2
-rwxr-xr-xbin/iex2
-rw-r--r--bin/iex.bat2
-rw-r--r--lib/elixir/lib/kernel.ex15
-rw-r--r--lib/elixir/lib/kernel/cli.ex12
-rw-r--r--lib/iex/lib/iex.ex11
7 files changed, 27 insertions, 19 deletions
diff --git a/bin/elixir b/bin/elixir
index 3aaa1d45a..5a8cd9d87 100755
--- a/bin/elixir
+++ b/bin/elixir
@@ -114,7 +114,7 @@ while [ $I -le $LENGTH ]; do
C=1
MODE="elixirc"
;;
- -v|--no-halt|--no-pry)
+ -v|--no-halt|--dbg)
C=1
;;
-e|-r|-pr|-pa|-pz|--app|--eval|--remsh|--dot-iex)
diff --git a/bin/elixir.bat b/bin/elixir.bat
index 9099df89d..2cbbb5485 100644
--- a/bin/elixir.bat
+++ b/bin/elixir.bat
@@ -143,7 +143,7 @@ if ""==!par:--app=! (set "parsElixir=!parsElixir! --app %~1" && shift && g
if ""==!par:--no-halt=! (set "parsElixir=!parsElixir! --no-halt" && goto startloop)
if ""==!par:--remsh=! (set "parsElixir=!parsElixir! --remsh %~1" && shift && goto startloop)
if ""==!par:--dot-iex=! (set "parsElixir=!parsElixir! --dot-iex %~1" && shift && goto startloop)
-if ""==!par:--no-pry=! (set "parsElixir=!parsElixir! --no-pry" && goto startloop)
+if ""==!par:--dbg=! (set "parsElixir=!parsElixir! --dbg %~1" && shift && goto startloop)
rem ******* ERLANG PARAMETERS **********************
if ""==!par:--boot=! (set "parsErlang=!parsErlang! -boot %~1" && shift && goto startloop)
if ""==!par:--boot-var=! (set "parsErlang=!parsErlang! -boot_var %~1 %~2" && shift && shift && goto startloop)
diff --git a/bin/iex b/bin/iex
index 9b734e212..b84e1b3dd 100755
--- a/bin/iex
+++ b/bin/iex
@@ -7,11 +7,11 @@ Usage: $(basename "$0") [options] [.exs file] [data]
The following options are exclusive to IEx:
+ --dbg pry Sets the backend for Kernel.dbg/2 to IEx.pry/0
--dot-iex "FILE" Evaluates FILE, line by line, to set up IEx' environment.
Defaults to evaluating .iex.exs or ~/.iex.exs, if any exists.
If FILE is empty, then no file will be loaded.
--remsh NAME Connects to a node using a remote shell.
- --no-pry Doesn't start pry sessions when dbg/2 is called.
It accepts all other options listed by "elixir --help".
USAGE
diff --git a/bin/iex.bat b/bin/iex.bat
index e8a1c1061..93a5fdfa8 100644
--- a/bin/iex.bat
+++ b/bin/iex.bat
@@ -11,12 +11,12 @@ echo Usage: %~nx0 [options] [.exs file] [data]
echo.
echo The following options are exclusive to IEx:
echo.
+echo --dbg pry Sets the backend for Kernel.dbg/2 to IEx.pry/0
echo --dot-iex "FILE" Evaluates FILE, line by line, to set up IEx' environment.
echo Defaults to evaluating .iex.exs or ~/.iex.exs, if any exists.
echo If FILE is empty, then no file will be loaded.
echo --remsh NAME Connects to a node using a remote shell
echo --werl Uses Erlang's Windows shell GUI (Windows only)
-echo --no-pry Doesn't start pry sessions when dbg/2 is called.
echo.
echo Set the IEX_WITH_WERL environment variable to always use werl.
echo It accepts all other options listed by "elixir --help".
diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex
index fc4c69c05..8a7a186d6 100644
--- a/lib/elixir/lib/kernel.ex
+++ b/lib/elixir/lib/kernel.ex
@@ -5870,17 +5870,16 @@ defmodule Kernel do
## `dbg` inside IEx
- IEx integrates with `dbg` to provide additional features:
+ You can enable IEx to replace `dbg` with its `IEx.pry/0` backend by calling:
- * If you have IEx running and you call `dbg`, it will start a `pry`
- session where you can interact with the imports, aliases, and
- variables of the current environment at the location of the `dbg` call
+ $ iex --dbg pry
- * If you call `dbg` at the end of a pipeline (using `|>`) within IEx,
- you are able to go through each step of the pipeline one by one by
- entering "next" (or "n")
+ In such cases, `dbg` will start a `pry` session where you can interact with
+ the imports, aliases, and variables of the current environment at the location
+ of the `dbg` call.
- * You can disable this behaviour by calling `iex --no-pry`
+ If you call `dbg` at the end of a pipeline (using `|>`) within IEx, you are able
+ to go through each step of the pipeline one by one by entering "next" (or "n").
Note `dbg` only supports stepping for pipelines (in other words, it can only
step through the code it sees). For general stepping, you can set breakpoints
diff --git a/lib/elixir/lib/kernel/cli.ex b/lib/elixir/lib/kernel/cli.ex
index 88dbf8a20..44db4a364 100644
--- a/lib/elixir/lib/kernel/cli.ex
+++ b/lib/elixir/lib/kernel/cli.ex
@@ -326,7 +326,7 @@ defmodule Kernel.CLI do
end
defp parse_argv(["+iex" | t], config) do
- parse_iex(t, %{config | pry: true})
+ parse_iex(t, config)
end
defp parse_argv(["-S", h | t], config) do
@@ -416,11 +416,17 @@ defmodule Kernel.CLI do
end
# These clauses are here so that Kernel.CLI does not error out with "unknown option"
+ defp parse_iex(["--dbg", backend | t], config) do
+ case backend do
+ "pry" -> parse_iex(t, %{config | pry: true})
+ "kernel" -> parse_iex(t, %{config | pry: false})
+ _ -> {:error, "--dbg : Unknown dbg backend #{inspect(backend)}"}
+ end
+ end
+
defp parse_iex(["--dot-iex", _ | t], config), do: parse_iex(t, config)
defp parse_iex(["--remsh", _ | t], config), do: parse_iex(t, config)
- defp parse_iex(["--no-pry" | t], config), do: parse_iex(t, %{config | pry: false})
-
defp parse_iex([h | t] = list, config) do
case h do
"-" <> _ -> shared_option?(list, config, &parse_iex(&1, &2))
diff --git a/lib/iex/lib/iex.ex b/lib/iex/lib/iex.ex
index 21f900160..4818021dc 100644
--- a/lib/iex/lib/iex.ex
+++ b/lib/iex/lib/iex.ex
@@ -173,7 +173,11 @@ defmodule IEx do
## `dbg` and breakpoints
IEx integrates with `Kernel.dbg/2` and introduces a backend that
- can pause code execution:
+ can pause code execution. To enable it, you must pass `--dbg pry`:
+
+ $ iex --dbg pry
+
+ For example, take the following function:
def my_fun(arg1, arg2) do
dbg(arg1 + arg2)
@@ -181,8 +185,8 @@ defmodule IEx do
end
When the code is executed with `iex` (most often by calling
- `iex -S mix`), it will ask you permission to use "pry". If you
- agree, it will start an IEx shell in the context of the function
+ `iex --dbg pry -S mix`), it will ask you permission to use "pry".
+ If you agree, it will start an IEx shell in the context of the function
above, with access to its variables, imports, and aliases. However,
you can only access existing values, it is not possible to access
private functions nor change the execution itself (hence the name
@@ -194,7 +198,6 @@ defmodule IEx do
of the steps but stay within the pried process. Type `respawn` when
you want to leave the pried process and start a new shell.
- You can disable "pry" as the `dbg/2` backend by calling `iex --no-pry`.
Alternatively, you can start a pry session directly, without `dbg/2`
by calling `IEx.pry/0`.