I recorded a video to show the process of debug. In this video, you can obviously see that the debugger cannot hit the breakpoint in a Julia callback function. The definition
of this function is showed below:
function on_exit(reason::Cint, user_data::Ptr{Cvoid})::Cvoid
strategy_log(2, string("strategy exit, reason:", reason))
println("This is a julia callback function passed to C lib")
println("debugger cannot hit this breakpoint")
println("strategy completed")
nothing
end
#Using cfunction can pass julia callback function to c
function strategy_set_exit_callback(on_exit::Function)::Cint
on_exit_c = @cfunction($on_exit, Cvoid, (Cint, Ptr{Cvoid}))
user_data = Ref{Cvoid}()
err = ccall((:strategy_set_exit_callback, lib), Int32, (Ptr{Cvoid}, Ptr{Cvoid}), on_exit_c, user_data)
return err
end
strategy_set_exit_callback(on_exit)
This callback function is passed to a c lib by the macro @cfunction.
Is there any way to debug the callback function?