Unicode output from the debugger

I was using the Erlang trace debugger to see how my string parsing code was being called. The strings are Unicode and so the output was like this…

(<0.101.0>) returned from ‘Elixir.Tinker’:handle/2 -> [<<226,191,178>>,

I ran iex --werl but that didn’t affect the debug output. Is it possible to make the Erlang debugger output Unicode strings so that they’re readable, rather than as bitstrings?


How do you debug?

Simply copy pasting this into my shell gives me proper inspection:

 % iex
Erlang/OTP 21 [erts-10.0.8] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>  [<<226,191,178>>,
...(1)> [<<230,173,162>>,
...(1)> <<232,135,170>>,
...(1)> <<229,183,179>>,
...(1)> <<229,133,171>>,
...(1)> <<229,164,130>>]]
["⿲", ["止", "自", "巳", "八", "夂"]]

So it may depend on which part of the program generates the message.

Unicode characters and strings do appear in the shell. It’s the output during tracing, where everything displays as bitstrings. Since I’m debugging consuming Unicode strings recursively, it’d be helpful if those bitstrings displayed as Unicode characters.

Which debugging are you using? :dbg? :sys? Note they usually allow you to pass a handler, so you can pass your own handler instead of relying on the default one.

1 Like

I used :dbg. Thanks for the pointer to handlers. I’ll look into that.

The Adopting Elixir book has a chapter on production tools and a section on :dbg, here is the example we use:

iex> fun = fn _, 100 -> :dbg.stop_clear(); msg, n -> IO.inspect(msg) && n + 1 end
iex> :dbg.tracer(:process, {fun, 0})