|
|
Subscribe / Log in / New account

rust: add suppord for dynamic debug

From:  Andrew Ballance <andrewjballance-AT-gmail.com>
To:  jbaron-AT-akamai.com, jim.cromie-AT-gmail.com, daniel.almeida-AT-collabora.com, acourbot-AT-nvidia.com, ojeda-AT-kernel.org, alex.gaynor-AT-gmail.com, boqun.feng-AT-gmail.com, gary-AT-garyguo.net, bjorn3_gh-AT-protonmail.com, lossin-AT-kernel.org, a.hindborg-AT-kernel.org, aliceryhl-AT-google.com, tmgross-AT-umich.edu, dakr-AT-kernel.org, gregkh-AT-linuxfoundation.org, rafael-AT-kernel.org, rostedt-AT-goodmis.org, andrewjballance-AT-gmail.com
Subject:  [RFC PATCH 0/3] rust: add suppord for dynamic debug
Date:  Wed, 11 Jun 2025 15:29:49 -0500
Message-ID:  <20250611202952.1670168-1-andrewjballance@gmail.com>
Cc:  viresh.kumar-AT-linaro.org, lina+kernel-AT-asahilina.net, tamird-AT-gmail.com, jubalh-AT-iodoru.org, rust-for-linux-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org
Archive-link:  Article

This patch series adds support for dynamic debug to the rust
pr_debug! and dev_dbg! macros.

I have tested it and it and it does work but, there are a few
differences between this and the c version (hence why this is a rfc).

rust does not have an equivlant to the C __func__ macro. so, for the
time being this hard codes the function name to be the name of the
macro e.g. "pr_debug!" and "dev_dbg!".

This uses the module_path! macro to get the module name, which will not
be exactly the same as the c version if a kernel module contains multiple
rust modules. e.g. it might be "kernel_module_name::rust_module_name".
this does give a more accurate description of where the print statement
is located but it exactly what the c version does.

This patch series also had to make a small change to the static_branch!
macro so that it allows keys that are nested multiple structs deep within
a static variable. 

Closes: https://github.com/Rust-for-Linux/linux/issues/453
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/Dynamic.20Debug.3F/with/519289668

Andrew Ballance (3):
  rust: static jump: add support for nested arguments
  rust: device add support for dynamic debug to pr_debug!
  rust: device add support for dynamic debug to dev_dbg!

 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/device.rs           | 102 ++++++++++++++++++-
 rust/kernel/jump_label.rs       |  10 +-
 rust/kernel/print.rs            | 167 +++++++++++++++++++++++++++++++-
 4 files changed, 269 insertions(+), 11 deletions(-)

-- 
2.49.0




Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds