Tools for debugging Rust programs and compiler plugins

Rust is a modern system programming language with a strong focus on speed, safety, and concurrency. The main novelty of its compiler is the ability to detect at compile time certain memory-related bugs such as dangling pointers, without sacrificing runtime performance.


Compared to other high-level programming languages, however, debugging Rust programs can be more difficult. When a panic (similar to an expection) occurs, Rust displays just the stacktrace of the program, without showing the value of the function parameters. A debugger like rust-gdb can be used to inspect the value of the paramenters, but in some cases the debugger does not work out of the box. The last resource is to use print functions to display debug information, but this approach is time-consuming and it does not work well on big projects.


This thesis project aims to develop tools to help debugging Rust programs, in particular the so called “compiler plugins”: Rust programs that act as a replacement of the Rust compiler, providing special functionalities. The efficacy of all the techniques developed in the thesis will be evaluated on our Rust verifier project, called Prusti .


The techniques developed in this project will enable Rust developers to be more productive, helping them to quickly identify bugs and the source of panics in large projects. This is particularly important, given that a finding of the last external page Rust survey  is that “Rust projects are continuing to trend to larger sizes”. Even if the thesis focuses on Rust, the knowledge and debugging techniques learned during the process can be transferred to other programming languages.

Goals

  1. Develop a Rust library to augment the debug information displayed when a panic occurs. In addition to the existing stacktrace, this library should allow a developer to store and update informations that will only be shown in case of crash, to help identify the conditions under which a panic occurred.
  2. Develop a test runner for compiler plugins, on the model of (or extending) the existing compiletest-rs library, such that code coverage is collected during the execution of the test suite.
  3. Search and document the correct way to use a debugger like gdb, rust-gdb or rr to debug a Rust program, under the particular constraint that the program to be debugged starts JVM instances.

Possible extensions

  1. Develop a library that automatically displays the arguments of the calls in the stacktrace when a panic occurs. Particular attention should be gave to runtime overhead: a zero-cost solution is preferrable, but if it is not possible then a Rust macro can be built to instrument selected functions.
  2. Develop a test runner for compiler plugins, in order to automatically run tests on the top N crates published on the official external page package manager, or on the N latest code snippets shared via the Rust-playground online external page editor. The test runner should be configurable in order to easily reproduce the reported errors.

Since Rust is a major component of this project, prior knowledge of the language is required.

Contact

JavaScript has been disabled in your browser