axelson

axelson

Scenic Core Team

4) ElixirConf US 2018 – You Can Never Debug the Code You Run, But You Can View the Code the Debugger is Running – Luke Imhoff

ElixirConf US 2018 – You Can Never Debug the Code You Run, But You Can View the Code the Debugger is Running – Luke Imhoff (@KronicDeth)

Elixir supports various ways to debug code: printing with IO.inspect, prying with IEx.pry, or using more advanced OTP tools like :debugger and :int. Choosing when to use these different tools can be confusing, and understanding how they work can prove downright intimidating.

Throughout this talk we’ll peel back the covers on the more advanced debugging techniques and dissect exactly how each debugging tool can be used to examine our compiled code. None of debugging techniques leave your code the same as how it was running in production. Adding IO and IEx.pry calls obviously changes the code as you edit the source, but using the OTP debugger, either with :debugger, IntelliJ Elixir, or Elixir Language Server, or by adding new break points from the IEx.pry shell changes the module code being run.

Luke Imhoff will show how each type of debugging changes the code by revealing how IEx.pry and :debugger are implemented. You’ll see why sometimes the debuggers can’t reproduce bugs because the modifications to make the code debuggable also subtly changes the execution of the code by looking at changes to the bytecode and AST. Although the modified code never exists as source, we can recover the Abstract Syntax Tree (AST) of either the Elixir quoted form or the Erlang Abstract Code from the Dbgi chunk, but the Dbgi chunk ASTs aren’t terribly easy to read, so we can use tools to decompile the code and translate it to Elixir or Erlang modules.

When looking at Dgbi code isn’t enough, we can drop down to the Code chunk and look at the bytecode. The bytecode is a unique binary format, so once again we reach for for tools to render it, so instead of having to read machine code, we can read assembly. Looking at this bytecode also allows us to check if our high-level optimizations, such as module attribute reuse, compute variables once, and the order of pattern matching, have an impact on the code run by the VM, as unlike Dbgi, the Code chunk is actually loaded by the VM when running code without debugging.

Audience: Intermediate, Advanced
Topics: elixir, debugging

All talks are available in the ElixirConf US 2018 Talks List or via the elixirconf2018 tag

Most Liked

blatyo

blatyo

Conduit Core Team

I’m always impressed with the things he’s able to do in IntelliJ. I really enjoyed the deep dive on how the debuggers work and the BEAM bytecode.

Where Next?

Popular in Talks Top

axelson
ElixirConf US 2018 Opening Keynote - The Next Five Years – José Valim (@josevalim) All talks thread:
New
kokolegorille
Lonestar Elixir 2018 videos are starting to pop up :slight_smile: https://www.youtube.com/channel/UCOy-_b9bqjokoWX9Hg5ZgUg Day 1 Chris ...
New
Lawrence_elixir
@keathley - Senior Engineer Bleacher Report and Elixir Outlaws presenter Talk: Building Resilient Systems with Stacking Talk in three w...
New
CodeSync
Hologram Building Rich UIs with Elixir Running in the Browser - Bart Blast | ElixirConf EU 2025 Comments welcome! View th...
New
Lawrence_elixir
@voltone - Security advocate, BEAM enthusiast Learn you some ‘ssl’ for much security! Talk in three words: TLS, security, troubleshooti...
New
ElixirConf
ElixirConf: ElixirConf 2022 - Brian Cardarella - What is LiveView Native? Comments welcome! View the <span class="hashtag-icon-placehold...
New
axelson
ElixirConf 2017 - Cajoling the Bird: How we squeezed more out of Phoenix PubSub- Simon Zelazny Grindr is a m...
New
zporter
ElixirConf US 2018 – Breaking Down the User Monolith – Zach Porter Coming from Ruby on Rails, the convention is to have a...
New
axelson
ElixirConf US 2018 – Beyond Command and Response Chatbot – Fahad Almusharraf The talk discusses an attempt ...
New
AstonJ
Keywords: LiveView autocomplete, LiveView search, focus Startups and web developers take note. Phoenix LiveView is the revolutionary fr...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement