Julia ---- Debugger 代码调试方式

Julia debug相对比较麻烦,但还是有一些比较好用的工具 ,这里简单介绍两种方式

1、JuliaPro 中debug插件

    IDE中的debug工具,比较简单直接在REPL中使用 Juno.@enter 命令执行函数。看起来还是比较简单的

 

 

2、Debugger.jl

这是官方提供的debug工具,简单用法如下

using Debugger

function f(x)
        if x < 0
            @bp
            println("false")
        elseif x===0
            println("missing")
        elseif x>0
            @bp
            println("true")
        end
end

#使用断点运行方法
@run f(2) 

执行 @run f(2) REPL中显示如下:

julia> 
Hit breakpoint:
In f(x) at D:\leaning\Julia\julia\jbl\Debugger\DebuggerTest.jl:4
  3  function f(x)
  4          if x < 0
● 5              @bp
> 6              println("false")
  7          elseif x===0
  8              println("missing")
  9          elseif x>0
●10              @bp

About to run: (println)("false")

bt 查看断点信息,然后输入n 继续执行下一行

1|debug> bt
[1] f(x) at D:\leaning\Julia\julia\jbl\Debugger\DebuggerTest.jl:6
  | x::Int64 = -21|debug> bt
[1] f(x) at D:\leaning\Julia\julia\jbl\Debugger\DebuggerTest.jl:6
  | x::Int64 = -2
1|debug> n
false
In f(x) at D:\leaning\Julia\julia\jbl\Debugger\DebuggerTest.jl:4
  3  function f(x)
  4          if x < 0
● 5              @bp
> 6              println("false")
  7          elseif x===0
  8              println("missing")
  9          elseif x>0
●10              @bp

About to run: return
1|debug> n

详细的使用命令请跳转:Debugger.jl

 

3、Traceur.jl

支持1.0.5,但是在在1.4.2版本中不起作用,暂时放弃使用。

4、其他一些debug工具

  • Juno - the official integrated development environment (IDE) for the Julia language
  • Debugger.jl - the official Julia debugger
  • Rebugger.jl - an expression-level debugger for Julia with a provocative command-line (REPL) user interface
  • MagneticReadHead.jl - a Julia debugger based on Cassette.jl
  • Infiltrator.jl - allows you to set a breakpoint in a local context, inspect local variables and the call stack, and execute arbitrary statements in the context of the current function's module

You might also enjoy:

  • Traceur.jl - runs your code and tells you about any obvious performance traps
  • Cthulhu.jl - descend into Julia code and see it in all its representations.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

October-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值