Skip to content

feat(wdk): add error-level debug output - #721

Open
ITSMESB (ITSMERNB) wants to merge 2 commits into
microsoft:mainfrom
ITSMERNB:feat/wdk-eprintln-debug-level
Open

feat(wdk): add error-level debug output#721
ITSMESB (ITSMERNB) wants to merge 2 commits into
microsoft:mainfrom
ITSMERNB:feat/wdk-eprintln-debug-level

Conversation

@ITSMERNB

@ITSMERNB ITSMESB (ITSMERNB) commented Aug 18, 2026

Copy link
Copy Markdown

Summary

  • add a no_std eprintln! macro for WDK debug output
  • route WDM/KMDF print! and println! through DbgPrintEx at DPFLTR_INFO_LEVEL
  • route eprintln! and dbg! through DbgPrintEx at DPFLTR_ERROR_LEVEL
  • preserve the existing DbgPrint component/filter behavior with DPFLTR_DEFAULT_ID
  • keep UMDF output on OutputDebugStringA, which has no message-level parameter

Fixes #616

Testing

  • cargo test -p wdk --locked (29 unit tests + doctests pass)
  • cargo clippy -p wdk --locked --all-targets -- -D warnings
  • git diff --check
  • KMDF/UMDF fixture checks reach wdk-sys but the local WDK install is missing Windows Kits\10\Include\10.0.26100.0\km\crt, so bindgen stops before compiling the driver-model-specific crate path.

Copilot AI lite review requested due to automatic review settings August 18, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the debugger print plumbing to use DbgPrintEx (enabling message levels), adds an eprintln! macro for error-level output, and updates dbg! to route through error-level printing.

Changes:

  • Replace DbgPrint documentation/usage with DbgPrintEx for WDM/KMDF output.
  • Add eprintln! plus internal _eprint support, and update dbg! to use eprintln!.
  • Introduce an internal print-level abstraction (DebugPrintLevel) and consolidate printing via _print_with_level.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/wdk/src/print.rs Adds eprintln!, introduces _print_with_level using DbgPrintEx, and updates docs/dbg! to match the new behavior.
crates/wdk/src/lib.rs Re-exports _eprint alongside _print so the new macro can call into crate internals.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/wdk/src/print.rs
Comment thread crates/wdk/src/print.rs Outdated
Copilot AI review requested due to automatic review settings August 18, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

crates/wdk/src/print.rs:142

  • dbg! now routes through eprintln!, which (for WDM/KMDF) maps to DbgPrintEx(..., DPFLTR_ERROR_LEVEL, ...). This is a behavior change from the prior println! path (INFO/default-level) and can affect consumers who filter error-level output differently (e.g., treating it as higher-severity noise or missing it if only INFO is enabled). Consider keeping dbg! on the INFO path (e.g., continue using println!/_print) and reserving eprintln! for explicitly error-level logging; alternatively, make the level selection for dbg! explicit in the API/docs.
        $crate::eprintln!("[{}:{}:{}]", core::file!(), core::line!(), core::column!())

crates/wdk/src/print.rs:149

  • dbg! now routes through eprintln!, which (for WDM/KMDF) maps to DbgPrintEx(..., DPFLTR_ERROR_LEVEL, ...). This is a behavior change from the prior println! path (INFO/default-level) and can affect consumers who filter error-level output differently (e.g., treating it as higher-severity noise or missing it if only INFO is enabled). Consider keeping dbg! on the INFO path (e.g., continue using println!/_print) and reserving eprintln! for explicitly error-level logging; alternatively, make the level selection for dbg! explicit in the API/docs.
                $crate::eprintln!(

crates/wdk/src/print.rs:197

  • The local level shadows the level: DebugPrintLevel parameter, which makes the code harder to read (the identifier refers to different types before/after the match). Rename the converted value (e.g., dpfltr_level) to avoid shadowing and clarify intent.
            let level = match level {
                DebugPrintLevel::Error => wdk_sys::DPFLTR_ERROR_LEVEL,
                DebugPrintLevel::Info => wdk_sys::DPFLTR_INFO_LEVEL,
            };

@ITSMERNB

Copy link
Copy Markdown
Author

Addressed the two review notes in 3ccc4eb: DbgPrintEx now keeps DPFLTR_DEFAULT_ID so existing print!/println! visibility is preserved while only the message level changes, and the unused enum discriminants are removed. cargo test -p wdk --locked passes 29 unit tests plus doctests, and clippy is clean with -D warnings.

@ITSMERNB

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement an eprintln! macro and replace the println! implementation in dbg!

2 participants