-/* replace_build_execution_state ***********************************************
-
- This function contains the final phase of replacement. It builds the new
- execution state, releases dump memory, and returns to the calling
- assembler function which finishes replacement.
-
- NOTE: This function is called from asm_replacement_in, with the stack
- pointer at the start of the safe stack area.
-
- THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
-
- CAUTION: This function and its children must not use a lot of stack!
- There are only REPLACE_SAFESTACK_SIZE bytes of C stack
- available.
-
- IN:
- st...............the safestack contained the necessary data
-
-*******************************************************************************/
-
-void replace_build_execution_state(replace_safestack_t *st)
-{
- replace_build_execution_state_intern(st->ss, &(st->es));
-
- DOLOG( replace_executionstate_println(&(st->es)); );
-
- /* release dump area */
-
- dump_release(st->dumpsize);
-
- /* new code is entered after returning */
-
- DOLOG( printf("JUMPING IN!\n"); fflush(stdout); );
-}
-
-
-/* replace_alloc_safestack *****************************************************
-
- Allocate a safe stack area to use during the final phase of replacement.
- The returned area is not initialized. This must be done by the caller.
-
- RETURN VALUE:
- a newly allocated replace_safestack_t *
-
-*******************************************************************************/
-
-static replace_safestack_t *replace_alloc_safestack()
-{
- u1 *mem;
- replace_safestack_t *st;
-
- mem = MNEW(u1, sizeof(replace_safestack_t) + REPLACE_STACK_ALIGNMENT - 1);
-
- st = (replace_safestack_t *) ((ptrint)(mem + REPLACE_STACK_ALIGNMENT - 1)
- & ~(REPLACE_STACK_ALIGNMENT - 1));
-
-#if !defined(NDEBUG)
- memset(st, 0xa5, sizeof(replace_safestack_t));
-#endif
-
- st->mem = mem;
-
- return st;
-}
-
-
-/* replace_free_safestack ******************************************************
-
- Free the given safestack structure, making a copy of the contained
- execution state before freeing it.
-
- NOTE: This function is called from asm_replacement_in.
-
- IN:
- st...............the safestack to free
- tmpes............where to copy the execution state to
-
- OUT:
- *tmpes...........receives a copy of st->es
-
-*******************************************************************************/
-
-void replace_free_safestack(replace_safestack_t *st, executionstate_t *tmpes)
-{
- u1 *mem;
-
- /* copy the executionstate_t to the temporary location */
-
- *tmpes = st->es;
-
- /* get the memory address to free */
-
- mem = st->mem;
-
- /* destroy memory (in debug mode) */
-
-#if !defined(NDEBUG)
- memset(st, 0xa5, sizeof(replace_safestack_t));
-#endif
-
- /* free the safe stack struct */
-
- MFREE(mem, u1, sizeof(replace_safestack_t) + REPLACE_STACK_ALIGNMENT - 1);
-}
-
-