From d6223690bef8d7eb48e26baad6f9db3f2fdef4a0 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Fri, 26 May 2023 00:54:09 +0100 Subject: [PATCH] Updated to bitflags 2.2.1. (#138) * Updated to bitflags 2.2.1. * Don't derive so many traits for ProtocolFeatures. * Update to bitflags 2.3.1. * Use external version of bitflags macro. --- Cargo.toml | 2 +- src/stub/core_impl.rs | 6 +++++- src/target/ext/host_io.rs | 32 ++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8f95cd..6e11ef4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ categories = ["development-tools::debugging", "embedded", "emulators", "network- exclude = ["examples/**/*.elf", "examples/**/*.o"] [dependencies] -bitflags = "1.3" +bitflags = "2.3.1" cfg-if = "1.0" log = "0.4" managed = { version = "0.8", default-features = false } diff --git a/src/stub/core_impl.rs b/src/stub/core_impl.rs index cf5bbb7..07774d4 100644 --- a/src/stub/core_impl.rs +++ b/src/stub/core_impl.rs @@ -249,11 +249,15 @@ impl GdbStubImpl { } } +#[derive(Copy, Clone)] +#[repr(transparent)] +struct ProtocolFeatures(u8); + // This bitflag is not part of the protocol - it is an internal implementation // detail. The alternative would be to use multiple `bool` fields, which wastes // space in minimal `gdbstub` configurations. bitflags::bitflags! { - struct ProtocolFeatures: u8 { + impl ProtocolFeatures: u8 { const NO_ACK_MODE = 1 << 0; const MULTIPROCESS = 1 << 1; } diff --git a/src/target/ext/host_io.rs b/src/target/ext/host_io.rs index b741299..1f5cfc6 100644 --- a/src/target/ext/host_io.rs +++ b/src/target/ext/host_io.rs @@ -3,14 +3,18 @@ use crate::arch::Arch; use crate::target::Target; use bitflags::bitflags; +/// Host flags for opening files. +/// +/// Extracted from the GDB documentation at +/// [Open Flags](https://sourceware.org/gdb/current/onlinedocs/gdb/Open-Flags.html#Open-Flags), +/// and the LLDB source code at +/// [`lldb/include/lldb/Host/File.h`](https://github.com/llvm/llvm-project/blob/ec642ceebc1aacc8b16249df7734b8cf90ae2963/lldb/include/lldb/Host/File.h#L47-L66) +#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[repr(transparent)] +pub struct HostIoOpenFlags(u32); + bitflags! { - /// Host flags for opening files. - /// - /// Extracted from the GDB documentation at - /// [Open Flags](https://sourceware.org/gdb/current/onlinedocs/gdb/Open-Flags.html#Open-Flags), - /// and the LLDB source code at - /// [`lldb/include/lldb/Host/File.h`](https://github.com/llvm/llvm-project/blob/ec642ceebc1aacc8b16249df7734b8cf90ae2963/lldb/include/lldb/Host/File.h#L47-L66) - pub struct HostIoOpenFlags: u32 { + impl HostIoOpenFlags: u32 { /// A read-only file. const O_RDONLY = 0x0; /// A write-only file. @@ -37,12 +41,16 @@ bitflags! { } } +/// Host file permissions. +/// +/// Extracted from the GDB documentation at +/// [mode_t Values](https://sourceware.org/gdb/current/onlinedocs/gdb/mode_005ft-Values.html#mode_005ft-Values) +#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[repr(transparent)] +pub struct HostIoOpenMode(u32); + bitflags! { - /// Host file permissions. - /// - /// Extracted from the GDB documentation at - /// [mode_t Values](https://sourceware.org/gdb/current/onlinedocs/gdb/mode_005ft-Values.html#mode_005ft-Values) - pub struct HostIoOpenMode: u32 { + impl HostIoOpenMode: u32 { /// A regular file. const S_IFREG = 0o100000; /// A directory.