我现在正在学习 Erlang。据我所知,有一个工具叫钢筋3 可以生成项目样板。好的,所以在安装之后,我生成了一个像这样的空项目:
$ rebar3 new umbrella myproj
甜的。现在我用 Erlang extension 打开 VS Code安装。我添加一个 启动.json 如文档中所述的文件:{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch erlang",
"type": "erlang",
"request": "launch",
"cwd": "${workspaceRoot}",
"preLaunchTask": "rebar3 compile"
}
]
}
然后,我添加另一个 任务.json 文件:{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "rebar3 compile",
"type": "shell",
"command": "rebar3 compile",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$erlang"
}
]
}
然后,我在 中设置了一个断点。 myproj_app.erl 文件:%%%-------------------------------------------------------------------
%% @doc myproj public API
%% @end
%%%-------------------------------------------------------------------
-module(myproj_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
io:format("Hello, world!~n"), %<-- BREAKPOINT
myproj_sup:start_link().
stop(_State) ->
io:format("Hello, world!~n"),
ok.
%% internal functions
我按 F5,调试器启动但它永远不会停止。这是输出:> Executing task: rebar3 compile <
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling myproj
Terminal will be reused by tasks, press any key to close it.
Compiling arguments file "/tmp/bp_2863283.erl"
Compile result: sucess
Module bp_2863283 loaded
如果我添加该行:"arguments": "-config dev -s sample"
致启动.json 文件,它给了我一个错误并且没有启动。而且我很确定这些不是我必须传递给负责启动我的程序的任何人的论点。这是输出:{
"
c
o
u
l
d
n
o
t
s
t
a
r
t
kernel pid",application_controller,"error in config file \"./dev.config\" (none): configuration file not found"}
c
o
u
l
d
n
o
t
s
t
a
r
t
k
e
r
n
e
l
p
id (application_controller) (error in config file "./dev.config" (none): configuration file not found)
Crash dump is being written to: erl_crash.dump...
d
o
n
e
erl exit code:1
erl exit with code 1
如何配置 VS Code 进行调试?缺少什么?
最佳答案
我是 Erlang 的新手,遇到了同样的问题......显然,启动调试 session 不会启动您的程序,而只会启动带有调试标志的 elang shell,您可以在其中启动任何你感兴趣的模块:函数(args)调试。请注意,调试控制台窗口有“>”提示,您可以在其中调用它。因此,在您的具体示例中,我将使用“myproj_app:start(1, 2)”。 args 并不重要,因为它们没有被使用。一旦进入
关于visual-studio-code - 如何在 VS Code 中调试 Erlang 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63728063/