Cthulhu.BOOKMARKS
— ConstantCthulhu.BOOKMARKS :: Vector{Bookmark}
During a descent, methods can be "bookmarked" by pressing b
key. It pushes a Cthulhu.Bookmark
into Cthulhu.BOOKMARKS
. This can be used to, e.g., continue descending by descend(Cthulhu.BOOKMARKS[end])
. See Cthulhu.Bookmark
for other usages.
Cthulhu.CONFIG
— ConstantCthulhu.CONFIG
Options
enable_highlighter::Bool
: Use command linehighlighter
to syntax highlight Julia, LLVM and native code.highlighter::Cmd
: A command line program that receives "julia" as an argument and julia code as stdin. Defaults to $pygmentize -l$.asm_syntax::Symbol
: Set the syntax of assembly code being used. Defaults toatt
.dead_code_elimination::Bool
: Enable dead-code elimination for high-level Julia IR. Defaults totrue
. DCE is known to be buggy and you may want to disable it if you encounter errors. Please report such bugs with a MWE to Julia or Cthulhu.pretty_ast::Bool
: Use a pretty printer for the ast dump. Defaults tofalse
.interruptexc::Bool
: Use <q>-key to quit or ascend. Defaults tofalse
.debuginfo::Symbol
: Initial state of "debuginfo" toggle. Defaults to:compact
. Options:.:none
,:compact
,:source
optimize::Bool
: Initial state of "optimize" toggle. Defaults totrue
.hide_type_stable::Bool
: Initial state of "hidetypestable" toggle. Defaults tofalse
.iswarn::Bool
: Initial state of "warn" toggle. Defaults tofalse
.remarks::Bool
Initial state of "remarks" toggle. Defaults tofalse
.with_effects::Bool
Intial state of "effects" toggle. Defaults tofalse
.exception_type::Bool
Intial state of "exception type" toggle. Defaults to
false`.inline_cost::Bool
Initial state of "inlining costs" toggle. Defaults tofalse
.type_annotations::Bool
Initial state of "type annnotations" toggle. Defaults totrue
.annotate_source::Bool
Initial state of "Source". Defaults totrue
.inlay_types_vscode::Bool
Initial state of "vscode: inlay types" toggle. Defaults totrue
diagnostics_vscode::Bool
Initial state of "Vscode: diagnostics" toggle. Defaults totrue
jump_always::Bool
Initial state of "jump to source always" toggle. Defaults tofalse
.
Cthulhu.AbstractCursor
— TypeAbstractCursor
Required overloads:
Cthulhu.lookup(interp::AbstractInterpreter, curs::AbstractCursor, optimize::Bool)
Cthulhu.lookup_constproped(interp::AbstractInterpreter, curs::AbstractCursor, override::InferenceResult, optimize::Bool)
Cthulhu.get_mi(curs::AbstractCursor) -> MethodInstance
Cthulhu.get_optimized_codeinst(interp::AbstractInterpreter, curs::AbstractCursor) -> CodeInstance
Cthulhu.update_cursor(curs::AbstractCursor, mi::MethodInstance)
Cthulhu.navigate(curs::AbstractCursor, callsite::Callsite) -> AbstractCursor
Cthulhu.Bookmark
— TypeCthulhu.Bookmark
A Cthulhu.Bookmark
remembers a method marked by b
key during a descent. It can be used with the following functions:
descend(::Bookmark)
,descend_code_typed(::Bookmark)
,descend_code_warntype(::Bookmark)
: continue the descent.code_typed(::Bookmark)
,code_warntype([::IO,] ::Bookmark)
: show typed IRcode_llvm([::IO,] ::Bookmark)
: pretty-print LLVM IRcode_native([::IO,] ::Bookmark)
: pretty-print native code
Cthulhu.ascend
— Functionascend(mi::MethodInstance; kwargs...)
ascend(bt; kwargs...)
Follow a chain of calls (either through a backtrace bt
or the backedges of a MethodInstance
mi
), with the option to descend
into intermediate calls. kwargs
are passed to descend
.
Cthulhu.descend
— Functiondescend
Shortcut for descend_code_typed
.
Cthulhu.descend_code_typed
— Methoddescend_code_typed(f, argtypes=Tuple{...}; kwargs...)
descend_code_typed(tt::Type{<:Tuple}; kwargs...)
descend_code_typed(Cthulhu.BOOKMARKS[i]; kwargs...)
descend_code_typed(mi::MethodInstance; kwargs...)
Given a function and a tuple-type, interactively explore the output of code_typed
by descending into invoke
statements. Type enter to select an invoke
to descend into, select ↩
to ascend, and press q
or control-c
to quit.
Usage:
julia> descend_code_typed(sin, (Int,))
[...]
julia> descend_code_typed(sin, Tuple{Int})
[...]
julia> descend_code_typed(Tuple{typeof(sin), Int})
[...]
julia> descend_code_typed() do
T = rand() > 0.5 ? Int64 : Float64
sin(rand(T)
end
[...]
Cthulhu.descend_code_warntype
— Methoddescend_code_warntype(f, argtypes=Tuple{...}; kwargs...)
descend_code_warntype(tt::Type{<:Tuple}; kwargs...)
descend_code_warntype(Cthulhu.BOOKMARKS[i])
descend_code_warntype(mi::MethodInstance; kwargs...)
Given a function and a tuple-type, interactively explore the output of code_warntype
by descending into invoke
statements. Type enter to select an invoke
to descend into, select ↩
to ascend, and press q
or control-c
to quit.
Usage:
julia> descend_code_warntype(sin, (Int,))
[...]
julia> descend_code_warntype(sin, Tuple{Int})
[...]
julia> descend_code_warntype(Tuple{typeof(sin), Int})
[...]
julia> descend_code_warntype() do
T = rand() > 0.5 ? Int64 : Float64
sin(rand(T)
end
[...]
Cthulhu.save_config!
— Functionsave_config!(config::CthulhuConfig=CONFIG)
Save a Cthulhu.jl configuration config
(by default, Cthulhu.CONFIG
) to your LocalPreferences.toml
file using Preferences.jl.
The saved preferences will be automatically loaded next time you using Cthulhu
Examples
julia> using Cthulhu
julia> Cthulhu.CONFIG.enable_highlighter = true
true
julia> Cthulhu.CONFIG.debuginfo = :none # Customize some defaults
:none
julia> Cthulhu.save_config!(Cthulhu.CONFIG) # Will be automatically read next time you `using Cthulhu`
Cthulhu.@descend
— Macro@descend
Shortcut for @descend_code_typed
.
Cthulhu.@descend_code_typed
— Macro@descend_code_typed
Evaluates the arguments to the function or macro call, determines their types, and calls code_typed
on the resulting expression.
Cthulhu.@descend_code_warntype
— Macro@descend_code_warntype
Evaluates the arguments to the function or macro call, determines their types, and calls code_warntype
on the resulting expression.
Cthulhu.@interp
— Macro@interp
For debugging. Returns a CthulhuInterpreter from the appropriate entrypoint.