visual-studio-code - 如何在 VS Code 中调试 Erlang 程序

标签 visual-studio-code erlang vscode-debugger

我现在正在学习 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/

相关文章:

node.js - 用于启动前端和后端进行调试的 VS Code 设置

c - 使用 Visual Studio Code 任务自动化多个文件夹中的 C 生成文件

erlang - 是否可以重新创建 erlang 的 :math functions as elixir macros?

c - unicode 排序规则 NIF 运行速度比纯 Erlang 实现慢

list - 列表中的数字打印为 "\f"

python - 无法让 VS Code 将参数从 launch.json 传递给 Python

ruby-on-rails - 在 Docker 容器上进行远程调试时,无法使用 Visual Studio 代码中断任何断点

在 VS Code 上调试 Jest

python - 如何在 vs 代码中激活虚拟环境?

javascript - azure函数不在本地运行