Skip to content

Commit ca0ed0e

Browse files
authored
Merge pull request #699 from phip1611/debug-everywhere
debug everywhere
2 parents c5d0d13 + ca16970 commit ca0ed0e

File tree

31 files changed

+187
-23
lines changed

31 files changed

+187
-23
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Rust 1.68 or higher.
2626
- `FileType`, `FileHandle`, `RegularFile`, and `Directory` now implement `Debug`.
2727
- Added `RuntimeServices::delete_variable()` helper method.
2828
- Implement `Borrow` for `CString16` and `ToOwned` for `CStr16`.
29+
- Every public struct now implements `Debug`. Exceptions are cases when there
30+
is no sensible way of presenting a useful Debug representation, such as for
31+
Unions.
2932

3033
### Changed
3134

uefi-services/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
2929
#![no_std]
3030
#![deny(clippy::must_use_candidate)]
31+
#![deny(missing_debug_implementations)]
3132

3233
extern crate log;
3334
// Core types.

uefi/src/allocator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn exit_boot_services() {
4949
/// Allocator which uses the UEFI pool allocation functions.
5050
///
5151
/// Only valid for as long as the UEFI boot services are available.
52+
#[derive(Debug)]
5253
pub struct Allocator;
5354

5455
unsafe impl GlobalAlloc for Allocator {

uefi/src/data_types/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl Handle {
4141
///
4242
/// If you need to have a nullable event, use `Option<Event>`.
4343
#[repr(transparent)]
44+
#[derive(Debug)]
4445
pub struct Event(NonNull<c_void>);
4546

4647
impl Event {

uefi/src/data_types/unaligned_slice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl<'a, T: Copy> IntoIterator for &'a UnalignedSlice<'a, T> {
163163
}
164164

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

181182
/// Iterator for a [`UnalignedSlice`] reference.
183+
#[derive(Debug)]
182184
pub struct UnalignedSliceIter<'a, T: Copy> {
183185
slice: &'a UnalignedSlice<'a, T>,
184186
index: usize,

uefi/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#![warn(clippy::ptr_as_ptr, missing_docs, unused)]
8484
#![deny(clippy::all)]
8585
#![deny(clippy::must_use_candidate)]
86+
#![deny(missing_debug_implementations)]
8687

8788
#[cfg(feature = "alloc")]
8889
extern crate alloc;

uefi/src/logger.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use core::ptr::NonNull;
2222
/// If this logger is used as a global logger, you must disable it using the
2323
/// `disable` method before exiting UEFI boot services in order to prevent
2424
/// undefined behaviour from inadvertent logging.
25+
#[derive(Debug)]
2526
pub struct Logger {
2627
writer: Option<NonNull<Output>>,
2728
}

uefi/src/proto/console/gop.rs

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use crate::proto::unsafe_protocol;
5454
use crate::util::usize_from_u32;
5555
use crate::{Result, Status};
56+
use core::fmt::{Debug, Formatter};
5657
use core::marker::PhantomData;
5758
use core::mem;
5859
use core::ptr;
@@ -375,6 +376,7 @@ pub struct PixelBitmask {
375376
}
376377

377378
/// Represents a graphics mode compatible with a given graphics device.
379+
#[derive(Debug)]
378380
pub struct Mode {
379381
index: u32,
380382
info_sz: usize,
@@ -472,6 +474,15 @@ impl<'gop> Iterator for ModeIter<'gop> {
472474
}
473475
}
474476

477+
impl<'gop> Debug for ModeIter<'gop> {
478+
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
479+
f.debug_struct("ModeIter")
480+
.field("current", &self.current)
481+
.field("max", &self.max)
482+
.finish()
483+
}
484+
}
485+
475486
impl ExactSizeIterator for ModeIter<'_> {}
476487

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

580591
/// Direct access to a memory-mapped frame buffer
592+
#[derive(Debug)]
581593
pub struct FrameBuffer<'gop> {
582594
base: *mut u8,
583595
size: usize,

uefi/src/proto/console/text/input.rs

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl From<RawKey> for Key {
111111

112112
/// A key read from the console (UEFI version)
113113
#[repr(C)]
114+
#[derive(Debug)]
114115
pub struct RawKey {
115116
/// The key's scan code.
116117
/// or 0 if printable

uefi/src/proto/console/text/output.rs

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ impl OutputMode {
288288
}
289289

290290
/// An iterator of the text modes (possibly) supported by a device.
291+
#[derive(Debug)]
291292
pub struct OutputModeIter<'out> {
292293
output: &'out mut Output,
293294
current: usize,

uefi/src/proto/debug/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// Universal EFI_SYSTEM_CONTEXT definition
55
/// This is passed to debug callbacks
66
#[repr(C)]
7+
#[allow(missing_debug_implementations)]
78
pub union SystemContext {
89
ebc: *mut SystemContextEBC,
910
riscv_32: *mut SystemContextRiscV32,

uefi/src/proto/debug/exception.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// Represents supported CPU exceptions.
22
#[repr(C)]
3+
#[derive(Debug)]
34
pub struct ExceptionType(isize);
45

56
impl ExceptionType {

uefi/src/proto/device_path/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use alloc::vec::Vec;
6969
/// # Ok(())
7070
/// # }
7171
/// ```
72+
#[derive(Debug)]
7273
pub struct DevicePathBuilder<'a> {
7374
storage: BuilderStorage<'a>,
7475
}
@@ -143,6 +144,7 @@ impl<'a> DevicePathBuilder<'a> {
143144
}
144145
}
145146

147+
#[derive(Debug)]
146148
enum BuilderStorage<'a> {
147149
Buf {
148150
buf: &'a mut [MaybeUninit<u8>],

0 commit comments

Comments
 (0)