aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2023-05-09 20:34:50 +0100
committerPedro Alves <pedro@palves.net>2024-05-10 11:25:58 +0100
commit8055ea0bb694c37fe3e0a90a17d3b29b85a538c1 (patch)
treec9942664bf81af07391f8fdb6639b6c5e25f62a8
parent49fcf1ccc7453b3f88499359364a0643f943927d (diff)
downloadfsf-binutils-gdb-8055ea0bb694c37fe3e0a90a17d3b29b85a538c1.zip
fsf-binutils-gdb-8055ea0bb694c37fe3e0a90a17d3b29b85a538c1.tar.gz
fsf-binutils-gdb-8055ea0bb694c37fe3e0a90a17d3b29b85a538c1.tar.bz2
Windows gdb: Factor code out of windows_nat_target::windows_continue
This factors some code out of windows_nat_target::windows_continue into a new windows_continue_one function. This will make the following patch easier to read (as well as the resulting code itself). Change-Id: I14a0386b1b8b03015e86273060af173b5130e375
-rw-r--r--gdb/windows-nat.c137
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,