diff --git a/src/gdbstub_impl/mod.rs b/src/gdbstub_impl/mod.rs index c0f714c8..4ecad26c 100644 --- a/src/gdbstub_impl/mod.rs +++ b/src/gdbstub_impl/mod.rs @@ -303,7 +303,9 @@ impl GdbStubImpl { // TODO: implement conditional breakpoint support (since that's kool). // res.write_str("ConditionalBreakpoints+;")?; - if T::Arch::target_description_xml().is_some() { + // FIXME: `description_xml` returns an owned String, so this is not a very + // efficient way to check if it will return a custom description. + if target.description_xml().is_some() { res.write_str(";qXfer:features:read+")?; } @@ -314,7 +316,7 @@ impl GdbStubImpl { HandlerStatus::NeedsOK } ext::Base::qXferFeaturesRead(cmd) => { - match T::Arch::target_description_xml() { + match target.description_xml() { Some(xml) => { let xml = xml.trim(); if cmd.offset >= xml.len() { diff --git a/src/target/mod.rs b/src/target/mod.rs index c027824e..9bb6d616 100644 --- a/src/target/mod.rs +++ b/src/target/mod.rs @@ -239,6 +239,16 @@ pub trait Target { fn section_offsets(&mut self) -> Option> { None } + + /// Get the target description in XML. + /// In most cases you will not need to implement this method, and can simply + /// rely on the one defined in [`Arch`]. + /// + /// Please refer to [`Arch::target_description_xml`] for further + /// documentation. + fn description_xml(&self) -> Option<&'static str> { + Self::Arch::target_description_xml() + } } macro_rules! impl_dyn_target {