aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2024-05-07 20:34:18 +0100
committerPedro Alves <pedro@palves.net>2024-05-10 11:26:01 +0100
commitacd3803fa94f0f9cc5e47751d183320e12a2c90b (patch)
tree6bce4bd55591f2ce6ad39b1b439bc714d5a7cfe5
parent13c13b58d20b6d4691fe1df73d63213300838f9f (diff)
downloadfsf-binutils-gdb-acd3803fa94f0f9cc5e47751d183320e12a2c90b.zip
fsf-binutils-gdb-acd3803fa94f0f9cc5e47751d183320e12a2c90b.tar.gz
fsf-binutils-gdb-acd3803fa94f0f9cc5e47751d183320e12a2c90b.tar.bz2
windows_per_inferior::continue_one_thread, unify WoW64/non-WoW64 paths
Consolidate the WoW64 & non-WoW64 paths in windows_per_inferior::continue_one_thread to avoid code duplication. The next patch will add more code to this function, and this unification avoids writing that new code twice. Change-Id: I794aadb412a3b8081212e4acf2af80d3edba7392
-rw-r--r--gdb/windows-nat.c68
1 files changed, 32 insertions, 36 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index e12c7d5..bdabe67 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1289,64 +1289,60 @@ windows_per_inferior::continue_one_thread (windows_thread_info *th,
struct x86_debug_reg_state *state = x86_debug_reg_state (process_id);
#ifdef __x86_64__
- if (wow64_process)
+ DWORD &context_flags_ref = (wow64_process
+ ? th->wow64_context.ContextFlags
+ : th->context.ContextFlags);
+#else
+ DWORD &context_flags_ref = th->context.ContextFlags;
+#endif
+
+ if (th->debug_registers_changed)
{
- if (th->debug_registers_changed)
+ context_flags_ref |= CONTEXT_DEBUG_REGISTERS;
+#ifdef __x86_64__
+ if (wow64_process)
{
- 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
+ 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);
+ th->debug_registers_changed = false;
+ }
+ if (context_flags_ref != 0)
+ {
+ DWORD ec = 0;
- if ((cont_flags & WCONT_KILLED) == 0)
- CHECK (status);
- }
- th->context.ContextFlags = 0;
+ if (GetExitCodeThread (th->h, &ec)
+ && ec == STILL_ACTIVE)
+ {
+ BOOL status;
+#ifdef __x86_64__
+ if (wow64_process)
+ status = Wow64SetThreadContext (th->h, &th->wow64_context);
+ else
+#endif
+ status = SetThreadContext (th->h, &th->context);
+
+ if ((cont_flags & WCONT_KILLED) == 0)
+ CHECK (status);
}
+ context_flags_ref = 0;
}
+
th->resume ();
th->last_sig = GDB_SIGNAL_0;
}