Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1740 from reicast/skmp/store-uctx-not-mctx
Browse files Browse the repository at this point in the history
Linux/Context: Store uctx, not mctx. mctx sometimes misses the float regs
  • Loading branch information
skmp committed Aug 30, 2019
2 parents 9aa8304 + 5edcf55 commit d350e68
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libswirl/linux/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

//////

#define UCTX(p) (((ucontext_t *)(segfault_ctx))->uc_mcontext p)
#define UCTX(p) (((ucontext_t *)(segfault_ctx)) p)

#if HOST_OS == OS_DARWIN
#define UCTX_type mcontext_t
#define UCTX_type ucontext_t
#define UCTX_data (UCTX())
#else
#define UCTX_type mcontext_t
#define UCTX_data (&UCTX())
#define UCTX_type ucontext_t
#define UCTX_data (UCTX())
#endif

template <typename Ta, typename Tb>
Expand All @@ -45,19 +45,19 @@ void segfault_store(void* segfault_ctx) {
#if !defined(TARGET_NO_EXCEPTIONS)
memcpy(&segfault_copy, UCTX_data, sizeof(segfault_copy));

fault_printf("sgctx stored, %d pc: %p\n", sizeof(segfault_copy), segfault_copy.gregs[REG_RIP]);
fault_printf("sgctx stored, %d\n", sizeof(segfault_copy));
#endif
}

void segfault_load(void* segfault_ctx) {
#if !defined(TARGET_NO_EXCEPTIONS)
memcpy(UCTX_data, &segfault_copy, sizeof(*UCTX_data));

fault_printf("sgctx loaded, %d pc: %p\n", sizeof(*UCTX_data), UCTX_data->gregs[REG_RIP]);
fault_printf("sgctx loaded, %d\n", sizeof(*UCTX_data));
#endif
}

#define MCTX(p) ((*(UCTX_type*)segfault_ctx) p)
#define MCTX(p) (((UCTX_type*)segfault_ctx)->uc_mcontext p)

void context_segfault_bicopy(rei_host_context_t* reictx, void* segfault_ctx, bool to_segfault) {

Expand Down

0 comments on commit d350e68

Please sign in to comment.