mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
kernel: gdb: don't panic when accessing kernel memory
Instead, just return 0x00000000. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9c2523ded4
commit
0673ad912c
1 changed files with 19 additions and 5 deletions
|
|
@ -53,9 +53,7 @@ impl MultiThreadBase for XousTarget {
|
||||||
regs: &gdbstub_arch::riscv::reg::RiscvCoreRegs<u32>,
|
regs: &gdbstub_arch::riscv::reg::RiscvCoreRegs<u32>,
|
||||||
tid: Tid,
|
tid: Tid,
|
||||||
) -> TargetResult<(), Self> {
|
) -> TargetResult<(), Self> {
|
||||||
let Some(pid) = self.pid else {
|
let Some(pid) = self.pid else { return Ok(()) };
|
||||||
return Ok(())
|
|
||||||
};
|
|
||||||
|
|
||||||
crate::services::SystemServices::with(|system_services| {
|
crate::services::SystemServices::with(|system_services| {
|
||||||
let current_pid = system_services.current_pid();
|
let current_pid = system_services.current_pid();
|
||||||
|
|
@ -92,8 +90,19 @@ impl MultiThreadBase for XousTarget {
|
||||||
_tid: Tid, // same address space for each core
|
_tid: Tid, // same address space for each core
|
||||||
) -> TargetResult<(), Self> {
|
) -> TargetResult<(), Self> {
|
||||||
let current_addr = start_addr as usize;
|
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)
|
||||||
|
{
|
||||||
|
for entry in data.iter_mut() {
|
||||||
|
*entry = 0
|
||||||
|
}
|
||||||
|
return Ok(()); // don't allow reads outside of the user area
|
||||||
|
}
|
||||||
|
|
||||||
let Some(pid) = self.pid else {
|
let Some(pid) = self.pid else {
|
||||||
for entry in data.iter_mut() { *entry = 0 };
|
for entry in data.iter_mut() {
|
||||||
|
*entry = 0
|
||||||
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -153,11 +162,16 @@ impl MultiThreadBase for XousTarget {
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
_tid: Tid, // all threads share the same process memory space
|
_tid: Tid, // all threads share the same process memory space
|
||||||
) -> TargetResult<(), Self> {
|
) -> TargetResult<(), Self> {
|
||||||
let mut current_addr = start_addr;
|
let mut current_addr = start_addr as usize;
|
||||||
let Some(pid) = self.pid else {
|
let Some(pid) = self.pid else {
|
||||||
println!("Couldn't poke memory: no current process!");
|
println!("Couldn't poke memory: no current process!");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (current_addr + data.len()) > crate::arch::mem::USER_AREA_END {
|
||||||
|
return Ok(()); // don't allow reads outside of the user area
|
||||||
|
}
|
||||||
|
|
||||||
crate::services::SystemServices::with(|system_services| {
|
crate::services::SystemServices::with(|system_services| {
|
||||||
let current_pid = system_services.current_pid();
|
let current_pid = system_services.current_pid();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue