Building a Debugger with Cassette
2019-07-25, 16:15–16:45, Elm B

As the saying goes: "You can solve that with Cassette".
This is a tuitoral on how to use Cassette for building a debugger.
It explains the core of MagneticReadHead.jl, and how you can build similar tools,
to instrument julia code for your purposes.

As the saying goes: "You can solve that with Cassette".
You can do anything with Cassette, and debugging is a thing, therefore Cassette can be used for it.
Generally speaking, you shouldn't solve problems with Cassette that you can solve in any other way.
However if you want to build a debugger, the options include building an entire interpreter,
going deep into the lowest levels of the compiler/LLVM,
or using Cassette.
The other options are certainly good, and indeed the interpreter work has yeilded Debugger.jl.
But this talk is about doing it with Cassette.

MagneticReadHead v0.1.0 is usable debugger based on easy-to-use Cassette function overdubs.
It is under 300 lines of code, and allowed setting breakpoints and stepping between function calls.
MagneticReadHead v0.2+ is featureful debugger based on Cassette IR passes.
It is under 800 lines of code, and alloweds setting breakpoints at arbitary locations and stepping between IR statements.

The talk will first explain the Cassette function overdubs used in v0.1.0 and how you can use them to fairly painlessly instrument julia code at the function call level.
It will then move on the the much more complex IR passes used in current versions of MagneticReadHead.
Explaining how you can recursively modify julia code at run time to instert the extra functionality needed for debugging.

At first Julia IR may seem like a read-only language.
It is surprisingly easy to read, but actually modifying it... the concept brings on a special kind of head pain.
After this talk you will be able to experience that special pain for yourself,
and hopefuly push through it to do something useful.

This tuitorial type presentation is for the advanced julia user.
While knowledge of Cassette is not required, it is expected that attendees are broadly familar with the idea of what IR is, even if they have no idea how to write it.
Everyone is welcome to come along for the ride.

Hopefully by the time of juliacon, offically a PhD gradute, NLP & ML.
A reseach software engineer at Invenia Labs.
Been using julia since 0.3.
Broadly speaking: a useful human.