You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ中基于Makefile调试Erlang测试套件断点失效及替代方案咨询

问题背景

环境配置

  • OTP 26
  • IntelliJ IDEA 2022.3.1
  • 已安装插件:Erlang 0.11.1162、Makefile 223.8214.6

待调试对象

测试套件ct_netconfc_SUITE,可通过以下CLI命令运行:

make common_test_test ARGS="-suite ct_netconfc_SUITE"

当前状态

已在代码中设置断点,且通过Run→Edit Configurations创建了匹配上述Makefile命令的调试配置。执行Run→Debug→Makefile→Run后配置运行成功,但未触发任何断点。


咨询问题
  1. 如何让调试过程停在预设的断点处?
  2. 除IntelliJ IDEA外,还有哪些基于Makefile调试Erlang应用的方案?

解决方案

问题1:触发断点的解决方法

方案1:修改Makefile,注入调试启动参数

Makefile中的common_test_test目标需要显式启用Erlang调试模式,修改目标定义,在调用测试时添加调试相关参数:

common_test_test:
    ct_run -suite ct_netconfc_SUITE -debug -start_debugger

修改后重新运行调试配置,IntelliJ就能连接到调试进程并触发断点。

方案2:替换为IntelliJ原生Erlang调试配置

跳过Makefile,直接创建Erlang类型的调试配置:

  1. 打开Run→Edit Configurations,点击+选择Erlang
  2. 在Module字段选择对应项目模块
  3. 在Arguments中填入Common Test执行参数:
    -noshell -eval 'ct:run_test([{suite, ct_netconfc_SUITE}])' -s init stop
    
  4. 保存配置后启动调试,断点会正常触发。

方案3:验证断点有效性

  • 确认断点设置在实际会执行的代码行(比如测试用例的函数体内部,而非注释、空行或未被调用的分支)
  • 检查Erlang插件是否正常激活,必要时重启IntelliJ

问题2:其他基于Makefile的Erlang调试方案

1. Erlang自带图形化调试器debugger

在Makefile中新增调试专用目标:

common_test_test_debug:
    erl -noshell -eval 'debugger:start(), ct:run_test([{suite, ct_netconfc_SUITE}])' -s init stop

运行make common_test_test_debug后,会弹出Erlang图形化调试器,手动设置断点即可进行调试。

2. 命令行调试工具dbg

通过dbg模块跟踪函数调用,新增Makefile目标:

common_test_test_dbg:
    erl -noshell -eval 'dbg:tracer(), dbg:p(all, c), dbg:tpl(ct_netconfc_SUITE, x), ct:run_test([{suite, ct_netconfc_SUITE}])' -s init stop

运行后终端会输出函数调用的详细跟踪日志,适合快速定位执行流程问题。

3. 系统监控工具observer

启动测试时同时启动observer,用于监控进程状态、查看调用栈和性能数据:

common_test_test_observer:
    erl -noshell -eval 'observer:start(), ct:run_test([{suite, ct_netconfc_SUITE}])' -s init stop

内容的提问来源于stack exchange,提问作者Bhuvan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 19:50:11