3
줄리아 기능 호출자의 파일/이름/라인 정보를 가져 오는 방법이 있습니까?Julia 백 트레이스에서 발신자를 표시하는 방법은 무엇입니까?
나는 this way to get some stacktrace info을 발견하고, 호출자가 다른 함수 (하지만 주요 상황) 인 경우 I 파일 수 : 라인 정보 :
module pd
global g_bTraceOn = true
export callerOfTraceIt
function callerOfTraceIt()
traceit("hi") ;
end
function traceit(msg)
global g_bTraceOn
if (g_bTraceOn)
bt = backtrace() ;
s = sprint(io->Base.show_backtrace(io, bt))
println("debug: $s: $msg")
end
end
end
using pd
callerOfTraceIt()
이 보여줍니다
$ julia bt.jl
debug:
in traceit at C:\cygwin64\home\Peeter\julia\HarmonicBalance\bt.jl:15
in callerOfTraceIt at C:\cygwin64\home\Peeter\julia\HarmonicBalance\bt.jl:8
in include at boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at client.jl:285
in _start at client.jl:354: hi
내가 좋겠를 정말 두 번째 프레임 (traceit()의 호출자)을 좋아하고 함수 이름이 있으면 사용할 수도 있습니다.
감사합니다. Tim. 다음은 이것을 사용하는 방법입니다. https://github.com/peeterjoot/julia/blob/master/HarmonicBalance/pd.jl ... 내 첫 번째 줄리아 코드 중 일부는 일반적으로 내 새로운 언어로 된 첫 번째 코드. –