如何在vscode中使用erlang插件调试rebar3 erlang ?



我使用Erlang语言插件vscode。我创建了一个新的rebar3应用程序,并创建了一个简单的应用程序,不使用监视器:

-module(test_app_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
load_file("input.txt").
stop(_State) ->
ok.
load_file(Filename) ->
case file:read_file(Filename) of
{ok, Bin} ->
Bin;
{error, Reason} ->
erlang:error(Reason)
end.

我已经配置了一个启动。Json文件如下:

{
"version": "0.2.0",
"configurations": [
{
"name": "Launch erlang",
"type": "erlang",
"request": "launch",
"cwd": "${workspaceRoot}",
"arguments": "-s test_app_app start",
"preLaunchTask": "rebar3 compile"
}
]
}

和a任务。用于编译的Json:

{
"version": "2.0.0",
"tasks": [
{
"label": "rebar3 compile",
"type": "shell",
"command": "rebar3 compile",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$erlang"
}
]
}

当我按下F5,我得到以下输出:

compiling erlang bridge to '/home/peter/.vscode/extensions/pgourlain.erlang-0.8.1/_build/default/lib/ebin'
Compiling arguments file  "/tmp/bp_1454870.erl"
Compile result: sucess 
Module bp_1454870 loaded
{"init terminating in do_boot",{undef,[{t
est_app_app,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{test_app_app,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})
Crash dump is being written to: erl_crash.dump...
done
erl exit code:1
erl exit with code 1

有没有人知道为什么这对我不起作用?

问题在你的launch.json中。您尝试从模块test_app_app运行函数start/0,但该函数不存在。

尝试使用

"arguments": "-eval "application:start(test_app)""

最新更新