Module kernel::debug

source ·
Expand description

Support for in-kernel debugging.

For printing, this module uses an internal buffer to write the strings into. If you are writing and the buffer fills up, you can make the size of output_buffer larger.

Before debug interfaces can be used, the board file must assign them hardware:



The debug queue is optional, if not set in the board it is just ignored. You can add one in the board file as follows:



debug!("Yes the code gets here with value {}", i);
debug_verbose!("got here"); // Includes message count, file, and line.

debug_gpio!(0, toggle); // Toggles the first debug GPIO.

debug_enqueue!("foo"); // Adds some message to the debug queue.
debug_flush_queue!(); // Flushes the queue, writing "foo".
panic!("42"); // Flushes the queue, writing "bar" in the debug queue section
              // of the panic diagnostic.
Yes the code gets here with value 42
TOCK_DEBUG(0): /tock/capsules/src/ got here


  • Wrapper type that we need a mutable reference to for the core::fmt::Write interface.
  • Main type that we need an immutable reference to so we can share it with the UART provider and this debug module.
  • Wrapper type that we need a mutable reference to for the core::fmt::Write interface.


  • Static variable that holds the kernel’s reference to the debug tool. This is needed so the debug!() macros have a reference to the object to use.


  • This trait is similar to std::io::Write in that it takes bytes instead of a string (contrary to core::fmt::Write), but io::Write isn’t available in no_std (due to std::io::Error not being available).