Skip to content

Commit

Permalink
Updated to bitflags 2.2.1. (#138)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
qwandor authored May 25, 2023
1 parent 2cf3299 commit d622369
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 5 additions & 1 deletion src/stub/core_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,15 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> {
}
}

#[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;
}
Expand Down
32 changes: 20 additions & 12 deletions src/target/ext/host_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit d622369

Please sign in to comment.