1*fae6e9adSlinfeng use crate::arch::interrupt::TrapFrame;
2*fae6e9adSlinfeng
setup_single_step(frame: &mut TrapFrame, step_addr: usize)3*fae6e9adSlinfeng pub fn setup_single_step(frame: &mut TrapFrame, step_addr: usize) {
4*fae6e9adSlinfeng frame.rflags |= 0x100;
5*fae6e9adSlinfeng frame.set_pc(step_addr);
6*fae6e9adSlinfeng }
7*fae6e9adSlinfeng
clear_single_step(frame: &mut TrapFrame, return_addr: usize)8*fae6e9adSlinfeng pub fn clear_single_step(frame: &mut TrapFrame, return_addr: usize) {
9*fae6e9adSlinfeng frame.rflags &= !0x100;
10*fae6e9adSlinfeng frame.set_pc(return_addr);
11*fae6e9adSlinfeng }
12*fae6e9adSlinfeng
13*fae6e9adSlinfeng #[repr(C)]
14*fae6e9adSlinfeng #[derive(Debug, Copy, Clone)]
15*fae6e9adSlinfeng pub struct KProbeContext {
16*fae6e9adSlinfeng pub r15: ::core::ffi::c_ulong,
17*fae6e9adSlinfeng pub r14: ::core::ffi::c_ulong,
18*fae6e9adSlinfeng pub r13: ::core::ffi::c_ulong,
19*fae6e9adSlinfeng pub r12: ::core::ffi::c_ulong,
20*fae6e9adSlinfeng pub rbp: ::core::ffi::c_ulong,
21*fae6e9adSlinfeng pub rbx: ::core::ffi::c_ulong,
22*fae6e9adSlinfeng pub r11: ::core::ffi::c_ulong,
23*fae6e9adSlinfeng pub r10: ::core::ffi::c_ulong,
24*fae6e9adSlinfeng pub r9: ::core::ffi::c_ulong,
25*fae6e9adSlinfeng pub r8: ::core::ffi::c_ulong,
26*fae6e9adSlinfeng pub rax: ::core::ffi::c_ulong,
27*fae6e9adSlinfeng pub rcx: ::core::ffi::c_ulong,
28*fae6e9adSlinfeng pub rdx: ::core::ffi::c_ulong,
29*fae6e9adSlinfeng pub rsi: ::core::ffi::c_ulong,
30*fae6e9adSlinfeng pub rdi: ::core::ffi::c_ulong,
31*fae6e9adSlinfeng pub orig_rax: ::core::ffi::c_ulong,
32*fae6e9adSlinfeng pub rip: ::core::ffi::c_ulong,
33*fae6e9adSlinfeng pub cs: ::core::ffi::c_ulong,
34*fae6e9adSlinfeng pub eflags: ::core::ffi::c_ulong,
35*fae6e9adSlinfeng pub rsp: ::core::ffi::c_ulong,
36*fae6e9adSlinfeng pub ss: ::core::ffi::c_ulong,
37*fae6e9adSlinfeng }
38*fae6e9adSlinfeng
39*fae6e9adSlinfeng impl From<&TrapFrame> for KProbeContext {
from(trap_frame: &TrapFrame) -> Self40*fae6e9adSlinfeng fn from(trap_frame: &TrapFrame) -> Self {
41*fae6e9adSlinfeng Self {
42*fae6e9adSlinfeng r15: trap_frame.r15,
43*fae6e9adSlinfeng r14: trap_frame.r14,
44*fae6e9adSlinfeng r13: trap_frame.r13,
45*fae6e9adSlinfeng r12: trap_frame.r12,
46*fae6e9adSlinfeng rbp: trap_frame.rbp,
47*fae6e9adSlinfeng rbx: trap_frame.rbx,
48*fae6e9adSlinfeng r11: trap_frame.r11,
49*fae6e9adSlinfeng r10: trap_frame.r10,
50*fae6e9adSlinfeng r9: trap_frame.r9,
51*fae6e9adSlinfeng r8: trap_frame.r8,
52*fae6e9adSlinfeng rax: trap_frame.rax,
53*fae6e9adSlinfeng rcx: trap_frame.rcx,
54*fae6e9adSlinfeng rdx: trap_frame.rdx,
55*fae6e9adSlinfeng rsi: trap_frame.rsi,
56*fae6e9adSlinfeng rdi: trap_frame.rdi,
57*fae6e9adSlinfeng orig_rax: 0,
58*fae6e9adSlinfeng rip: trap_frame.rip,
59*fae6e9adSlinfeng cs: trap_frame.cs,
60*fae6e9adSlinfeng eflags: trap_frame.rflags,
61*fae6e9adSlinfeng rsp: trap_frame.rsp,
62*fae6e9adSlinfeng ss: trap_frame.ss,
63*fae6e9adSlinfeng }
64*fae6e9adSlinfeng }
65*fae6e9adSlinfeng }
66