pfitz

pfitz

Coming from Objective-C/Swift/PHP/Java I am used to a full IDE for my projects. The one thing I miss the most is a good debugger. So far I just did „poor mans debugging“ with IO.inspect but I am guessing there are better ways to debug ones elixir apps. So how do you debug your apps ?

Showing Posts 1 to 9

Qqwy

Qqwy

TypeCheck Core Team

Because of the ability to run multiple Erlang applications side-by-side in the same process and because of metaprogramming awesomeness, one of the fancy things you can do is IEX.pry(after you require IEx in the module) , which starts a shell at that current location in the code, so you can debug the scope you are in.

The cool thing about IO.inspect by the way is that you can plug it in everywhere in your pipelines without altering the result:

(1..10)
|> IO.inspect
|> Enum.map(fn x -> x * x end) 
|> IO.inspect
|> Enum.sum
|> IO.inspect

rvirding

rvirding

Creator of Erlang

You have to be very careful when debugging things in a concurrent environment, at least when you debug in a more traditional way which stops and controls execution. Anything that is waiting for the debugged process will hang and in many cases may time out and crash, which is not what was intended. Also doing something like IEx.pry in a function which is called in many processes will also be interesting.

Sorry to sound very negative here but having very concurrent systems does change you need to work with them. Sometimes IO.inspect is all that is reasonable. Or use the built-in tracing facilities.

Robert

gausby

gausby

I think that we, as a community, need to study our options for inspecting our applications. As others has mentioned in this thread: The Beam is a different beast. Introducing break points changes the program and such.

Personally I have to look into this book: http://www.erlang-in-anger.com. It is another Erlang book, but learning a little bit of Erlang goes a long way :)—it describes strategies for tracing and probing a running Erlang system.

rvirding

rvirding

Creator of Erlang

Yes, most of that book should be directly applicable to Elixir, with a bit of syntax change. The way systems are built, work and interact are basically the same.

Qqwy

Qqwy

TypeCheck Core Team

For anyone who reads this topic and doesn’t know about observer: :observer.start will make your life easier. It basically is a Task Manager, for inside the BEAM. It gives you a lot of high-level information about what is going on in your system, and it is very useful to, for instance, spot bottlenecks in your message-passing.

pfitz

pfitz OP

Debugging concurrent apps seem to be a reason why debugging „is so hard“. One the other side: for beginners like me - we do not make concurrent apps from start :slight_smile: - I would argue that debugging could be more easy.

Does one have experience with the erlang debugger :debugger.start
Debugger — OTP 29.0.2 (debugger 7.0) ?

sribe

sribe

Yes, I used the Erlang debugger just a bit. There’s a blog post out there about a modification you have to make in order for it to be able to find Elixir sources. Start here, this shows a bit of use, and links to the description of the setup:

aboroska

aboroska

In the past 6 years I had the opportunity to work with many excellent Erlang developers and nobody used the debugger tool for nothing. I guess two reasons can be behind the lack of interest:

1., Inserting printout in the code is trivial thanks to hot code reloading.

2., Tracing provided by the VM.

There are several options for tracing, for a newish gui you might want try a beta project called erlyberly: How to trace Elixir nodes with Erlyberly « Plataformatec Blog

stephen_m

stephen_m

(1..10)
|> IO.inspect
|> Enum.map(fn x -> x * x end) 
|> IO.inspect
|> Enum.sum
|> IO.inspect

As above, I do very similar to Qqwy except I log the result. often times with pieces of data from the ENV macro.

Except I use Og, a tiny set of functions that log it instead,

(1..10)
|> Og.log_return() # defaults to debug
|> Enum.map(fn x -> x * x end) 
|> Og.log_return(__ENV__, :info) # will print line, number func and in `info` style
|> Enum.sum
|> Og.log_return(__ENV__, :debug) 

I end up using __ENV__ alot.

Not sure if this is good or not though but it’s helped me. :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews