buxizhizhoum
buxizhizhoum

Reputation: 1929

How to debug a Erlang project with Intellij idea?

I would like to learn an open source software used as a message broker(EMQTT https://github.com/emqtt/emqttd), but when I am trying to change some code and trace how messages flow in it, there comes an problem that the Intellij Idea seems can only debug one Erlang function or one module at one time. Is there any way that I could debug the whole project and trace it with break point instead of debugging them in function one by one? enter image description here

Upvotes: 1

Views: 2526

Answers (3)

chbest
chbest

Reputation: 23

Your solution of having the source files and artefacts in one directory seem to be the only way to use the Intellij debugger. Since usually the source files and artefacts are not in the same directory, this behaviour seems odd. I have opened an issue therefore (https://github.com/ignatov/intellij-erlang/issues/811).

A solution which works with rebar3 and eunit is described in How to debug erlang code during rebar3 eunit?. You can start rebar3 as test shell in Intellij by using the support for running a rebar3 command provided with the erlang plugin.

Upvotes: 0

buxizhizhoum
buxizhizhoum

Reputation: 1929

After some days of tries, I have found a method that could be used do debug with Intellij Idea, it is not as prefect as the method I would like to find, but it helps on some degree, just post it here for someone in need to reference.

  1. cd in to the directory where your *.erl file is in.
  2. compile with c("your erl file", debug_info). There must be a debug_info when compile, otherwise, the debug will raise error: "no debug info in beam file".

  3. config parameters according to your module, below figure is for reference. You may need provide function args if your function needs args

ps: This is relative redundant to compile with shell, but it is the only method I found could works, if no beam file is supplied, it always raise error: "no beam file".

If anyone has a better method, please give me a help whether by answer this question or a comment, thanks a lot!

enter image description here

Upvotes: 1

Pouriya
Pouriya

Reputation: 1626

Intellij Uses rebar as project manager. rebar was deprecated and rebar3 (new version of rebar) is available with advanced features.

You can use rebar3 and its advanced features for running tests & dialyzer.

EMQTT supports travis !
You can fork it and enable travis in your project. travis is a test platform and will test your project after every change.
for more info see travis docs

Upvotes: 0

Related Questions