Skip to content

Commit

Permalink
Merge pull request #699 from phip1611/debug-everywhere
Browse files Browse the repository at this point in the history
debug everywhere
  • Loading branch information
phip1611 authored Mar 24, 2023
2 parents c5d0d13 + ca16970 commit ca0ed0e
Show file tree
Hide file tree
Showing 31 changed files with 187 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Rust 1.68 or higher.
- `FileType`, `FileHandle`, `RegularFile`, and `Directory` now implement `Debug`.
- Added `RuntimeServices::delete_variable()` helper method.
- Implement `Borrow` for `CString16` and `ToOwned` for `CStr16`.
- Every public struct now implements `Debug`. Exceptions are cases when there
is no sensible way of presenting a useful Debug representation, such as for
Unions.

### Changed

Expand Down
1 change: 1 addition & 0 deletions uefi-services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![no_std]
#![deny(clippy::must_use_candidate)]
#![deny(missing_debug_implementations)]

extern crate log;
// Core types.
Expand Down
1 change: 1 addition & 0 deletions uefi/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn exit_boot_services() {
/// Allocator which uses the UEFI pool allocation functions.
///
/// Only valid for as long as the UEFI boot services are available.
#[derive(Debug)]
pub struct Allocator;

unsafe impl GlobalAlloc for Allocator {
Expand Down
1 change: 1 addition & 0 deletions uefi/src/data_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl Handle {
///
/// If you need to have a nullable event, use `Option<Event>`.
#[repr(transparent)]
#[derive(Debug)]
pub struct Event(NonNull<c_void>);

impl Event {
Expand Down
2 changes: 2 additions & 0 deletions uefi/src/data_types/unaligned_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl<'a, T: Copy> IntoIterator for &'a UnalignedSlice<'a, T> {
}

/// Iterator for a [`UnalignedSlice`].
#[derive(Debug)]
pub struct UnalignedSliceIntoIter<'a, T: Copy> {
slice: UnalignedSlice<'a, T>,
index: usize,
Expand All @@ -179,6 +180,7 @@ impl<'a, T: Copy> Iterator for UnalignedSliceIntoIter<'a, T> {
}

/// Iterator for a [`UnalignedSlice`] reference.
#[derive(Debug)]
pub struct UnalignedSliceIter<'a, T: Copy> {
slice: &'a UnalignedSlice<'a, T>,
index: usize,
Expand Down
1 change: 1 addition & 0 deletions uefi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
#![warn(clippy::ptr_as_ptr, missing_docs, unused)]
#![deny(clippy::all)]
#![deny(clippy::must_use_candidate)]
#![deny(missing_debug_implementations)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
1 change: 1 addition & 0 deletions uefi/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use core::ptr::NonNull;
/// If this logger is used as a global logger, you must disable it using the
/// `disable` method before exiting UEFI boot services in order to prevent
/// undefined behaviour from inadvertent logging.
#[derive(Debug)]
pub struct Logger {
writer: Option<NonNull<Output>>,
}
Expand Down
12 changes: 12 additions & 0 deletions uefi/src/proto/console/gop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use crate::proto::unsafe_protocol;
use crate::util::usize_from_u32;
use crate::{Result, Status};
use core::fmt::{Debug, Formatter};
use core::marker::PhantomData;
use core::mem;
use core::ptr;
Expand Down Expand Up @@ -375,6 +376,7 @@ pub struct PixelBitmask {
}

/// Represents a graphics mode compatible with a given graphics device.
#[derive(Debug)]
pub struct Mode {
index: u32,
info_sz: usize,
Expand Down Expand Up @@ -472,6 +474,15 @@ impl<'gop> Iterator for ModeIter<'gop> {
}
}

impl<'gop> Debug for ModeIter<'gop> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.debug_struct("ModeIter")
.field("current", &self.current)
.field("max", &self.max)
.finish()
}
}

impl ExactSizeIterator for ModeIter<'_> {}

/// Format of pixel data used for blitting.
Expand Down Expand Up @@ -578,6 +589,7 @@ pub enum BltOp<'buf> {
}

/// Direct access to a memory-mapped frame buffer
#[derive(Debug)]
pub struct FrameBuffer<'gop> {
base: *mut u8,
size: usize,
Expand Down
1 change: 1 addition & 0 deletions uefi/src/proto/console/text/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl From<RawKey> for Key {

/// A key read from the console (UEFI version)
#[repr(C)]
#[derive(Debug)]
pub struct RawKey {
/// The key's scan code.
/// or 0 if printable
Expand Down
1 change: 1 addition & 0 deletions uefi/src/proto/console/text/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl OutputMode {
}

/// An iterator of the text modes (possibly) supported by a device.
#[derive(Debug)]
pub struct OutputModeIter<'out> {
output: &'out mut Output,
current: usize,
Expand Down
1 change: 1 addition & 0 deletions uefi/src/proto/debug/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// Universal EFI_SYSTEM_CONTEXT definition
/// This is passed to debug callbacks
#[repr(C)]
#[allow(missing_debug_implementations)]
pub union SystemContext {
ebc: *mut SystemContextEBC,
riscv_32: *mut SystemContextRiscV32,
Expand Down
1 change: 1 addition & 0 deletions uefi/src/proto/debug/exception.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Represents supported CPU exceptions.
#[repr(C)]
#[derive(Debug)]
pub struct ExceptionType(isize);

impl ExceptionType {
Expand Down
2 changes: 2 additions & 0 deletions uefi/src/proto/device_path/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use alloc::vec::Vec;
/// # Ok(())
/// # }
/// ```
#[derive(Debug)]
pub struct DevicePathBuilder<'a> {
storage: BuilderStorage<'a>,
}
Expand Down Expand Up @@ -143,6 +144,7 @@ impl<'a> DevicePathBuilder<'a> {
}
}

#[derive(Debug)]
enum BuilderStorage<'a> {
Buf {
buf: &'a mut [MaybeUninit<u8>],
Expand Down
Loading

0 comments on commit ca0ed0e

Please sign in to comment.