gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 05:54:42 34 4
gpt4 key购买 nike

我正在为 vscode 使用 Erlang 语言插件。我创建了一个新的 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.

我已经像这样配置了一个 launch.json 文件:

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

和用于编译的 tasks.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)\""

关于debugging - 如何使用 erlang 插件在 vscode 中调试 rebar3 erlang?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69590165/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com