Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Schimpe, Christina" <christina.schimpe@intel.com>
To: Hannes Domani <ssbssa@yahoo.de>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>
Subject: RE: [PATCH v2 07/11] Move x86 selector code into x86-windows-nat.c
Date: Mon, 19 Jan 2026 13:56:02 +0000	[thread overview]
Message-ID: <SN7PR11MB7638534D2BFCB0F4A2308466F988A@SN7PR11MB7638.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20260117134052.2660009-7-ssbssa@yahoo.de>

> -----Original Message-----
> From: Hannes Domani <ssbssa@yahoo.de>
> Sent: Samstag, 17. Januar 2026 14:36
> To: gdb-patches@sourceware.org
> Cc: Tom Tromey <tom@tromey.com>
> Subject: [PATCH v2 07/11] Move x86 selector code into x86-windows-nat.c
> 
> Approved-By: Tom Tromey <tom@tromey.com>
> ---
> No changes in v2
> ---
>  gdb/windows-nat.c     | 125 -----------------------------------------
>  gdb/x86-windows-nat.c | 127
> ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 127 insertions(+), 125 deletions(-)
> 
> diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index
> 926b85d479b..f9d07336cca 100644
> --- a/gdb/windows-nat.c
> +++ b/gdb/windows-nat.c
> @@ -685,127 +685,6 @@
> windows_per_inferior::handle_output_debug_string
>    return retval;
>  }
> 
> -static int
> -display_selector (HANDLE thread, DWORD sel) -{
> -  LDT_ENTRY info;
> -  BOOL ret = windows_process->with_context (nullptr, [&] (auto *context)
> -    {
> -      return get_thread_selector_entry (context, thread, sel, &info);
> -    });
> -  if (ret)
> -    {
> -      int base, limit;
> -      gdb_printf ("0x%03x: ", (unsigned) sel);
> -      if (!info.HighWord.Bits.Pres)
> -	{
> -	  gdb_puts ("Segment not present\n");
> -	  return 0;
> -	}
> -      base = (info.HighWord.Bits.BaseHi << 24) +
> -	     (info.HighWord.Bits.BaseMid << 16)
> -	     + info.BaseLow;
> -      limit = (info.HighWord.Bits.LimitHi << 16) + info.LimitLow;
> -      if (info.HighWord.Bits.Granularity)
> -	limit = (limit << 12) | 0xfff;
> -      gdb_printf ("base=0x%08x limit=0x%08x", base, limit);
> -      if (info.HighWord.Bits.Default_Big)
> -	gdb_puts(" 32-bit ");
> -      else
> -	gdb_puts(" 16-bit ");
> -      switch ((info.HighWord.Bits.Type & 0xf) >> 1)
> -	{
> -	case 0:
> -	  gdb_puts ("Data (Read-Only, Exp-up");
> -	  break;
> -	case 1:
> -	  gdb_puts ("Data (Read/Write, Exp-up");
> -	  break;
> -	case 2:
> -	  gdb_puts ("Unused segment (");
> -	  break;
> -	case 3:
> -	  gdb_puts ("Data (Read/Write, Exp-down");
> -	  break;
> -	case 4:
> -	  gdb_puts ("Code (Exec-Only, N.Conf");
> -	  break;
> -	case 5:
> -	  gdb_puts ("Code (Exec/Read, N.Conf");
> -	  break;
> -	case 6:
> -	  gdb_puts ("Code (Exec-Only, Conf");
> -	  break;
> -	case 7:
> -	  gdb_puts ("Code (Exec/Read, Conf");
> -	  break;
> -	default:
> -	  gdb_printf ("Unknown type 0x%lx",
> -		      (unsigned long) info.HighWord.Bits.Type);
> -	}
> -      if ((info.HighWord.Bits.Type & 0x1) == 0)
> -	gdb_puts(", N.Acc");
> -      gdb_puts (")\n");
> -      if ((info.HighWord.Bits.Type & 0x10) == 0)
> -	gdb_puts("System selector ");
> -      gdb_printf ("Privilege level = %ld. ",
> -		  (unsigned long) info.HighWord.Bits.Dpl);
> -      if (info.HighWord.Bits.Granularity)
> -	gdb_puts ("Page granular.\n");
> -      else
> -	gdb_puts ("Byte granular.\n");
> -      return 1;
> -    }
> -  else
> -    {
> -      DWORD err = GetLastError ();
> -      if (err == ERROR_NOT_SUPPORTED)
> -	gdb_printf ("Function not supported\n");
> -      else
> -	gdb_printf ("Invalid selector 0x%x.\n", (unsigned) sel);
> -      return 0;
> -    }
> -}
> -
> -static void
> -display_selectors (const char * args, int from_tty) -{
> -  if (inferior_ptid == null_ptid)
> -    {
> -      gdb_puts ("Impossible to display selectors now.\n");
> -      return;
> -    }
> -
> -  windows_thread_info *current_windows_thread
> -    = windows_process->thread_rec (inferior_ptid,
> DONT_INVALIDATE_CONTEXT);
> -
> -  if (!args)
> -    {
> -      windows_process->with_context (current_windows_thread, [&] (auto
> *context)
> -	{
> -	  gdb_puts ("Selector $cs\n");
> -	  display_selector (current_windows_thread->h, context->SegCs);
> -	  gdb_puts ("Selector $ds\n");
> -	  display_selector (current_windows_thread->h, context->SegDs);
> -	  gdb_puts ("Selector $es\n");
> -	  display_selector (current_windows_thread->h, context->SegEs);
> -	  gdb_puts ("Selector $ss\n");
> -	  display_selector (current_windows_thread->h, context->SegSs);
> -	  gdb_puts ("Selector $fs\n");
> -	  display_selector (current_windows_thread->h, context->SegFs);
> -	  gdb_puts ("Selector $gs\n");
> -	  display_selector (current_windows_thread->h, context->SegGs);
> -	});
> -    }
> -  else
> -    {
> -      int sel;
> -      sel = parse_and_eval_long (args);
> -      gdb_printf ("Selector \"%s\"\n",args);
> -      display_selector (current_windows_thread->h, sel);
> -    }
> -}
> -
>  /* See nat/windows-nat.h.  */
> 
>  bool
> @@ -2727,10 +2606,6 @@ Show whether to display kernel exceptions in
> child process."), NULL,
> 
>    init_w32_command_list ();
> 
> -  add_cmd ("selector", class_info, display_selectors,
> -	   _("Display selectors infos."),
> -	   &info_w32_cmdlist);
> -
>    if (!initialize_loadable ())
>      {
>        /* This will probably fail on Windows 9x/Me.  Let the user know diff --git
> a/gdb/x86-windows-nat.c b/gdb/x86-windows-nat.c index
> 96dd61b39fb..7538c360bfe 100644
> --- a/gdb/x86-windows-nat.c
> +++ b/gdb/x86-windows-nat.c
> @@ -17,9 +17,11 @@
>     You should have received a copy of the GNU General Public License
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> 
> +#include "windows-tdep.h"
>  #include "windows-nat.h"
>  #include "regcache.h"
>  #include "gdbarch.h"
> +#include "inferior.h"
> 
>  #include "x86-nat.h"
> 
> @@ -346,6 +348,127 @@ cygwin_get_dr7 (void)
>    return (unsigned long) x86_windows_process.dr[7];  }
> 
> +static int
> +display_selector (HANDLE thread, DWORD sel) {
> +  LDT_ENTRY info;
> +  BOOL ret = windows_process->with_context (nullptr, [&] (auto *context)
> +    {
> +      return get_thread_selector_entry (context, thread, sel, &info);
> +    });
> +  if (ret)
> +    {
> +      int base, limit;
> +      gdb_printf ("0x%03x: ", (unsigned) sel);
> +      if (!info.HighWord.Bits.Pres)
> +	{
> +	  gdb_puts ("Segment not present\n");
> +	  return 0;
> +	}
> +      base = (info.HighWord.Bits.BaseHi << 24) +
> +	     (info.HighWord.Bits.BaseMid << 16)
> +	     + info.BaseLow;
> +      limit = (info.HighWord.Bits.LimitHi << 16) + info.LimitLow;
> +      if (info.HighWord.Bits.Granularity)
> +	limit = (limit << 12) | 0xfff;
> +      gdb_printf ("base=0x%08x limit=0x%08x", base, limit);
> +      if (info.HighWord.Bits.Default_Big)
> +	gdb_puts(" 32-bit ");
> +      else
> +	gdb_puts(" 16-bit ");
> +      switch ((info.HighWord.Bits.Type & 0xf) >> 1)
> +	{
> +	case 0:
> +	  gdb_puts ("Data (Read-Only, Exp-up");
> +	  break;
> +	case 1:
> +	  gdb_puts ("Data (Read/Write, Exp-up");
> +	  break;
> +	case 2:
> +	  gdb_puts ("Unused segment (");
> +	  break;
> +	case 3:
> +	  gdb_puts ("Data (Read/Write, Exp-down");
> +	  break;
> +	case 4:
> +	  gdb_puts ("Code (Exec-Only, N.Conf");
> +	  break;
> +	case 5:
> +	  gdb_puts ("Code (Exec/Read, N.Conf");
> +	  break;
> +	case 6:
> +	  gdb_puts ("Code (Exec-Only, Conf");
> +	  break;
> +	case 7:
> +	  gdb_puts ("Code (Exec/Read, Conf");
> +	  break;
> +	default:
> +	  gdb_printf ("Unknown type 0x%lx",
> +		      (unsigned long) info.HighWord.Bits.Type);
> +	}
> +      if ((info.HighWord.Bits.Type & 0x1) == 0)
> +	gdb_puts(", N.Acc");
> +      gdb_puts (")\n");
> +      if ((info.HighWord.Bits.Type & 0x10) == 0)
> +	gdb_puts("System selector ");
> +      gdb_printf ("Privilege level = %ld. ",
> +		  (unsigned long) info.HighWord.Bits.Dpl);
> +      if (info.HighWord.Bits.Granularity)
> +	gdb_puts ("Page granular.\n");
> +      else
> +	gdb_puts ("Byte granular.\n");
> +      return 1;
> +    }
> +  else
> +    {
> +      DWORD err = GetLastError ();
> +      if (err == ERROR_NOT_SUPPORTED)
> +	gdb_printf ("Function not supported\n");
> +      else
> +	gdb_printf ("Invalid selector 0x%x.\n", (unsigned) sel);
> +      return 0;
> +    }
> +}
> +
> +static void
> +display_selectors (const char * args, int from_tty) {
> +  if (inferior_ptid == null_ptid)
> +    {
> +      gdb_puts ("Impossible to display selectors now.\n");
> +      return;
> +    }
> +
> +  windows_thread_info *current_windows_thread
> +    = windows_process->thread_rec (inferior_ptid,
> + DONT_INVALIDATE_CONTEXT);
> +
> +  if (!args)
> +    {
> +      windows_process->with_context (current_windows_thread, [&] (auto
> *context)
> +	{
> +	  gdb_puts ("Selector $cs\n");
> +	  display_selector (current_windows_thread->h, context->SegCs);
> +	  gdb_puts ("Selector $ds\n");
> +	  display_selector (current_windows_thread->h, context->SegDs);
> +	  gdb_puts ("Selector $es\n");
> +	  display_selector (current_windows_thread->h, context->SegEs);
> +	  gdb_puts ("Selector $ss\n");
> +	  display_selector (current_windows_thread->h, context->SegSs);
> +	  gdb_puts ("Selector $fs\n");
> +	  display_selector (current_windows_thread->h, context->SegFs);
> +	  gdb_puts ("Selector $gs\n");
> +	  display_selector (current_windows_thread->h, context->SegGs);
> +	});
> +    }
> +  else
> +    {
> +      int sel;
> +      sel = parse_and_eval_long (args);
> +      gdb_printf ("Selector \"%s\"\n",args);
> +      display_selector (current_windows_thread->h, sel);
> +    }
> +}
> +
>  INIT_GDB_FILE (x86_windows_nat)
>  {
>    x86_dr_low.set_control = cygwin_set_dr7; @@ -363,4 +486,8 @@
> INIT_GDB_FILE (x86_windows_nat)
>    add_inf_child_target (new x86_windows_nat_target);
> 
>    windows_process = &x86_windows_process;
> +
> +  add_cmd ("selector", class_info, display_selectors,
> +	   _("Display selectors infos."),
> +	   &info_w32_cmdlist);
>  }
> --
> 2.52.0
> 

LGTM.

Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>

Christina

Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928

  reply	other threads:[~2026-01-19 13:57 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260117134052.2660009-1-ssbssa.ref@yahoo.de>
2026-01-17 13:36 ` [PATCH v2 01/11] Remove duplicate code from windows_nat_target::resume Hannes Domani
2026-01-17 13:36   ` [PATCH v2 02/11] Simplify windows_nat_target::resume Hannes Domani
2026-01-19 13:55     ` Schimpe, Christina
2026-01-21 15:42       ` Tom Tromey
2026-01-23 19:11       ` Hannes Domani
2026-01-17 13:36   ` [PATCH v2 03/11] Move struct declarations into windows-nat.h Hannes Domani
2026-01-17 13:36   ` [PATCH v2 04/11] Create x86-windows-nat.c Hannes Domani
2026-01-21 15:38     ` Tom Tromey
2026-01-17 13:36   ` [PATCH v2 05/11] Move x86 debug registers and related code into x86-windows-nat.c Hannes Domani
2026-01-19 12:49     ` Schimpe, Christina
2026-01-20 15:49       ` Hannes Domani
2026-01-21  8:06         ` Schimpe, Christina
2026-01-23 13:17     ` [PATCH v3] " Hannes Domani
2026-01-23 18:50       ` Tom Tromey
2026-01-23 19:20         ` Hannes Domani
2026-01-23 19:56           ` Tom Tromey
2026-01-17 13:36   ` [PATCH v2 06/11] Move x86 register " Hannes Domani
2026-01-19 12:50     ` Schimpe, Christina
2026-01-17 13:36   ` [PATCH v2 07/11] Move x86 selector " Hannes Domani
2026-01-19 13:56     ` Schimpe, Christina [this message]
2026-01-17 13:36   ` [PATCH v2 08/11] Move software breakpoint recognition " Hannes Domani
2026-01-19 12:51     ` Schimpe, Christina
2026-01-21 15:43       ` Tom Tromey
2026-01-23 19:12         ` Hannes Domani
2026-01-17 13:36   ` [PATCH v2 09/11] Move auto_wide_charset gdbarch method to windows-tdep Hannes Domani
2026-01-17 13:36   ` [PATCH v2 10/11] Move setting size of long " Hannes Domani
2026-01-21 15:47     ` Tom Tromey
2026-01-17 13:54   ` [PATCH v2 04/11] Create x86-windows-nat.c Hannes Domani
2026-01-17 14:01     ` Hannes Domani
2026-01-17 14:14       ` Hannes Domani
2026-01-17 15:04       ` Simon Marchi
2026-01-17 15:15         ` Hannes Domani
2026-01-17 13:54   ` [PATCH v2 05/11] Move x86 debug registers and related code into x86-windows-nat.c Hannes Domani
2026-01-17 13:54   ` [PATCH v2 06/11] Move x86 register " Hannes Domani
2026-01-21 16:08     ` Tom Tromey
2026-01-17 13:54   ` [PATCH v2 09/11] Move auto_wide_charset gdbarch method to windows-tdep Hannes Domani
2026-01-21 15:48     ` Tom Tromey
2026-01-23 19:13       ` Hannes Domani
2026-01-17 13:54   ` [PATCH v2 10/11] Move setting size of long " Hannes Domani
2026-01-21 15:59     ` Tom Tromey
2026-01-17 13:54   ` [PATCH v2 11/11] Add aarch64-windows support Hannes Domani
2026-01-17 16:04     ` Eli Zaretskii
2026-01-21 16:18     ` Tom Tromey
2026-01-23 19:14       ` 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=SN7PR11MB7638534D2BFCB0F4A2308466F988A@SN7PR11MB7638.namprd11.prod.outlook.com \
    --to=christina.schimpe@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    --cc=tom@tromey.com \
    /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