-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to wrap the functional form of @infiltrate
into a macro?
#94
Comments
seems to work fairly reliably and conveniently:
I'll include this macro in the readme/docs. |
Great, thanks a lot for the quick & helpful reply 🙏 |
Further testing revealed that there seems to be something broken with either how I use this or in the implementation: If I copy paste https://github.com/JuliaDebug/Infiltrator.jl#auto-loading-infiltratorjl to the REPL and define function foo(condition)
@autoinfiltrate condition
end then running
I think the issue here is that the argument gets expanded to julia> condition = true
true
julia> foo(true)
Infiltrating foo(condition::Bool)
at REPL[28]:2
infil> and as evidenced by julia> bar(condition) = @macroexpand @autoinfiltrate condition
bar (generic function with 3 methods)
julia> bar(true)
quote
#= /home/mschlott/.julia/packages/Infiltrator/r3Hf5/src/Infiltrator.jl:61 =#
if Main.condition
#= /home/mschlott/.julia/packages/Infiltrator/r3Hf5/src/Infiltrator.jl:62 =#
(Infiltrator.start_prompt)(Main, $(Expr(:locals)), "REPL[41]", 1)
end
end Unfortunately I am way out of my depth regarding metaprogramming here, but maybe you know how to fix this? |
Ah, yeah, I missed an |
Thanks, that seemed to do it 👍 |
For the life of me, I cannot remember how to type
Since I think Infiltrator.jl is a great tool for debugging and we like to use it when working with Trixi.jl, I thought about adding a macro to Trixi.jl such as
However, while this works functionally, it will produce the wrong information about where
infiltrate(...)
was called - I assume it's because the macro adds another stackframe and thusInfiltrator.jl/src/Infiltrator.jl
Line 253 in 112c8e2
should be a
+ 3
(or a+ 1
?) instead of+ 2
.Is there a way around this limitation, i.e., could I make it produce the correct stack frame by doing something different in my macro definition? Or is this just an inherent limitation and would require Infiltrator.jl itself to be changed?
The text was updated successfully, but these errors were encountered: