# Debug function call macro

**URL:** <https://forum.elixirforum.com/t/debug-function-call-macro/54544>\
**Category:** Guides/Tuts/Tips/Info\
**Tags:** macros, discussion, suggestion\
**Created:** [March 13, 2023, 7:46pm UTC](https://forum.elixirforum.com/t/debug-function-call-macro/54544 "2023-03-13T19:46:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![KoviRobi](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kovirobi/32/29824_2.png) [@KoviRobi](https://forum.elixirforum.com/u/KoviRobi)\
**Post date:** [March 13, 2023, 10:36pm UTC](https://forum.elixirforum.com/t/debug-function-call-macro/54544/4 "2023-03-13T22:36:08Z")

</div>

Playing around with it, `dbg` seems to be able to do this, after I run `Application.put_env(:elixir, :dbg_callback, {Macro, :dbg, []})`. Though if I may segue a bit into using the Elixir debugger:

The reason I want to avoid actually doing a breakpoint is because I don’t know how to work around IEx breakpoints forgetting values. E.g.

```elixir
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> x = 123 # open some hardware
123
iex(2)> dbg(IO.inspect(1) + IO.inspect(2))
Break reached: iex:2
pry(1)> cont
warning: variable "cont" does not exist and is being expanded to "cont()", please use parentheses to remove the ambiguity or change the variable name
  iex:1

** (CompileError) iex:1: undefined function cont/0 (there is no such import)
    (elixir 1.14.3) src/elixir.erl:376: :elixir.quoted_to_erl/4
    (elixir 1.14.3) src/elixir.erl:277: :elixir.eval_forms/4
    (elixir 1.14.3) lib/module/parallel_checker.ex:110: Module.ParallelChecker.verify/1
    (iex 1.14.3) lib/iex/evaluator.ex:329: IEx.Evaluator.eval_and_inspect/3
    (iex 1.14.3) lib/iex/evaluator.ex:303: IEx.Evaluator.eval_and_inspect_parsed/3
    (iex 1.14.3) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
    (iex 1.14.3) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
pry(1)> continue
1
2
IO.inspect(1) + IO.inspect(2) #=> 3

3

Interactive Elixir (1.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> x
warning: variable "x" does not exist and is being expanded to "x()", please use parentheses to remove the ambiguity or change the variable name
  iex:1

** (CompileError) iex:1: undefined function x/0 (there is no such import)
    (elixir 1.14.3) src/elixir.erl:376: :elixir.quoted_to_erl/4
    (elixir 1.14.3) src/elixir.erl:277: :elixir.eval_forms/4
    (elixir 1.14.3) lib/module/parallel_checker.ex:110: Module.ParallelChecker.verify/1
    (iex 1.14.3) lib/iex/evaluator.ex:329: IEx.Evaluator.eval_and_inspect/3
    (iex 1.14.3) lib/iex/evaluator.ex:303: IEx.Evaluator.eval_and_inspect_parsed/3
    (iex 1.14.3) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
    (iex 1.14.3) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1

```

Is there a way to avoid IEx not forgetting my variables after a breakpoint? It is a big problem when the variable it forgets is some device I have opened (which seems to stay open in the background so I can’t even open it again).

And if I can ask something else, is there a way to add hooks to breakpoints? I.e. to execute a command when the breakpoint gets triggered, and then continue instead of waiting for user input.

---

_[View the full topic](https://forum.elixirforum.com/t/debug-function-call-macro/54544)._
