Break out of Infiltrator

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.

1 Like

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

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> 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
1 Like

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

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.

3 Likes

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

7 Likes

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 .

2 Likes