diff --git a/test/reflection.jl b/test/reflection.jl index 0be5766f829b7..de527f97f99bc 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -374,3 +374,29 @@ test_typed_ast_printing(g15714, Tuple{Vector{Float32}}, [:array_var15714, :index_var15714]) @test used_dup_var_tested15714 @test used_unique_var_tested15714 + +# Linfo Tracing test +tracefoo(x, y) = x+y +didtrace = false +tracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), LambdaInfo); global didtrace = true; nothing) +ccall(:jl_register_tracer, Void, (Ptr{Void},), cfunction(tracer, Void, (Ptr{Void},))) +mlinfo = first(methods(tracefoo)).func +ccall(:jl_trace_linfo, Void, (Any,), mlinfo) +@test tracefoo(1, 2) == 3 +ccall(:jl_untrace_linfo, Void, (Any,), mlinfo) +@test didtrace +didtrace = false +@test tracefoo(1.0, 2.0) == 3.0 +@test !didtrace +ccall(:jl_register_tracer, Void, (Ptr{Void},), C_NULL) + +# Method Tracing test +methtracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), Method); global didtrace = true; nothing) +ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), cfunction(methtracer, Void, (Ptr{Void},))) +tracefoo2(x, y) = x*y +@test didtrace +didtrace = false +tracefoo(x::Int64, y::Int64) = x*y +@test didtrace +didtrace = false +ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), C_NULL)