- // Take a copy of the context for our own purpose:
- st->context = *(unw_context_t*)current_stack->context;
-#if defined(PROCESSOR_x86_64) || defined(PROCESSOR_i686)
- // On x86_64, ucontext_t contains a pointer to itself for FP registers.
- // We don't really need support for FR registers as they are caller saved
- // and probably never use those fields as libunwind-x86_64 does not read
- // FP registers from the unw_context_t
- // but we fix the pointer in order to avoid dangling pointers:
- st->context.uc_mcontext.fpregs = &st->context.__fpregs_mem;
-#else
- // Do we need to do any fixup like this?
- #error Target CPU type is not handled.
-#endif
+ unw_context_t* original_context = (unw_context_t*) current_stack->context;
+
+ st->context = xbt_new0(s_mc_unw_context_t, 1);
+ if (mc_unw_init_context(st->context, &mc_model_checker->process,
+ original_context) < 0) {
+ xbt_die("Could not initialise the libunwind context.");
+ }