Cthulhu.BOOKMARKSConstant
Cthulhu.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.CONFIGConstant
Cthulhu.CONFIG

Options

  • enable_highlighter::Bool: Use command line highlighter 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 to att.
  • dead_code_elimination::Bool: Enable dead-code elimination for high-level Julia IR. Defaults to true. 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 to false.
  • interruptexc::Bool: Use <q>-key to quit or ascend. Defaults to false.
  • debuginfo::Symbol: Initial state of "debuginfo" toggle. Defaults to :compact. Options:. :none, :compact, :source
  • optimize::Bool: Initial state of "optimize" toggle. Defaults to true.
  • hide_type_stable::Bool: Initial state of "hidetypestable" toggle. Defaults to false.
  • iswarn::Bool: Initial state of "warn" toggle. Defaults to false.
  • remarks::Bool Initial state of "remarks" toggle. Defaults to false.
  • with_effects::Bool Intial state of "effects" toggle. Defaults to false.
  • exception_type::Bool Intial state of "exception type" toggle. Defaults tofalse`.
  • inline_cost::Bool Initial state of "inlining costs" toggle. Defaults to false.
  • type_annotations::Bool Initial state of "type annnotations" toggle. Defaults to true.
  • annotate_source::Bool Initial state of "Source". Defaults to true.
  • inlay_types_vscode::Bool Initial state of "vscode: inlay types" toggle. Defaults to true
  • diagnostics_vscode::Bool Initial state of "Vscode: diagnostics" toggle. Defaults to true
  • jump_always::Bool Initial state of "jump to source always" toggle. Defaults to false.
Cthulhu.AbstractCursorType
AbstractCursor

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.BookmarkType
Cthulhu.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 IR
  • code_llvm([::IO,] ::Bookmark): pretty-print LLVM IR
  • code_native([::IO,] ::Bookmark): pretty-print native code
Cthulhu.ascendFunction
ascend(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_code_typedMethod
descend_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_warntypeMethod
descend_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!Function
save_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_code_typedMacro
@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_warntypeMacro
@descend_code_warntype

Evaluates the arguments to the function or macro call, determines their types, and calls code_warntype on the resulting expression.

Cthulhu.@interpMacro
@interp

For debugging. Returns a CthulhuInterpreter from the appropriate entrypoint.