From d39087b2e9cc0aaacc6bad7d7859279deb0dd9fc Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 14 Jan 2026 03:15:26 +0800 Subject: [PATCH] cleanup warnings in gdb debug and cleanup debug shell for bao1x bao1x debug shell has no input, so removing the help functions will save space in the kernel --- kernel/src/debug/gdb.rs | 6 ++++++ kernel/src/debug/gdb/multi_thread_base.rs | 6 +++--- kernel/src/debug/gdb/target.rs | 4 ++-- kernel/src/debug/shell.rs | 15 +++++++++------ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/kernel/src/debug/gdb.rs b/kernel/src/debug/gdb.rs index d050087a0..9efb1cbaa 100644 --- a/kernel/src/debug/gdb.rs +++ b/kernel/src/debug/gdb.rs @@ -5,6 +5,9 @@ use gdbstub::stub::{GdbStubBuilder, GdbStubError, MultiThreadStopReason}; use gdbstub::target::Target; use crate::io::SerialRead; +#[cfg(feature = "bao1x")] +use crate::platform::bao1x::gdbuart::GdbUart; +#[cfg(not(feature = "bao1x"))] use crate::platform::precursor::gdbuart::GdbUart; mod breakpoints; @@ -29,6 +32,9 @@ pub struct XousTarget { pub struct XousDebugState<'a> { pub target: XousTarget, + #[cfg(feature = "bao1x")] + pub server: GdbStubStateMachine<'a, XousTarget, crate::platform::bao1x::gdbuart::GdbUart>, + #[cfg(not(feature = "bao1x"))] pub server: GdbStubStateMachine<'a, XousTarget, crate::platform::precursor::gdbuart::GdbUart>, } diff --git a/kernel/src/debug/gdb/multi_thread_base.rs b/kernel/src/debug/gdb/multi_thread_base.rs index 894983179..ec46d6de5 100644 --- a/kernel/src/debug/gdb/multi_thread_base.rs +++ b/kernel/src/debug/gdb/multi_thread_base.rs @@ -75,8 +75,8 @@ impl MultiThreadBase for XousTarget { _tid: Tid, // same address space for each core ) -> TargetResult<(), Self> { let current_addr = start_addr as usize; - if (current_addr + data.len()) >= crate::arch::mem::USER_AREA_END - || (current_addr >= crate::arch::mem::USER_AREA_END) + if (current_addr + data.len()) >= xous_kernel::arch::USER_AREA_END + || (current_addr >= xous_kernel::arch::USER_AREA_END) { for entry in data.iter_mut() { *entry = 0 @@ -143,7 +143,7 @@ impl MultiThreadBase for XousTarget { return Ok(()); }; - if (current_addr + data.len()) > crate::arch::mem::USER_AREA_END { + if (current_addr + data.len()) > xous_kernel::arch::USER_AREA_END { return Ok(()); // don't allow reads outside of the user area } diff --git a/kernel/src/debug/gdb/target.rs b/kernel/src/debug/gdb/target.rs index 530a5c0e0..1afa70568 100644 --- a/kernel/src/debug/gdb/target.rs +++ b/kernel/src/debug/gdb/target.rs @@ -11,9 +11,9 @@ impl Target for XousTarget { type Arch = gdbstub_arch::riscv::Riscv32; type Error = &'static str; - fn base_ops(&mut self) -> BaseOps { BaseOps::MultiThread(self) } + fn base_ops(&mut self) -> BaseOps<'_, Self::Arch, Self::Error> { BaseOps::MultiThread(self) } - fn support_breakpoints(&mut self) -> Option> { Some(self) } + fn support_breakpoints(&mut self) -> Option> { Some(self) } /// Opt in to having GDB handle breakpoints for us. This allows for an unlimited number /// of breakpoints without having us keep track of the breakpoints ourselves, but diff --git a/kernel/src/debug/shell.rs b/kernel/src/debug/shell.rs index bf8552792..f091fef91 100644 --- a/kernel/src/debug/shell.rs +++ b/kernel/src/debug/shell.rs @@ -7,9 +7,10 @@ use core::fmt; -use crate::io::SerialWrite; +use crate::args::KernelArguments; #[cfg(not(feature = "bao1x"))] -use crate::{args::KernelArguments, io::SerialRead}; +use crate::io::SerialRead; +use crate::io::SerialWrite; /// Instance of the shell output. pub static mut OUTPUT: Option = None; @@ -58,7 +59,6 @@ impl fmt::Write for Output { /// Initialize the kernel shell. /// /// This should be called in platform initialization code. -#[cfg(not(feature = "bao1x"))] pub fn init(serial: &'static mut dyn SerialWrite) { unsafe { OUTPUT = Some(Output::new(serial)) } @@ -69,9 +69,12 @@ pub fn init(serial: &'static mut dyn SerialWrite) { println!(" {}", arg); } - println!("=== Kernel Debug Shell Available ===="); - print_help(); - println!("====================================="); + #[cfg(not(feature = "bao1x"))] + { + println!("=== Kernel Debug Shell Available ===="); + print_help(); + println!("====================================="); + } } /// Process possible characters received through a serial interface.