1

Setup: OTP 26. IntelliJ 2022.3.1 with plugins Erlang 0.11.1162 and Makefile 223.8214.6

Code under preview: The test suite ct_netconfc_SUITE. We could run it from CLI using the command make common_test_test ARGS="-suite ct_netconfc_SUITE".

Goal: I want to debug test suite ct_netconfc_SUITE.

I have set breakpoints in the code. I have created a configuration using Run-->Edit Configurations for the make command specified above. I tried to debug using Run-->Debug-->Makefile-->Run. It successfully runs the configuration. But it did not stop at the breakpoint.

How to stop at the breakpoint?

Other than IntelliJ, what are the other options to debug an Erlang application with Makefile?

Installed Plugins

Makefile Plugin

Erlang plugin

Debug Configurations created for the make command Debug Configurations

Debugging command

Debug - Makefile

Bhuvan
  • 370
  • 9
  • You don't debug with a makefile. I'm not really sure what you're trying to do, but make and makefiles are used to build code. After it's built, then you run it either directly or in the debugger. But you generally don't run it from make and you definitely can't debug it when run from make. – MadScientist Jan 04 '23 at 17:43
  • Thanks @MadScientist. I want to debug the application which has a Makefile for build and run. – Bhuvan Jan 06 '23 at 06:01
  • For Java, I use a build management tool called Maven. It provides a build file (pom.xml) to build, run & debug the application. Makefiles are similar to Maven build file and I thought it should allow the user to debug the application as well by setting some arguments (debug port, etc) – Bhuvan Jan 06 '23 at 06:30
  • 1
    Not really. Makefiles are not meant to be run "interactively". They are meant to be started, build stuff in the background, and exit. make follows the UNIX philosophy that a tool should do one thing, and that tools can be combined. `make` is intended to build things. Running code and debugging code is left to other tools. I don't know much about intellij since I use F/OSS software but presumably there's some facility in it which lets it invoke a debugger on the code. – MadScientist Jan 06 '23 at 14:17
  • Thanks @MadScientist for throwing some light on the UNIX philosophy. Whereas, Software management tools such as Maven are built on the principle of "providing complete functionalities". It performs build, run, debug, manage the software dependencies as well while building, https://www.jetbrains.com/help/idea/work-with-maven-goals.html#debug_goal – Bhuvan Jan 15 '23 at 15:55

1 Answers1

2

I think you can use io:format function to debug what you want in the code, for example, print out List attribute:

io:format("I_want_to_print_this_List_~p", [List]).

In erlang, not like other programming languages (java, c#, c++) that can add breakpoints in there, with erlang if you have a million processes are running every second and over a hundred functions, that means impossible to add breakpoins to debug one by one.

As the comment of MadScientist, Makefile just helps us stop/start/build... application or which tool or script.

  • Thanks @tam-ly-nhat. Yes, I am using io:format for a smaller project. I see, it is not feasible to debug bigger projects such as OTP which has a huge code base. – Bhuvan Jan 15 '23 at 16:01