MCPcopy Create free account
hub / github.com/F-Stack/f-stack / get_mcontext

Function get_mcontext

freebsd/amd64/amd64/machdep.c:2270–2321  ·  view source on GitHub ↗

* Get machine context. */

Source from the content-addressed store, hash-verified

2268 * Get machine context.
2269 */
2270int
2271get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
2272{
2273 struct pcb *pcb;
2274 struct trapframe *tp;
2275
2276 pcb = td->td_pcb;
2277 tp = td->td_frame;
2278 PROC_LOCK(curthread->td_proc);
2279 mcp->mc_onstack = sigonstack(tp->tf_rsp);
2280 PROC_UNLOCK(curthread->td_proc);
2281 mcp->mc_r15 = tp->tf_r15;
2282 mcp->mc_r14 = tp->tf_r14;
2283 mcp->mc_r13 = tp->tf_r13;
2284 mcp->mc_r12 = tp->tf_r12;
2285 mcp->mc_r11 = tp->tf_r11;
2286 mcp->mc_r10 = tp->tf_r10;
2287 mcp->mc_r9 = tp->tf_r9;
2288 mcp->mc_r8 = tp->tf_r8;
2289 mcp->mc_rdi = tp->tf_rdi;
2290 mcp->mc_rsi = tp->tf_rsi;
2291 mcp->mc_rbp = tp->tf_rbp;
2292 mcp->mc_rbx = tp->tf_rbx;
2293 mcp->mc_rcx = tp->tf_rcx;
2294 mcp->mc_rflags = tp->tf_rflags;
2295 if (flags & GET_MC_CLEAR_RET) {
2296 mcp->mc_rax = 0;
2297 mcp->mc_rdx = 0;
2298 mcp->mc_rflags &= ~PSL_C;
2299 } else {
2300 mcp->mc_rax = tp->tf_rax;
2301 mcp->mc_rdx = tp->tf_rdx;
2302 }
2303 mcp->mc_rip = tp->tf_rip;
2304 mcp->mc_cs = tp->tf_cs;
2305 mcp->mc_rsp = tp->tf_rsp;
2306 mcp->mc_ss = tp->tf_ss;
2307 mcp->mc_ds = tp->tf_ds;
2308 mcp->mc_es = tp->tf_es;
2309 mcp->mc_fs = tp->tf_fs;
2310 mcp->mc_gs = tp->tf_gs;
2311 mcp->mc_flags = tp->tf_flags;
2312 mcp->mc_len = sizeof(*mcp);
2313 get_fpcontext(td, mcp, NULL, 0);
2314 update_pcb_bases(pcb);
2315 mcp->mc_fsbase = pcb->pcb_fsbase;
2316 mcp->mc_gsbase = pcb->pcb_gsbase;
2317 mcp->mc_xfpustate = 0;
2318 mcp->mc_xfpustate_len = 0;
2319 bzero(mcp->mc_spare, sizeof(mcp->mc_spare));
2320 return (0);
2321}
2322
2323/*
2324 * Set machine context.

Callers

nothing calls this directly

Calls 3

sigonstackFunction · 0.85
bzeroFunction · 0.85
get_fpcontextFunction · 0.70

Tested by

no test coverage detected