-
- ret = thread_get_state(thread,
- x86_THREAD_STATE32,
- (thread_state_t)&thread_state,
- &thread_state_count);
- ret = thread_get_state(thread,
- x86_FLOAT_STATE32,
- (thread_state_t)&float_state,
- &float_state_count);
- ret = thread_get_state(thread,
- x86_EXCEPTION_STATE32,
- (thread_state_t)&exception_state,
- &exception_state_count);
- if (0xffff0b0f == *((u32 *)thread_state.eip)) {
- /* fake sigreturn. */
-
- /* When we get here, thread_state.eax is a pointer to a
- * thread_state to restore. */
- /* thread_state = *((thread_state_t *)thread_state.eax); */
-
- ret = thread_set_state(thread,
- x86_THREAD_STATE32,
- (thread_state_t) thread_state.eax,
- /* &thread_state, */
- thread_state_count);
-
- ret = thread_set_state(thread,
- x86_FLOAT_STATE32,
- (thread_state_t) thread_state.ebx,
- /* &thread_state, */
- float_state_count);
- } else {
-
- backup_thread_state = thread_state;
- open_stack_allocation(&thread_state);
-
- /* Save thread state */
- target_thread_state =
- stack_allocate(&thread_state, sizeof(*target_thread_state));
- (*target_thread_state) = backup_thread_state;
-
- target_float_state =
- stack_allocate(&thread_state, sizeof(*target_float_state));
- (*target_float_state) = float_state;
-
- /* Set up siginfo */
- siginfo = stack_allocate(&thread_state, sizeof(*siginfo));
- /* what do we need to put in our fake siginfo? It looks like
- * the x86 code only uses si_signo and si_adrr. */
- if (*((unsigned short *)target_thread_state->eip) == 0x0b0f) {
- signal = SIGTRAP;
- siginfo->si_signo = signal;
- siginfo->si_addr = (void*)exception_state.faultvaddr;
- target_thread_state->eip += 2;
- call_c_function_in_context(&thread_state,
- signal_emulation_wrapper,
- 5,
- target_thread_state,
- target_float_state,
- signal,
- siginfo,
- sigtrap_handler);
- } else {
- signal = SIGILL;
- siginfo->si_signo = signal;
- siginfo->si_addr = (void*)exception_state.faultvaddr;
-
- call_c_function_in_context(&thread_state,
- signal_emulation_wrapper,
- 5,
- target_thread_state,
- target_float_state,
- signal,
- siginfo,
- sigill_handler);
- }
- ret = thread_set_state(thread,
- x86_THREAD_STATE32,
- (thread_state_t)&thread_state,
- thread_state_count);
- ret = thread_set_state(thread,
- x86_FLOAT_STATE32,
- (thread_state_t)&float_state,
- float_state_count);