Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@yahoo.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	 "Joos, Christina" <christina.joos@intel.com>
Subject: Re: [PATCH v5 8/9] Windows gdb: Implement AVX-512 register support
Date: Mon, 9 Nov 2026 17:22:21 +0000 (UTC)	[thread overview]
Message-ID: <1988371405.1685798.1794244941738@mail.yahoo.com> (raw)
In-Reply-To: <SN7PR11MB76380F598C9E37867CA2908689732@SN7PR11MB7638.namprd11.prod.outlook.com>

 Am Montag, 9. November 2026 um 18:00:14 MEZ hat Joos, Christina <christina.joos@intel.com> Folgendes geschrieben:

> > -----Original Message-----
> > From: Hannes Domani <ssbssa@yahoo.de>
> > Sent: Montag, 9. November 2026 17:16
> > To: gdb-patches@sourceware.org; Joos, Christina <christina.joos@intel.com>
> > Subject: Re: [PATCH v5 8/9] Windows gdb: Implement AVX-512 register
> > support
> >
> > Am Montag, 9. November 2026 um 16:03:08 MEZ hat Joos, Christina
> > <christina.joos@intel.com> Folgendes geschrieben:
> >
> > > > -----Original Message-----
> > > > From: Hannes Domani <ssbssa@yahoo.de>
> > > > Sent: Mittwoch, 4. November 2026 16:05
> > > > To: gdb-patches@sourceware.org
> > > > Subject: [PATCH v5 8/9] Windows gdb: Implement AVX-512 register
> > > > support
> > > >
> > > > This patch adds support for the Intel AVX-512 registers for 32 and
> > > > 64-bit mode on Windows, similar to what this commit does for Linux:
> > > >
> > > > commit 01f9f808e2e86187c95e7cff4aeb014a421a53ce
> > > > Date: Mon Dec 16 16:43:05 2013 +0100
> > > >
> > > > Add AVX512 registers support to GDB and GDBserver.
> > > >
> > > > It enables accessing registers $ymm16 - $ymm31, $zmm0 - $zmm31, and
> > > > $k0 - $k7 where they are available.
> > > >
> > > > After this patch gdb.arch/i386-avx512.exp passes on windows.
> > > > ---
> > > > v3:
> > > > - merged gdb+gdbserver parts, and split again AVX/AVX-512 parts
> > > > v4:
> > > > - Add reference to equivalent Linux commit in commit message
> > > > - Add check for enabled xstate_features in get_context_reg_ptr of
> > > > x86-windows-nat.c
> > > > - Changed all NULL to nullptr
> > > > v5:
> > > > - Improve commit message
> > > > - Split AVX-512 NEWS part from AVX
> > > > - Add asserts for locate_xstate_feature return value
> > > > - If not all AVX-512 features are available, disable all of them
> > > > ---
> > > > gdb/NEWS | 4 +++
> > > > gdb/nat/windows-nat.c | 7 +++--
> > > > gdb/x86-windows-nat.c | 45 +++++++++++++++++++++++++++++++
> > > > gdbserver/win32-i386-low.cc | 53
> > > > ++++++++++++++++++++++++++++++++++++-
> > > > 4 files changed, 106 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/gdb/NEWS b/gdb/NEWS
> > > > index f14d7ef4a84..4b40aeaeeb0 100644
> > > > --- a/gdb/NEWS
> > > > +++ b/gdb/NEWS
> > > > @@ -43,6 +43,10 @@
> > > > * Support for Intel AVX registers on Windows.
> > > > Support displaying and modifying Intel AVX registers $ymm0 - $ymm15.
> > > >
> > > > +* Support for Intel AVX-512 registers on Windows.
> > > > + Support displaying and modifying Intel AVX-512 registers $ymm16 -
> > > > +$ymm31,
> > > > + $zmm0 - $zmm31 and $k0 - $k7.
> > > > +
> > > > * New targets
> > > >
> > > > i386 Windows/MSVC i[34567]86-*-windows-msvc diff --git
> > > > a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index
> > > > cd3c827a5d5..bb55b2917e0 100644
> > > > --- a/gdb/nat/windows-nat.c
> > > > +++ b/gdb/nat/windows-nat.c
> > > > @@ -290,7 +290,7 @@ windows_thread_info::zero_xstate_features () if
> > > > (zeroed_features == 0) return;
> > > >
> > > > - for (int f = X86_XSTATE_AVX_ID; f <= X86_XSTATE_AVX_ID; f++)
> > > > + for (int f = X86_XSTATE_AVX_ID; f <= X86_XSTATE_ZMM_ID; f++)
> > > > {
> > > > DWORD64 flag = 1ULL << f;
> > > > if ((zeroed_features & flag) != 0)
> > > > @@ -1373,7 +1373,10 @@ initialize_loadable () {
> > > > /* Available XState features masked with implemented features. */
> > > > xstate_features = (GetEnabledXStateFeatures ()
> > > > - & X86_XSTATE_AVX_MASK);
> > > > + & X86_XSTATE_AVX_AVX512_MASK);
> > > > + /* If not all AVX-512 features are available, disable all of them.
> > > > + */ if ((xstate_features & X86_XSTATE_AVX512) != X86_XSTATE_AVX512)
> > > > + xstate_features &= ~X86_XSTATE_AVX512;
> > > > /* The extended XState functions are only needed if the available
> > > > features exceed SSE. */ if ((xstate_features & ~X86_XSTATE_SSE_MASK)
> > > > == 0) diff --git a/gdb/x86- windows-nat.c b/gdb/x86-windows-nat.c
> > > > index e4c947543d8..e27725ea29a
> > > > 100644
> > > > --- a/gdb/x86-windows-nat.c
> > > > +++ b/gdb/x86-windows-nat.c
> > > > @@ -277,6 +277,51 @@ get_context_reg_ptr (Context *context, int r,
> > > > i386_gdbarch_tdep *tdep) gdb_assert (context_offset != nullptr);
> > > > context_offset += 16 * (r - I387_YMM0H_REGNUM (tdep)); }
> > > > + else if ((xstate_features & X86_XSTATE_ZMM_H) != 0 &&
> > > > + I387_ZMM0H_REGNUM (tdep) > 0 && r >=
> > > > I387_ZMM0H_REGNUM (tdep)
> > > > + && r < I387_ZMM16H_REGNUM (tdep) && r <
> > > > I387_ZMMENDH_REGNUM (tdep))
> > > > + {
> > > > + context_offset = (char *) locate_xstate_feature (context,
> > > > + X86_XSTATE_ZMM_H_ID, nullptr); gdb_assert (context_offset !=
> > > > + nullptr); context_offset += 32 * (r - I387_ZMM0H_REGNUM (tdep)); }
> > > > + else if ((xstate_features & X86_XSTATE_ZMM) != 0 &&
> > > > + I387_ZMM0H_REGNUM (tdep) > 0 && r >=
> > > > I387_ZMM16H_REGNUM (tdep)
> > > > + && r < I387_ZMMENDH_REGNUM (tdep)) { context_offset = (char *)
> > > > + locate_xstate_feature (context, X86_XSTATE_ZMM_ID, nullptr);
> > > > + gdb_assert (context_offset != nullptr); context_offset += 32 + 64
> > > > + * (r - I387_ZMM16H_REGNUM (tdep)); } else if ((xstate_features &
> > > > + X86_XSTATE_K) != 0 && I387_K0_REGNUM (tdep) > 0 && r >=
> > > > + I387_K0_REGNUM (tdep) && r < I387_KEND_REGNUM (tdep)) {
> > > > + context_offset = (char *) locate_xstate_feature (context,
> > > > + X86_XSTATE_K_ID, nullptr); gdb_assert (context_offset != nullptr);
> > > > + context_offset += 8 * (r - I387_K0_REGNUM (tdep)); } else if
> > > > + ((xstate_features & X86_XSTATE_ZMM) != 0 && I387_YMM16H_REGNUM
> > > > + (tdep) > 0 && r >=
> > > > I387_YMM16H_REGNUM (tdep)
> > > > + && r < I387_YMMH_AVX512_END_REGNUM (tdep)) { context_offset =
> > > > + (char *) locate_xstate_feature (context, X86_XSTATE_ZMM_ID,
> > > > + nullptr); gdb_assert (context_offset != nullptr); context_offset
> > > > + += 16 + 64 * (r - I387_YMM16H_REGNUM (tdep)); } else if
> > > > + ((xstate_features & X86_XSTATE_ZMM) != 0 && I387_XMM16_REGNUM
> > > > + (tdep) > 0 && r >=
> > > > I387_XMM16_REGNUM (tdep)
> > > > + && r < I387_XMM_AVX512_END_REGNUM (tdep)) { context_offset =
> > (char
> > > > + *) locate_xstate_feature (context, X86_XSTATE_ZMM_ID, nullptr);
> > > > + gdb_assert (context_offset != nullptr); context_offset += 64 * (r
> > > > + - I387_XMM16_REGNUM (tdep)); }
> > > > else
> > > > gdb_assert_not_reached ("invalid register number %d", r);
> > >
> > > In my previous review I held back on this part since I'm not sure this
> > > structure is the right one to keep due to the open we discussed [1].
> > > If we do keep it, there's an easy
> > > simplification:
> > >
> > > else if ((xstate_features & X86_XSTATE_ZMM) != 0 &&
> > I387_ZMM0H_REGNUM
> > > (tdep) > 0) { [...]
> > >
> > > You could move all the regnum checks for these registers inside this
> > > block. Then we evaluate the condition only once. A similar refactoring is
> > possible for gdbserver below.
> >
> > I think I'm blind, because I don't see what you mean with this easy
> > simplification.
> > Since all the if()'s check for different registers, what exactly am I supposed to
> > move into this block?
> 
> Maybe I am blind, too. 😉 I meant something like this:
> 
> else if ((xstate_features & X86_XSTATE_ZMM) != 0
> && I387_ZMM0H_REGNUM (tdep) > 0)
> {
> context_offset = (char *) locate_xstate_feature
> (context, X86_XSTATE_ZMM_ID, nullptr);
> gdb_assert (context_offset != nullptr);
> 
> if (r >= I387_ZMM16H_REGNUM (tdep) && r < I387_ZMMENDH_REGNUM (tdep))
> context_offset += 32 + 64 * (r - I387_ZMM16H_REGNUM (tdep));
> else if (r >= I387_YMM16H_REGNUM (tdep)
> && r < I387_YMMH_AVX512_END_REGNUM (tdep))
> context_offset += 16 + 64 * (r - I387_YMM16H_REGNUM (tdep));
> [...]
> 
> Does that make sense?

Ah, you mean merging all the blocks with X86_XSTATE_ZMM_ID.
Is this if() then supposed to be the last one? Because it will always
be entered when these registers are available.
Am I still missing something?


Hannes

  reply	other threads:[~2026-11-09 17:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261104150749.3118853-1-ssbssa.ref@yahoo.de>
2026-11-04 15:05 ` [PATCH v5 1/9] gdb/testsuite: Add Windows replacement for aligned_alloc Hannes Domani
2026-11-04 15:05   ` [PATCH v5 2/9] Windows gdb: Use allocated buffer for CONTEXT Hannes Domani
2026-11-04 15:05   ` [PATCH v5 3/9] Windows gdb: Remove mappings member from windows_per_inferior Hannes Domani
2026-11-04 15:05   ` [PATCH v5 4/9] Windows gdb: Refactor getting pointer to register inside context Hannes Domani
2026-11-04 15:05   ` [PATCH v5 5/9] Windows gdb: Prepare XState functions Hannes Domani
2026-11-04 15:05   ` [PATCH v5 6/9] Windows gdb: Get available XState features Hannes Domani
2026-11-04 15:05   ` [PATCH v5 7/9] Windows gdb: Implement AVX register support Hannes Domani
2026-11-04 15:25     ` Eli Zaretskii
2026-11-09 15:15     ` Joos, Christina
2026-11-04 15:05   ` [PATCH v5 8/9] Windows gdb: Implement AVX-512 " Hannes Domani
2026-11-04 15:26     ` Eli Zaretskii
2026-11-09 15:02     ` Joos, Christina
2026-11-09 16:15       ` Hannes Domani
2026-11-09 17:00         ` Joos, Christina
2026-11-09 17:22           ` Hannes Domani [this message]
2026-11-09 18:44             ` Joos, Christina
2026-11-09 17:31           ` Joos, Christina
2026-11-09 19:20             ` Joos, Christina
2026-11-04 15:05   ` [PATCH v5 9/9] Windows gdbserver: Remove win32_target_ops "num_regs" method Hannes Domani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1988371405.1685798.1794244941738@mail.yahoo.com \
    --to=ssbssa@yahoo.de \
    --cc=christina.joos@intel.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox