diff options
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r-- | gdb/windows-nat.c | 137 |
1 files changed, 72 insertions, 65 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 8b9b1ea..2cfc855 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -114,6 +114,9 @@ struct windows_per_inferior : public windows_process_info void invalidate_context (windows_thread_info *th); + void continue_one_thread (windows_thread_info *th, + windows_continue_flags cont_flags); + int windows_initialization_done = 0; std::vector<std::unique_ptr<windows_thread_info>> thread_list; @@ -1274,6 +1277,74 @@ windows_per_inferior::handle_access_violation return false; } +void +windows_per_inferior::continue_one_thread (windows_thread_info *th, + windows_continue_flags cont_flags) +{ + struct x86_debug_reg_state *state = x86_debug_reg_state (process_id); + +#ifdef __x86_64__ + if (wow64_process) + { + if (th->debug_registers_changed) + { + th->wow64_context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; + th->wow64_context.Dr0 = state->dr_mirror[0]; + th->wow64_context.Dr1 = state->dr_mirror[1]; + th->wow64_context.Dr2 = state->dr_mirror[2]; + th->wow64_context.Dr3 = state->dr_mirror[3]; + th->wow64_context.Dr6 = DR6_CLEAR_VALUE; + th->wow64_context.Dr7 = state->dr_control_mirror; + th->debug_registers_changed = false; + } + if (th->wow64_context.ContextFlags) + { + DWORD ec = 0; + + if (GetExitCodeThread (th->h, &ec) + && ec == STILL_ACTIVE) + { + BOOL status = Wow64SetThreadContext (th->h, + &th->wow64_context); + + if ((cont_flags & WCONT_KILLED) == 0) + CHECK (status); + } + th->wow64_context.ContextFlags = 0; + } + } + else +#endif + { + if (th->debug_registers_changed) + { + th->context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; + th->context.Dr0 = state->dr_mirror[0]; + th->context.Dr1 = state->dr_mirror[1]; + th->context.Dr2 = state->dr_mirror[2]; + th->context.Dr3 = state->dr_mirror[3]; + th->context.Dr6 = DR6_CLEAR_VALUE; + th->context.Dr7 = state->dr_control_mirror; + th->debug_registers_changed = false; + } + if (th->context.ContextFlags) + { + DWORD ec = 0; + + if (GetExitCodeThread (th->h, &ec) + && ec == STILL_ACTIVE) + { + BOOL status = SetThreadContext (th->h, &th->context); + + if ((cont_flags & WCONT_KILLED) == 0) + CHECK (status); + } + th->context.ContextFlags = 0; + } + } + th->resume (); +} + /* Resume thread specified by ID, or all artificially suspended threads, if we are continuing execution. See windows_continue_flags' description for CONT_FLAGS. */ @@ -1295,71 +1366,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, for (auto &th : windows_process.thread_list) if (id == -1 || id == (int) th->tid) - { - struct x86_debug_reg_state *state - = x86_debug_reg_state (windows_process.process_id); - -#ifdef __x86_64__ - if (windows_process.wow64_process) - { - if (th->debug_registers_changed) - { - th->wow64_context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; - th->wow64_context.Dr0 = state->dr_mirror[0]; - th->wow64_context.Dr1 = state->dr_mirror[1]; - th->wow64_context.Dr2 = state->dr_mirror[2]; - th->wow64_context.Dr3 = state->dr_mirror[3]; - th->wow64_context.Dr6 = DR6_CLEAR_VALUE; - th->wow64_context.Dr7 = state->dr_control_mirror; - th->debug_registers_changed = false; - } - if (th->wow64_context.ContextFlags) - { - DWORD ec = 0; - - if (GetExitCodeThread (th->h, &ec) - && ec == STILL_ACTIVE) - { - BOOL status = Wow64SetThreadContext (th->h, - &th->wow64_context); - - if ((cont_flags & WCONT_KILLED) == 0) - CHECK (status); - } - th->wow64_context.ContextFlags = 0; - } - } - else -#endif - { - if (th->debug_registers_changed) - { - th->context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; - th->context.Dr0 = state->dr_mirror[0]; - th->context.Dr1 = state->dr_mirror[1]; - th->context.Dr2 = state->dr_mirror[2]; - th->context.Dr3 = state->dr_mirror[3]; - th->context.Dr6 = DR6_CLEAR_VALUE; - th->context.Dr7 = state->dr_control_mirror; - th->debug_registers_changed = false; - } - if (th->context.ContextFlags) - { - DWORD ec = 0; - - if (GetExitCodeThread (th->h, &ec) - && ec == STILL_ACTIVE) - { - BOOL status = SetThreadContext (th->h, &th->context); - - if ((cont_flags & WCONT_KILLED) == 0) - CHECK (status); - } - th->context.ContextFlags = 0; - } - } - th->resume (); - } + windows_process.continue_one_thread (th.get (), cont_flags); continue_last_debug_event_main_thread (_("Failed to resume program execution"), continue_status, |