diff options
author | Joel Galenson <jgalenson@google.com> | 2021-04-02 21:33:55 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-02 21:33:55 +0000 |
commit | 30ab38732c571957f9e174cfcdc7121e5331904c (patch) | |
tree | 1500d46718fb1a9b7a31aedf6a4f3aa7d68b849d | |
parent | b9d82314b432fabbc3f4ccb1f40d0c8f0446fb30 (diff) | |
parent | a229ba522dbcafec58afddd186f60c07667e164a (diff) | |
download | gdbstub-android12-qpr1-d-s1-release.tar.gz |
Upgrade rust/crates/gdbstub to 0.4.5 am: 06ef78fa3a am: 2b39a690ee am: a229ba522dandroid-12.0.0_r32android-12.0.0_r29android-12.0.0_r28android-12.0.0_r27android-12.0.0_r26android-12.0.0_r21android-12.0.0_r20android-12.0.0_r19android-12.0.0_r18android-12.0.0_r16android12-qpr1-releaseandroid12-qpr1-d-s3-releaseandroid12-qpr1-d-s2-releaseandroid12-qpr1-d-s1-releaseandroid12-qpr1-d-releaseandroid12-dev
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/gdbstub/+/1662786
Change-Id: I7a38ddafb8af314f03503b8f29022ec8d01e457f
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 6 | ||||
-rw-r--r-- | CHANGELOG.md | 12 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | examples/armv4t/gdb/mod.rs | 8 | ||||
-rw-r--r-- | examples/armv4t/gdb/target_description_xml_override.rs | 9 | ||||
-rw-r--r-- | src/arch/traits.rs | 9 | ||||
-rw-r--r-- | src/gdbstub_impl/mod.rs | 12 | ||||
-rw-r--r-- | src/protocol/console_output.rs | 2 | ||||
-rw-r--r-- | src/target/ext/mod.rs | 3 | ||||
-rw-r--r-- | src/target/ext/target_description_xml_override.rs | 22 | ||||
-rw-r--r-- | src/target/mod.rs | 14 |
14 files changed, 90 insertions, 21 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 95b71cd..72ca90a 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "dcbe203cd7d7fab60004aecefdbddd55fc2d115c" + "sha1": "7574b03e021e79b7023c76b21a340da197fd16c2" } } @@ -29,10 +29,6 @@ rust_library { "default", "std", ], - apex_available: [ - "//apex_available:platform", - "com.android.virt", - ], rustlibs: [ "libcfg_if", "liblog_rust", @@ -49,4 +45,4 @@ rust_library { // log-0.4.14 "std" // managed-0.8.0 "alloc" // num-traits-0.2.14 -// paste-1.0.4 +// paste-1.0.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index d69f0e3..2021cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# 0.4.5 + +#### New Protocol Extensions + +- `TargetDescriptionXmlOverride` - Allow targets to override the target description XML file (`target.xml`) specified by `Target::Arch::target_description_xml`. This is useful in cases where a `Target` is expected to be generic over multiple architectures. [\#43](https://github.com/daniel5151/gdbstub/pull/43) (with help from [DrChat](https://github.com/DrChat)) + +# 0.4.4 + +#### Bugfixes + +- use `write!` instead of `writeln!` in `output!` macro [\#41](https://github.com/daniel5151/gdbstub/issues/41) + # 0.4.3 #### New Arch Implementations @@ -13,7 +13,7 @@ [package] edition = "2018" name = "gdbstub" -version = "0.4.3" +version = "0.4.5" authors = ["Daniel Prilik <danielprilik@gmail.com>"] exclude = ["examples/**/*.elf", "examples/**/*.o"] description = "An implementation of the GDB Remote Serial Protocol in Rust" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index f01c556..7f2e7d5 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -2,7 +2,7 @@ name = "gdbstub" description = "An implementation of the GDB Remote Serial Protocol in Rust" authors = ["Daniel Prilik <danielprilik@gmail.com>"] -version = "0.4.3" +version = "0.4.5" license = "MIT" edition = "2018" readme = "README.md" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/gdbstub/gdbstub-0.4.3.crate" + value: "https://static.crates.io/crates/gdbstub/gdbstub-0.4.5.crate" } - version: "0.4.3" + version: "0.4.5" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 28 + month: 4 + day: 1 } } diff --git a/examples/armv4t/gdb/mod.rs b/examples/armv4t/gdb/mod.rs index ae3cbd9..7decab9 100644 --- a/examples/armv4t/gdb/mod.rs +++ b/examples/armv4t/gdb/mod.rs @@ -15,6 +15,7 @@ use crate::emu::{Emu, Event}; mod extended_mode; mod monitor_cmd; mod section_offsets; +mod target_description_xml_override; /// Turn a `ArmCoreRegId` into an internal register number of `armv4t_emu`. fn cpu_reg_id(id: ArmCoreRegId) -> Option<u8> { @@ -55,6 +56,13 @@ impl Target for Emu { fn section_offsets(&mut self) -> Option<target::ext::section_offsets::SectionOffsetsOps<Self>> { Some(self) } + + fn target_description_xml_override( + &mut self, + ) -> Option<target::ext::target_description_xml_override::TargetDescriptionXmlOverrideOps<Self>> + { + Some(self) + } } impl SingleThreadOps for Emu { diff --git a/examples/armv4t/gdb/target_description_xml_override.rs b/examples/armv4t/gdb/target_description_xml_override.rs new file mode 100644 index 0000000..843697e --- /dev/null +++ b/examples/armv4t/gdb/target_description_xml_override.rs @@ -0,0 +1,9 @@ +use gdbstub::target; + +use crate::emu::Emu; + +impl target::ext::target_description_xml_override::TargetDescriptionXmlOverride for Emu { + fn target_description_xml(&self) -> &str { + r#"<target version="1.0"><!-- custom override string --><architecture>armv4t</architecture></target>"# + } +} diff --git a/src/arch/traits.rs b/src/arch/traits.rs index 1903739..4af97ec 100644 --- a/src/arch/traits.rs +++ b/src/arch/traits.rs @@ -63,18 +63,17 @@ pub trait Arch { /// separate from the main `Registers` structure. type RegId: RegId; - /// (optional) Return the platform's `features.xml` file. + /// (optional) Return the target's description XML file (`target.xml`). /// - /// Implementing this method enables `gdb` to automatically detect the + /// Implementing this method enables GDB to automatically detect the /// target's architecture, saving the hassle of having to run `set /// architecture <arch>` when starting a debugging session. /// /// These descriptions can be quite succinct. For example, the target - /// description for an `armv4t` platform can be as simple as: + /// description for an `armv4t` target can be as simple as: /// /// ``` - /// r#"<target version="1.0"><architecture>armv4t</architecture></target>"# - /// # ; + /// r#"<target version="1.0"><architecture>armv4t</architecture></target>"#; /// ``` /// /// See the [GDB docs](https://sourceware.org/gdb/current/onlinedocs/gdb/Target-Description-Format.html) diff --git a/src/gdbstub_impl/mod.rs b/src/gdbstub_impl/mod.rs index c0f714c..72572fb 100644 --- a/src/gdbstub_impl/mod.rs +++ b/src/gdbstub_impl/mod.rs @@ -303,7 +303,9 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> { // TODO: implement conditional breakpoint support (since that's kool). // res.write_str("ConditionalBreakpoints+;")?; - if T::Arch::target_description_xml().is_some() { + if T::Arch::target_description_xml().is_some() + || target.target_description_xml_override().is_some() + { res.write_str(";qXfer:features:read+")?; } @@ -314,7 +316,13 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> { HandlerStatus::NeedsOK } ext::Base::qXferFeaturesRead(cmd) => { - match T::Arch::target_description_xml() { + #[allow(clippy::redundant_closure)] + let xml = target + .target_description_xml_override() + .map(|ops| ops.target_description_xml()) + .or_else(|| T::Arch::target_description_xml()); + + match xml { Some(xml) => { let xml = xml.trim(); if cmd.offset >= xml.len() { diff --git a/src/protocol/console_output.rs b/src/protocol/console_output.rs index 73157bc..211d8db 100644 --- a/src/protocol/console_output.rs +++ b/src/protocol/console_output.rs @@ -75,7 +75,7 @@ impl Drop for ConsoleOutput<'_> { macro_rules! output { ($console_output:expr, $($args:tt)*) => {{ use std::fmt::Write; - let _ = writeln!($console_output, $($args)*); + let _ = write!($console_output, $($args)*); }}; } diff --git a/src/target/ext/mod.rs b/src/target/ext/mod.rs index f3a0b54..9289655 100644 --- a/src/target/ext/mod.rs +++ b/src/target/ext/mod.rs @@ -101,7 +101,7 @@ //! //! - (library) Define a `trait OptExt: Target { ... }` with all the optional //! methods: -//! - Making `OptExt` a supertrait of `Target` enables using `Target`'s +//! - Making `OptExt` a subtrait of `Target` enables using `Target`'s //! associated types. //! //! ```rust,ignore @@ -250,3 +250,4 @@ pub mod breakpoints; pub mod extended_mode; pub mod monitor_cmd; pub mod section_offsets; +pub mod target_description_xml_override; diff --git a/src/target/ext/target_description_xml_override.rs b/src/target/ext/target_description_xml_override.rs new file mode 100644 index 0000000..7cac034 --- /dev/null +++ b/src/target/ext/target_description_xml_override.rs @@ -0,0 +1,22 @@ +//! Override the target description XML specified by `Target::Arch`. +use crate::target::Target; + +/// Target Extension - Override the target description XML specified by +/// `Target::Arch`. +/// +/// _Note:_ Unless you're working with a particularly dynamic, +/// runtime-configurable target, it's unlikely that you'll need to implement +/// this extension. +pub trait TargetDescriptionXmlOverride: Target { + /// Return the target's description XML file (`target.xml`). + /// + /// Refer to the + /// [target_description_xml](crate::arch::Arch::target_description_xml) + /// docs for more info. + fn target_description_xml(&self) -> &str; +} + +define_ext!( + TargetDescriptionXmlOverrideOps, + TargetDescriptionXmlOverride +); diff --git a/src/target/mod.rs b/src/target/mod.rs index c027824..e2139fb 100644 --- a/src/target/mod.rs +++ b/src/target/mod.rs @@ -239,6 +239,13 @@ pub trait Target { fn section_offsets(&mut self) -> Option<ext::section_offsets::SectionOffsetsOps<Self>> { None } + + /// Override the target description XML specified by `Target::Arch`. + fn target_description_xml_override( + &mut self, + ) -> Option<ext::target_description_xml_override::TargetDescriptionXmlOverrideOps<Self>> { + None + } } macro_rules! impl_dyn_target { @@ -278,6 +285,13 @@ macro_rules! impl_dyn_target { fn section_offsets(&mut self) -> Option<ext::section_offsets::SectionOffsetsOps<Self>> { (**self).section_offsets() } + + fn target_description_xml_override( + &mut self, + ) -> Option<ext::target_description_xml_override::TargetDescriptionXmlOverrideOps<Self>> + { + (**self).target_description_xml_override() + } } }; } |