Astarno

Astarno

How to use the dbg tracer in Elixir

I’m trying to use the dbg tracer from Erlang in Elixir. At the moment I have the following line:

:dbg.tracer(process, fn (msg, _) -> IO.puts("DEBUG: #{msg}") end)

This raises the error:

** (CompileError) iex:1: undefined function process/0
    (stdlib 3.16.1) lists.erl:1358: :lists.mapfoldl/3

Any help with this would be appreciated. I’m myself pretty new to Elixir and Erlang, so it’s very possible it’s something very simple that I’m doing wrong.

Kind regards!

Marked As Solved

John-Goff

John-Goff

From looking at the docs it appears as though that function does not take a two-arity function as its second argument. It should either be a zero-arity function, or a tuple with a two-arity function and the initial data for that function. This is the Erlang type syntax which specifies this:

Data = PortGenerator | HandlerSpec | ModuleSpec
PortGenerator = fun() (no arguments)
Error = term()
HandlerSpec = {HandlerFun, InitialData}
HandlerFun = fun() (two arguments)
ModuleSpec = fun() (no arguments) |{TracerModule, TracerState}
TracerModule = atom()
InitialData = TracerState = term()

Also Liked

RudManusachi

RudManusachi

The first argument of :dbg.tracer/2 is type which is one of the atoms :port | :process | :module.
You probably got that example mixed from some source in Erlang. process in Erlang is an atom. So the equivalent in elixir would be :process

:dbg.tracer(:process, fn (msg, _) -> IO.puts("DEBUG: #{msg}") end)
LostKobrakai

LostKobrakai

I usually suggest GitHub - redink/extrace: Elixir wrapper for Recon Trace., which translates quite well from and to erlang.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement