feat(wdk): add error-level debug output - #721
Conversation
There was a problem hiding this comment.
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
DbgPrintdocumentation/usage withDbgPrintExfor WDM/KMDF output. - Add
eprintln!plus internal_eprintsupport, and updatedbg!to useeprintln!. - 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.
There was a problem hiding this comment.
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 througheprintln!, which (for WDM/KMDF) maps toDbgPrintEx(..., DPFLTR_ERROR_LEVEL, ...). This is a behavior change from the priorprintln!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 keepingdbg!on the INFO path (e.g., continue usingprintln!/_print) and reservingeprintln!for explicitly error-level logging; alternatively, make the level selection fordbg!explicit in the API/docs.
$crate::eprintln!("[{}:{}:{}]", core::file!(), core::line!(), core::column!())
crates/wdk/src/print.rs:149
dbg!now routes througheprintln!, which (for WDM/KMDF) maps toDbgPrintEx(..., DPFLTR_ERROR_LEVEL, ...). This is a behavior change from the priorprintln!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 keepingdbg!on the INFO path (e.g., continue usingprintln!/_print) and reservingeprintln!for explicitly error-level logging; alternatively, make the level selection fordbg!explicit in the API/docs.
$crate::eprintln!(
crates/wdk/src/print.rs:197
- The local
levelshadows thelevel: DebugPrintLevelparameter, which makes the code harder to read (the identifier refers to different types before/after thematch). 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,
};
|
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. |
|
@microsoft-github-policy-service agree |
Summary
eprintln!macro for WDK debug outputprint!andprintln!throughDbgPrintExatDPFLTR_INFO_LEVELeprintln!anddbg!throughDbgPrintExatDPFLTR_ERROR_LEVELDbgPrintcomponent/filter behavior withDPFLTR_DEFAULT_IDOutputDebugStringA, which has no message-level parameterFixes #616
Testing
cargo test -p wdk --locked(29 unit tests + doctests pass)cargo clippy -p wdk --locked --all-targets -- -D warningsgit diff --checkwdk-sysbut the local WDK install is missingWindows Kits\10\Include\10.0.26100.0\km\crt, so bindgen stops before compiling the driver-model-specific crate path.