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.backedges
— Functionedges = backedges(obj)
Return an iterable of children (callers) of obj
. An edge
should support Cthulhu.method
and Cthulhu.specTypes
, as well as Cthulhu.nextnode
to get the next node object.
Part of the ascend
API.
Cthulhu.descend
— Methoddescend(f, argtypes=Tuple{...}; kwargs...)
descend(tt::Type{<:Tuple}; kwargs...)
descend(Cthulhu.BOOKMARKS[i])
descend(mi::MethodInstance; kwargs...)
Given a function and a tuple-type, interactively explore the source code of functions annotated with inferred types 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. See Cthulhu.CONFIG
for kwargs
and their defaults.
Usage:
julia> descend(sin, (Int,))
[...]
julia> descend(sin, Tuple{Int})
[...]
julia> descend(Tuple{typeof(sin), Int})
[...]
julia> descend() do
T = rand() > 0.5 ? Int64 : Float64
sin(rand(T))
end
[...]
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. See Cthulhu.CONFIG
for kwargs
and their defaults.
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. See Cthulhu.CONFIG
for kwargs
and their defaults.
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.instance
— Functioninst = instance(obj)
Return the current node data corresponding to obj
. inst
should support Cthulhu.method
and Cthulhu.specTypes
.
Part of the ascend
API.
Cthulhu.method
— Functionm = method(edge)
Return the method corresponding to edge
.
Part of the ascend
API.
Cthulhu.nextnode
— Functionchildobj = nextnode(obj, edge)
Return the next node object from obj
indicated by edge
.
Part of the ascend
API.
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.specTypes
— Functionsig = specTypes(edge)
Return the signature of edge
.
Part of the ascend
API.
Cthulhu.@descend
— Macro@descend
Evaluates the arguments to the function or macro call, determines their types, and calls descend
on the resulting expression. See Cthulhu.CONFIG
for options and their defaults.
Examples
julia> @descend sin(1)
[...]
julia> @descend iswarn=false foo()
[...]
Cthulhu.@descend_code_typed
— Macro@descend_code_typed
Evaluates the arguments to the function or macro call, determines their types, and calls descend_code_typed
on the resulting expression. See Cthulhu.CONFIG
for options and their defaults.
Examples
julia> @descend_code_typed sin(1)
[...]
julia> @descend_code_typed optimize=false sin(1)
[...]
Cthulhu.@descend_code_warntype
— Macro@descend_code_warntype
Evaluates the arguments to the function or macro call, determines their types, and calls descend_code_warntype
on the resulting expression. See Cthulhu.CONFIG
for options and their defaults.
Examples
julia> function foo()
T = rand() > 0.5 ? Int64 : Float64
sin(rand(T))
end
foo (generic function with 1 method)
julia> @descend_code_warntype foo()
[...]
julia> @descend_code_warntype hide_type_stable=true foo()
[...]
Cthulhu.@interp
— Macro@interp
For debugging. Returns a CthulhuInterpreter from the appropriate entrypoint.