1 use crate::arch::interrupt::TrapFrame;
2
setup_single_step(frame: &mut TrapFrame, step_addr: usize)3 pub fn setup_single_step(frame: &mut TrapFrame, step_addr: usize) {
4 frame.set_pc(step_addr);
5 }
6
clear_single_step(frame: &mut TrapFrame, return_addr: usize)7 pub fn clear_single_step(frame: &mut TrapFrame, return_addr: usize) {
8 frame.set_pc(return_addr);
9 }
10
11 #[repr(C)]
12 #[derive(Debug, Copy, Clone)]
13 pub struct KProbeContext {
14 pub pc: usize,
15 pub ra: usize,
16 pub sp: usize,
17 pub gp: usize,
18 pub tp: usize,
19 pub t0: usize,
20 pub t1: usize,
21 pub t2: usize,
22 pub s0: usize,
23 pub s1: usize,
24 pub a0: usize,
25 pub a1: usize,
26 pub a2: usize,
27 pub a3: usize,
28 pub a4: usize,
29 pub a5: usize,
30 pub a6: usize,
31 pub a7: usize,
32 pub s2: usize,
33 pub s3: usize,
34 pub s4: usize,
35 pub s5: usize,
36 pub s6: usize,
37 pub s7: usize,
38 pub s8: usize,
39 pub s9: usize,
40 pub s10: usize,
41 pub s11: usize,
42 pub t3: usize,
43 pub t4: usize,
44 pub t5: usize,
45 pub t6: usize,
46 }
47
48 impl From<&TrapFrame> for KProbeContext {
from(trap_frame: &TrapFrame) -> Self49 fn from(trap_frame: &TrapFrame) -> Self {
50 Self {
51 pc: trap_frame.epc,
52 ra: trap_frame.ra,
53 sp: trap_frame.sp,
54 gp: trap_frame.gp,
55 tp: trap_frame.tp,
56 t0: trap_frame.t0,
57 t1: trap_frame.t1,
58 t2: trap_frame.t2,
59 s0: trap_frame.s0,
60 s1: trap_frame.s1,
61 a0: trap_frame.a0,
62 a1: trap_frame.a1,
63 a2: trap_frame.a2,
64 a3: trap_frame.a3,
65 a4: trap_frame.a4,
66 a5: trap_frame.a5,
67 a6: trap_frame.a6,
68 a7: trap_frame.a7,
69 s2: trap_frame.s2,
70 s3: trap_frame.s3,
71 s4: trap_frame.s4,
72 s5: trap_frame.s5,
73 s6: trap_frame.s6,
74 s7: trap_frame.s7,
75 s8: trap_frame.s8,
76 s9: trap_frame.s9,
77 s10: trap_frame.s10,
78 s11: trap_frame.s11,
79 t3: trap_frame.t3,
80 t4: trap_frame.t4,
81 t5: trap_frame.t5,
82 t6: trap_frame.t6,
83 }
84 }
85 }
86