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

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
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
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement