kernel: debug panic: Use Capabilities instead of unsafe
#4479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Overview
This is a step towards enabling the lint
missing_safety_doc
(https://rust-lang.github.io/rust-clippy/master/#/missing_safety_doc).One place we have undocumented
unsafe
APIs in the kernel is in debug, particularly for the panic helpers. It seems to me that these areunsafe
because we don't want capsules to call them, not because we are signaling that there are Rust invariants that must be considered before calling them.This adds a
DebugCapability
capability and switches the debug panic APIs fromunsafe
to using the capability. This propagates into chips and arch. Again, I don't know if specifyingprint_state
asunsafe
was intentional or just propagated theunsafe
.Draft because switching to capabilities may not be the way to go. However, having this PR I think is still helpful because we should either switch to capabilities or document the unsafe expectations.
Testing Strategy
draft
TODO or Help Wanted
arch/cortex-m/src/lib.rs::print_cortexm_state
?debug::flush()
correct?Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.