Skip to content
Snippets Groups Projects
Verified Commit cdcb3448 authored by jD91mZM2's avatar jD91mZM2
Browse files

Keep singlestep across signals

parent 77f3a17c
No related branches found
No related tags found
No related merge requests found
......@@ -323,6 +323,10 @@ impl InterruptStack {
self.iret.rflags &= !(1 << 8);
}
}
/// Checks if the trap flag is enabled, see `set_singlestep`
pub fn is_singlestep(&self) -> bool {
self.iret.rflags & 1 << 8 == 1 << 8
}
}
macro_rules! interrupt_push {
......
use core::sync::atomic::Ordering;
use crate::context::{arch, contexts, Context, Status, CONTEXT_ID};
use crate::context::signal::signal_handler;
use crate::context::{arch, contexts, Context, Status, CONTEXT_ID};
use crate::gdt;
use crate::interrupt;
use crate::interrupt::irq::PIT_TICKS;
use crate::interrupt;
use crate::ptrace;
use crate::time;
unsafe fn update(context: &mut Context, cpu_id: usize) {
......@@ -16,6 +17,8 @@ unsafe fn update(context: &mut Context, cpu_id: usize) {
// Restore from signal, must only be done from another context to avoid overwriting the stack!
if context.ksig_restore && ! context.running {
let was_singlestep = ptrace::regs_for(context).map(|s| s.is_singlestep()).unwrap_or(false);
let ksig = context.ksig.take().expect("context::switch: ksig not set with ksig_restore");
context.arch = ksig.0;
......@@ -33,6 +36,11 @@ unsafe fn update(context: &mut Context, cpu_id: usize) {
context.ksig_restore = false;
// Keep singlestep flag across jumps
if let Some(regs) = ptrace::regs_for_mut(context) {
regs.set_singlestep(was_singlestep);
}
context.unblock();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment