# Break out of Infiltrator

**URL:** <https://discourse.julialang.org/t/break-out-of-infiltrator/124134>\
**Category:** General Usage\
**Tags:** debugging, infiltrator\
**Created:** [December 23, 2024, 6:36pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134 "2024-12-23T18:36:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ken\_Williams](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_williams/32/5289_2.png) [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Post date:** [December 23, 2024, 6:36pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/1 "2024-12-23T18:36:05Z")

</div>

Is there some way to break completely out of `Infiltrator`’s `@infiltrate` mode and return to the REPL, not executing any further code? Just like a “stop” button would in most IDEs’ debugging modes.

I see the `@exit` macro, but that seems to only disable all `@infiltrate` macros while continuing to execute all the code scheduled to execute.

The closest I’ve come is `@exit` and then hit Control-C, but that’s very unreliable (sometimes the code isn’t easily stopped with a signal) and sometimes really undesirable (if I know the code is going to do something I really don’t want it to do).

Maybe throwing an exception somehow? A manual `error()` seems to just give me the `infil>` prompt again.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [December 23, 2024, 7:28pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/2 "2024-12-23T19:28:38Z")

</div>

How about this macro? After `@exit`, the code asks the user if the program execution should be stopped.

```julia
macro my_infiltrate()
    quote
        @infiltrate
        println("Stop execution? [Y/N]")
        response = readline(stdin)
        if lowercase(response[1]) == 'y'
            error("User requested stop.")
        end
    end
end

```

Test:

```julia
julia> function f(x)
           x_plus_1 = x + 1
           @my_infiltrate
           return x_plus_1^2
       end
f (generic function with 1 method)

julia> f(3)
Infiltrating macro expansion
  at REPL[2]:3

infil> x_plus_1
4

infil> @exit

Stop execution? [Y/N]
y
ERROR: User requested stop.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] macro expansion
   @ ./REPL[2]:7 [inlined]
 [3] f(x::Int64)
   @ Main ./REPL[3]:3
 [4] top-level scope
   @ REPL[4]:1
 [5] top-level scope
   @ none:1

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 28, 2025, 12:14pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/3 "2025-07-28T12:14:42Z")

</div>

> [@Ken\_Williams](#):
>
> The closest I’ve come is `@exit` and then hit Control-C, but that’s very unreliable

Have you sorted out this issue?

I used Infiltrator.jl for the first time to debug a function, which was fantastic. However, neither `@exit` nor `Ctrl+C` worked for me.  
After waiting a long time, I had to kill the standalone Julia terminal.

_ **PS:** _  
_Windows 11, Julia Version 1.11.6, Infiltrator v1.9.2_

---

<div class="post-metadata">

**Author:** ![Ken\_Williams](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_williams/32/5289_2.png) [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Post date:** [July 28, 2025, 10:24pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/4 "2025-07-28T22:24:16Z")

</div>

Unfortunately I haven’t found a nice solution for this, no.

The problem with `my_infiltrate` above is that I have to remember to use that instead of `Main.infiltrate`, and it also makes the whole infiltrating experience much more noisy.

Also - what’s crazy is that I found myself searching the internet today for this, then was surprised to find my own self asking the question previously, (though this tends to happen to me pretty regularly), but REALLY surprised to see your response after 7 months, the very same day I went looking for a solution (again).

Anyway I would love it if `Infiltrator.jl` provided one of its macros to just break out altogether.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 5, 2025, 7:57am UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/5 "2025-08-05T07:57:52Z")

</div>

Infiltrator 1.9.3 now has the `@abort` command, which throws an exception to try and stop program execution altogether.

---

<div class="post-metadata">

**Author:** ![Ken\_Williams](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_williams/32/5289_2.png) [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Post date:** [August 12, 2025, 3:41pm UTC](https://discourse.julialang.org/t/break-out-of-infiltrator/124134/6 "2025-08-12T15:41:51Z")

</div>

I’ve been using this feature this past week and it’s been super helpful, thanks @pfitzseb!

For anyone curious to see the implementation, see [Break out of Infiltrator directly · Issue #148 · JuliaDebug/Infiltrator.jl · GitHub](https://github.com/JuliaDebug/Infiltrator.jl/issues/148) .
