简体   繁体   English

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

[英]How do I debug rebar3 erlang in vscode with the erlang plugin?

I am using the Erlang language plugin for vscode.我正在为 vscode 使用 Erlang 语言插件。 I created a new rebar3 app and created a simple app that doesnt use a supervisor:我创建了一个新的 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.

I have configured a launch.json file like so:我已经配置了一个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"
        }
    ]
}

and a tasks.json for the compile:和一个用于编译的 tasks.json:

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

When I hit F5 I get the following output:当我点击 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

Does anyone have a clue as to why this isnt working for me?有没有人知道为什么这对我不起作用?

The problem is in your launch.json.问题出在您的 launch.json 中。 You try to run a function start/0 from module test_app_app and such function does not exist.您尝试从模块test_app_app运行函数start/0test_app_app此类函数不存在。

Try to use尝试使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM