[binutils-gdb] Simplify windows_nat_target::resume

Hannes Domani ssbssa@sourceware.org
Fri Jan 23 19:18:35 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a46710128afb6d959c6d3e8d0e0f8caad936c3fd

commit a46710128afb6d959c6d3e8d0e0f8caad936c3fd
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Fri Jan 23 20:07:04 2026 +0100

    Simplify windows_nat_target::resume
    
    Now the thread context is only needed for setting the trace bit, so move
    the rest out of the with_context lambda.
    
    Approved-By: Tom Tromey <tom@tromey.com>
    Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>

Diff:
---
 gdb/windows-nat.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a6fd199530c..32bb8b1cd3a 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1366,18 +1366,15 @@ windows_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
   /* Get context for currently selected thread.  */
   th = windows_process.thread_rec (inferior_ptid, DONT_INVALIDATE_CONTEXT);
-  if (th)
+  if (th != nullptr && step)
     {
+      /* Single step by setting t bit.  */
+      regcache *regcache = get_thread_regcache (inferior_thread ());
+      struct gdbarch *gdbarch = regcache->arch ();
+      fetch_registers (regcache, gdbarch_ps_regnum (gdbarch));
       windows_process.with_context (th, [&] (auto *context)
 	{
-	  if (step)
-	    {
-	      /* Single step by setting t bit.  */
-	      regcache *regcache = get_thread_regcache (inferior_thread ());
-	      struct gdbarch *gdbarch = regcache->arch ();
-	      fetch_registers (regcache, gdbarch_ps_regnum (gdbarch));
-	      context->EFlags |= FLAG_TRACE_BIT;
-	    }
+	  context->EFlags |= FLAG_TRACE_BIT;
 	});
     }


More information about the Gdb-cvs mailing list