]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use appropriate context flags for Wow64 processes
authorHannes Domani <ssbssa@yahoo.de>
Fri, 22 Nov 2024 19:10:22 +0000 (20:10 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Fri, 22 Nov 2024 19:10:26 +0000 (20:10 +0100)
When I implemented debugging of Wow64 processes, I missed that there are
extra ContextFlags defines for them.
It's a bit surprising that the wrong ones actually worked, except that
CONTEXT_EXTENDED_REGISTERS is not available for x86_64, and they are
needed for i686, since that's where the xmm registers are stored.

So this replaces the ContextFlags values with their WOW64_* equivalents.
On gdbserver this also duplicates the fallback logic if the
GetThreadContext call failed with CONTEXT_EXTENDED_REGISTERS.

Fixes these fails:
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check contents of data[0]
FAIL: gdb.arch/i386-sse.exp: check contents of data[1]
FAIL: gdb.arch/i386-sse.exp: check contents of data[2]
FAIL: gdb.arch/i386-sse.exp: check contents of data[3]
FAIL: gdb.arch/i386-sse.exp: check contents of data[4]
FAIL: gdb.arch/i386-sse.exp: check contents of data[5]
FAIL: gdb.arch/i386-sse.exp: check contents of data[6]
FAIL: gdb.arch/i386-sse.exp: check contents of data[7]

Approved-By: Tom Tromey <tom@tromey.com>
gdb/windows-nat.c
gdbserver/win32-i386-low.cc

index 37c1f46be35cace6a2ff11616ba38d48da2f68e4..abacafe7af8e48e7c7cb98a464b6314feb0c7f34 100644 (file)
@@ -730,7 +730,7 @@ windows_nat_target::fetch_registers (struct regcache *regcache, int r)
 #ifdef __x86_64__
       if (windows_process.wow64_process)
        {
-         th->wow64_context.ContextFlags = CONTEXT_DEBUGGER_DR;
+         th->wow64_context.ContextFlags = WOW64_CONTEXT_ALL;
          CHECK (Wow64GetThreadContext (th->h, &th->wow64_context));
          /* Copy dr values from that thread.
             But only if there were not modified since last stop.
@@ -1290,7 +1290,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id,
          {
            if (th->debug_registers_changed)
              {
-               th->wow64_context.ContextFlags |= CONTEXT_DEBUG_REGISTERS;
+               th->wow64_context.ContextFlags |= WOW64_CONTEXT_DEBUG_REGISTERS;
                th->wow64_context.Dr0 = windows_process.dr[0];
                th->wow64_context.Dr1 = windows_process.dr[1];
                th->wow64_context.Dr2 = windows_process.dr[2];
index 688e0123025984e7dc456fb12e66169ba461e3f9..7898ac12bcf906508158a202d08165f2906b6a9c 100644 (file)
@@ -250,14 +250,17 @@ i386_get_thread_context (windows_thread_info *th)
   /* Requesting the CONTEXT_EXTENDED_REGISTERS register set fails if
      the system doesn't support extended registers.  */
   static DWORD extended_registers = CONTEXT_EXTENDED_REGISTERS;
+#ifdef __x86_64__
+  static DWORD wow64_extended_registers = WOW64_CONTEXT_EXTENDED_REGISTERS;
+#endif
 
  again:
 #ifdef __x86_64__
   if (windows_process.wow64_process)
-    th->wow64_context.ContextFlags = (CONTEXT_FULL
-                                     | CONTEXT_FLOATING_POINT
-                                     | CONTEXT_DEBUG_REGISTERS
-                                     | extended_registers);
+    th->wow64_context.ContextFlags = (WOW64_CONTEXT_FULL
+                                     | WOW64_CONTEXT_FLOATING_POINT
+                                     | WOW64_CONTEXT_DEBUG_REGISTERS
+                                     | wow64_extended_registers);
   else
 #endif
     th->context.ContextFlags = (CONTEXT_FULL
@@ -276,10 +279,23 @@ i386_get_thread_context (windows_thread_info *th)
     {
       DWORD e = GetLastError ();
 
-      if (extended_registers && e == ERROR_INVALID_PARAMETER)
+#ifdef __x86_64__
+      if (windows_process.wow64_process)
+       {
+         if (wow64_extended_registers && e == ERROR_INVALID_PARAMETER)
+           {
+             wow64_extended_registers = 0;
+             goto again;
+           }
+       }
+      else
+#endif
        {
-         extended_registers = 0;
-         goto again;
+         if (extended_registers && e == ERROR_INVALID_PARAMETER)
+           {
+             extended_registers = 0;
+             goto again;
+           }
        }
 
       error ("GetThreadContext failure %ld\n", (long) e);