Debian Codegraph @

third_party/rust/minidump-writer/src/linux/thread_info/mips.rs

raw
1 use crate::{errors::ThreadInfoError, Pid};
2 use libc;
3
4 type Result<T> = std::result::Result<T, ThreadInfoError>;
5
6 #[derive(Debug)]
7 pub struct ThreadInfoMips {
8 pub stack_pointer: libc::c_ulonglong,
9 pub tgid: Pid, // thread group id
10 pub ppid: Pid, // parent process
11 // Use the structure defined in <sys/ucontext.h>
12 pub mcontext: libc::mcontext_t,
13 }
14
15 impl ThreadInfoMips {
16 pub fn get_instruction_pointer(&self) -> libc::c_ulonglong {
17 self.mcontext.pc
18 }
19
20 pub fn fill_cpu_context(&self, out: &mut RawContextCPU) {
21 // #if _MIPS_SIM == _ABI64
22 // out->context_flags = MD_CONTEXT_MIPS64_FULL;
23 // #elif _MIPS_SIM == _ABIO32
24 // out->context_flags = MD_CONTEXT_MIPS_FULL;
25 for idx in 0..MD_CONTEXT_MIPS_GPR_COUNT {
26 out.iregs[idx] = self.mcontext.gregs[idx];
27 }
28
29 out.mdhi = self.mcontext.mdhi;
30 out.mdlo = self.mcontext.mdlo;
31 out.dsp_control = self.mcontext.dsp;
32
33 out.hi[0] = self.mcontext.hi1;
34 out.lo[0] = self.mcontext.lo1;
35 out.hi[1] = self.mcontext.hi2;
36 out.lo[1] = self.mcontext.lo2;
37 out.hi[2] = self.mcontext.hi3;
38 out.lo[2] = self.mcontext.lo3;
39
40 out.epc = self.mcontext.pc;
41 out.badvaddr = 0; // Not stored in mcontext
42 out.status = 0; // Not stored in mcontext
43 out.cause = 0; // Not stored in mcontext
44
45 for idx in 0..MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT {
46 out.float_save.regs[idx] = self.mcontext.fpregs.fp_r.fp_fregs[idx]._fp_fregs;
47 }
48
49 out.float_save.fpcsr = mcontext.fpc_csr;
50
51 // #if _MIPS_SIM == _ABIO32
52 // out.float_save.fir = self.mcontext.fpc_eir;
53 // #endif
54 }
55 }