Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: Support target specific qSupported
@ 2010-02-03  4:03 H.J. Lu
  2010-02-03  7:04 ` Hui Zhu
  2010-02-03 13:59 ` Daniel Jacobowitz
  0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu @ 2010-02-03  4:03 UTC (permalink / raw)
  To: GDB

Hi,

Intel AVX has 256bit YMM registers. XMM registers from SSE are the
aliases of the lower 128bit YMM registers. gdbserver on AVX machine
may use 256bit vector registers, instead of 128bit vector registers,
in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
to find out the maxium common register size supported by both gdb and
gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:

gdb will send

    `x86:xstate=BYTES:xcr0=VALUE'
          This feature indicates that GDB supports x86 XSAVE extended
          state. BYTES specifies the maximum size in bytes of x86 XSAVE
          extended state GDB supports. VALUE specifies the maximum
          value of the extended control register 0 (the
          XFEATURE_ENABLED_MASK register) GDB supports.  GDB does not
          enable x86 XSAVE extended state support unless the stub also
          reports that it supports them by including
          `x86:xstate=BYTES:xcr0=VALUE' in its `qSupported' reply.
          BYTES and VALUE are encoded as ASCII string in hexadecimal or
          decimal numbers.

in qSupported query.  The remote sub will send back

    `x86:xstate=BYTES:xcr0=VALUE'
          The remote stub supports x86 XSAVE extended state with the
          extended state size in BYTES and the extended control
          register 0 (the XFEATURE_ENABLED_MASK register) of VALUE.
          BYTES and VALUE are encoded as ASCII string in hexadecimal or
          decimal numbers.

in qSupported reply.  gdb will use those values sent back by gdbserver
to determine the proper vector size.

This patch adds qsupported and qsupported_process_ack to gdbarch. My
later AVX patch will use them.

However, I couldn't find a way to store and pass those values to
gdbarch used to commnunicate with remote stub. I wound up to use static
variable in i386-tdep.c and added

	  /* Prepare qSupported ACK processing.  */
	  gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NULL);

in remote_query_supported so that I could clear the static variable
before setting it with qSupported ACK.  Any comments? Does anyone have
better ideas to accomplish what I need?

Thanks.
 

H.J.
----
2010-02-02  H.J. Lu  <hongjiu.lu@intel.com>

	* gdbarch.c (gdbarch): Add qsupported and qsupported_process_ack.
	(startup_gdbarch): Likewise.
	(gdbarch_alloc): Likewise.
	(verify_gdbarch): Likewise.
	(gdbarch_dump): Likewise.
	(gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.
	(gdbarch_qsupported_process_ack): Likewise.
	(set_gdbarch_qsupported_process_ack): Likewise.

	* gdbarch.h (gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.
	(gdbarch_qsupported_process_ack_ftype): Likewise.
	(gdbarch_qsupported_process_ack): Likewise.
	(set_gdbarch_qsupported_process_ack): Likewise.

	* remote.c (remote_state): Add gdbarch.
	(init_remote_state): Set gdbarch.
	(remote_query_supported): Support gdbarch_qsupported and
	gdbarch_qsupported_process_ack.

diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 6448fc3..4fd5d0a 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -252,6 +252,8 @@ struct gdbarch
   int has_global_breakpoints;
   gdbarch_has_shared_address_space_ftype *has_shared_address_space;
   gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
+  const char *qsupported;
+  gdbarch_qsupported_process_ack_ftype *qsupported_process_ack;
 };
 
 
@@ -395,6 +397,8 @@ struct gdbarch startup_gdbarch =
   0,  /* has_global_breakpoints */
   default_has_shared_address_space,  /* has_shared_address_space */
   default_fast_tracepoint_valid_at,  /* fast_tracepoint_valid_at */
+  0,  /* qsupported */
+  0,  /* qsupported_process_ack */
   /* startup_gdbarch() */
 };
 
@@ -481,6 +485,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->target_signal_to_host = default_target_signal_to_host;
   gdbarch->has_shared_address_space = default_has_shared_address_space;
   gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
+  gdbarch->qsupported = NULL;
+  gdbarch->qsupported_process_ack = NULL;
   /* gdbarch_alloc() */
 
   return gdbarch;
@@ -661,6 +667,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of has_global_breakpoints, invalid_p == 0 */
   /* Skip verify of has_shared_address_space, invalid_p == 0 */
   /* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
+  /* Skip verify of qsuppoted, invalid_p == 0 */
+  /* Skip verify of qsupported_process_ack, invalid_p == 0 */
   buf = ui_file_xstrdup (log, &length);
   make_cleanup (xfree, buf);
   if (length > 0)
@@ -1184,6 +1192,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: write_pc = <%s>\n",
                       host_address_to_string (gdbarch->write_pc));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: qsupported = <%s>\n",
+		      gdbarch->qsupported);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: qsupported_process_ack = <%s>\n",
+                      host_address_to_string (gdbarch->qsupported_process_ack));
   if (gdbarch->dump_tdep != NULL)
     gdbarch->dump_tdep (gdbarch, file);
 }
@@ -3576,6 +3590,41 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
   gdbarch->fast_tracepoint_valid_at = fast_tracepoint_valid_at;
 }
 
+const char *
+gdbarch_qsupported (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->qsupported != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported called\n");
+  return gdbarch->qsupported;
+}
+
+void
+set_gdbarch_qsupported (struct gdbarch *gdbarch,
+			const char *qsupported)
+{
+  gdbarch->qsupported = qsupported;
+}
+
+void
+gdbarch_qsupported_process_ack (struct gdbarch *gdbarch,
+				const char *ack, const char *value)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported_process_ack called\n");
+  if (gdbarch->qsupported_process_ack != NULL)
+    gdbarch->qsupported_process_ack (gdbarch, ack, value);
+}
+
+void
+set_gdbarch_qsupported_process_ack
+  (struct gdbarch *gdbarch,
+   gdbarch_qsupported_process_ack_ftype *qsupported_process_ack)
+{
+  gdbarch->qsupported_process_ack = qsupported_process_ack;
+}
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 661d34b..44e5244 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -923,6 +923,23 @@ typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, C
 extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
 extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
 
+/* Not NULL if a target has additonal field for qSupported.  */
+
+extern const char *gdbarch_qsupported (struct gdbarch *gdbarch);
+extern void set_gdbarch_qsupported (struct gdbarch *gdbarch,
+				    const char *qsupported);
+
+/* Not NULL if a target has additonal process for qSupported ACK.  */
+
+typedef void (gdbarch_qsupported_process_ack_ftype)
+  (struct gdbarch *gdbarch, const char *ack, const char *value);
+extern void gdbarch_qsupported_process_ack (struct gdbarch *gdbarch,
+					    const char *ack,
+					    const char *value);
+extern void set_gdbarch_qsupported_process_ack
+  (struct gdbarch *gdbarch,
+   gdbarch_qsupported_process_ack_ftype *qsupported_process_ack);
+
 /* Definition for an unknown syscall, used basically in error-cases.  */
 #define UNKNOWN_SYSCALL (-1)
 
diff --git a/gdb/remote.c b/gdb/remote.c
index bf7568c..afb8f2c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -327,6 +327,9 @@ struct remote_state
   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
      responded to that.  */
   int ctrlc_pending_p;
+
+  /* GDBARCH associated with this target.  */
+  struct gdbarch *gdbarch;
 };
 
 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
       rs->buf = xrealloc (rs->buf, rs->buf_size);
     }
 
+  /* Record our GDBARCH.  */
+  rs->gdbarch = gdbarch;
+
   return rsa;
 }
 
@@ -3475,10 +3481,27 @@ remote_query_supported (void)
   rs->buf[0] = 0;
   if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
     {
-      if (rs->extended)
-	putpkt ("qSupported:multiprocess+");
+      const char *qsupported = gdbarch_qsupported (rs->gdbarch);
+      if (qsupported)
+	{
+	  char *q;
+	  if (rs->extended)
+	    q = concat ("qSupported:multiprocess+;", qsupported, NULL);
+	  else
+	    q = concat ("qSupported:", qsupported, NULL);
+	  putpkt (q);
+	  free (q);
+
+	  /* Prepare qSupported ACK processing.  */
+	  gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NULL);
+	}
       else
-	putpkt ("qSupported");
+	{
+	  if (rs->extended)
+	    putpkt ("qSupported:multiprocess+");
+	  else
+	    putpkt ("qSupported");
+	}
 
       getpkt (&rs->buf, &rs->buf_size, 0);
 
@@ -3564,6 +3587,9 @@ remote_query_supported (void)
 	    feature->func (feature, is_supported, value);
 	    break;
 	  }
+
+      if (i >= ARRAY_SIZE (remote_protocol_features))
+	gdbarch_qsupported_process_ack (rs->gdbarch, p, value);
     }
 
   /* If we increased the packet size, make sure to increase the global


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03  4:03 RFC: Support target specific qSupported H.J. Lu
@ 2010-02-03  7:04 ` Hui Zhu
  2010-02-03 13:59 ` Daniel Jacobowitz
  1 sibling, 0 replies; 19+ messages in thread
From: Hui Zhu @ 2010-02-03  7:04 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

I think maybe we can add a new interface to target that each gdbarch
can get arch special message from inferior.

Thanks,
Hui

On Wed, Feb 3, 2010 at 12:03, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> Intel AVX has 256bit YMM registers. XMM registers from SSE are the
> aliases of the lower 128bit YMM registers. gdbserver on AVX machine
> may use 256bit vector registers, instead of 128bit vector registers,
> in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
> to find out the maxium common register size supported by both gdb and
> gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:
>
> gdb will send
>
>    `x86:xstate=BYTES:xcr0=VALUE'
>          This feature indicates that GDB supports x86 XSAVE extended
>          state. BYTES specifies the maximum size in bytes of x86 XSAVE
>          extended state GDB supports. VALUE specifies the maximum
>          value of the extended control register 0 (the
>          XFEATURE_ENABLED_MASK register) GDB supports.  GDB does not
>          enable x86 XSAVE extended state support unless the stub also
>          reports that it supports them by including
>          `x86:xstate=BYTES:xcr0=VALUE' in its `qSupported' reply.
>          BYTES and VALUE are encoded as ASCII string in hexadecimal or
>          decimal numbers.
>
> in qSupported query.  The remote sub will send back
>
>    `x86:xstate=BYTES:xcr0=VALUE'
>          The remote stub supports x86 XSAVE extended state with the
>          extended state size in BYTES and the extended control
>          register 0 (the XFEATURE_ENABLED_MASK register) of VALUE.
>          BYTES and VALUE are encoded as ASCII string in hexadecimal or
>          decimal numbers.
>
> in qSupported reply.  gdb will use those values sent back by gdbserver
> to determine the proper vector size.
>
> This patch adds qsupported and qsupported_process_ack to gdbarch. My
> later AVX patch will use them.
>
> However, I couldn't find a way to store and pass those values to
> gdbarch used to commnunicate with remote stub. I wound up to use static
> variable in i386-tdep.c and added
>
>          /* Prepare qSupported ACK processing.  */
>          gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NULL);
>
> in remote_query_supported so that I could clear the static variable
> before setting it with qSupported ACK.  Any comments? Does anyone have
> better ideas to accomplish what I need?
>
> Thanks.
>
>
> H.J.
> ----
> 2010-02-02  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * gdbarch.c (gdbarch): Add qsupported and qsupported_process_ack.
>        (startup_gdbarch): Likewise.
>        (gdbarch_alloc): Likewise.
>        (verify_gdbarch): Likewise.
>        (gdbarch_dump): Likewise.
>        (gdbarch_qsupported): New.
>        (set_gdbarch_qsupported): Likewise.
>        (gdbarch_qsupported_process_ack): Likewise.
>        (set_gdbarch_qsupported_process_ack): Likewise.
>
>        * gdbarch.h (gdbarch_qsupported): New.
>        (set_gdbarch_qsupported): Likewise.
>        (gdbarch_qsupported_process_ack_ftype): Likewise.
>        (gdbarch_qsupported_process_ack): Likewise.
>        (set_gdbarch_qsupported_process_ack): Likewise.
>
>        * remote.c (remote_state): Add gdbarch.
>        (init_remote_state): Set gdbarch.
>        (remote_query_supported): Support gdbarch_qsupported and
>        gdbarch_qsupported_process_ack.
>
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index 6448fc3..4fd5d0a 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -252,6 +252,8 @@ struct gdbarch
>   int has_global_breakpoints;
>   gdbarch_has_shared_address_space_ftype *has_shared_address_space;
>   gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
> +  const char *qsupported;
> +  gdbarch_qsupported_process_ack_ftype *qsupported_process_ack;
>  };
>
>
> @@ -395,6 +397,8 @@ struct gdbarch startup_gdbarch =
>   0,  /* has_global_breakpoints */
>   default_has_shared_address_space,  /* has_shared_address_space */
>   default_fast_tracepoint_valid_at,  /* fast_tracepoint_valid_at */
> +  0,  /* qsupported */
> +  0,  /* qsupported_process_ack */
>   /* startup_gdbarch() */
>  };
>
> @@ -481,6 +485,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
>   gdbarch->target_signal_to_host = default_target_signal_to_host;
>   gdbarch->has_shared_address_space = default_has_shared_address_space;
>   gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
> +  gdbarch->qsupported = NULL;
> +  gdbarch->qsupported_process_ack = NULL;
>   /* gdbarch_alloc() */
>
>   return gdbarch;
> @@ -661,6 +667,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
>   /* Skip verify of has_global_breakpoints, invalid_p == 0 */
>   /* Skip verify of has_shared_address_space, invalid_p == 0 */
>   /* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
> +  /* Skip verify of qsuppoted, invalid_p == 0 */
> +  /* Skip verify of qsupported_process_ack, invalid_p == 0 */
>   buf = ui_file_xstrdup (log, &length);
>   make_cleanup (xfree, buf);
>   if (length > 0)
> @@ -1184,6 +1192,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
>   fprintf_unfiltered (file,
>                       "gdbarch_dump: write_pc = <%s>\n",
>                       host_address_to_string (gdbarch->write_pc));
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: qsupported = <%s>\n",
> +                     gdbarch->qsupported);
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: qsupported_process_ack = <%s>\n",
> +                      host_address_to_string (gdbarch->qsupported_process_ack));
>   if (gdbarch->dump_tdep != NULL)
>     gdbarch->dump_tdep (gdbarch, file);
>  }
> @@ -3576,6 +3590,41 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
>   gdbarch->fast_tracepoint_valid_at = fast_tracepoint_valid_at;
>  }
>
> +const char *
> +gdbarch_qsupported (struct gdbarch *gdbarch)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  gdb_assert (gdbarch->qsupported != NULL);
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported called\n");
> +  return gdbarch->qsupported;
> +}
> +
> +void
> +set_gdbarch_qsupported (struct gdbarch *gdbarch,
> +                       const char *qsupported)
> +{
> +  gdbarch->qsupported = qsupported;
> +}
> +
> +void
> +gdbarch_qsupported_process_ack (struct gdbarch *gdbarch,
> +                               const char *ack, const char *value)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported_process_ack called\n");
> +  if (gdbarch->qsupported_process_ack != NULL)
> +    gdbarch->qsupported_process_ack (gdbarch, ack, value);
> +}
> +
> +void
> +set_gdbarch_qsupported_process_ack
> +  (struct gdbarch *gdbarch,
> +   gdbarch_qsupported_process_ack_ftype *qsupported_process_ack)
> +{
> +  gdbarch->qsupported_process_ack = qsupported_process_ack;
> +}
>
>  /* Keep a registry of per-architecture data-pointers required by GDB
>    modules. */
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index 661d34b..44e5244 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -923,6 +923,23 @@ typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, C
>  extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
>  extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
>
> +/* Not NULL if a target has additonal field for qSupported.  */
> +
> +extern const char *gdbarch_qsupported (struct gdbarch *gdbarch);
> +extern void set_gdbarch_qsupported (struct gdbarch *gdbarch,
> +                                   const char *qsupported);
> +
> +/* Not NULL if a target has additonal process for qSupported ACK.  */
> +
> +typedef void (gdbarch_qsupported_process_ack_ftype)
> +  (struct gdbarch *gdbarch, const char *ack, const char *value);
> +extern void gdbarch_qsupported_process_ack (struct gdbarch *gdbarch,
> +                                           const char *ack,
> +                                           const char *value);
> +extern void set_gdbarch_qsupported_process_ack
> +  (struct gdbarch *gdbarch,
> +   gdbarch_qsupported_process_ack_ftype *qsupported_process_ack);
> +
>  /* Definition for an unknown syscall, used basically in error-cases.  */
>  #define UNKNOWN_SYSCALL (-1)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index bf7568c..afb8f2c 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -327,6 +327,9 @@ struct remote_state
>   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
>      responded to that.  */
>   int ctrlc_pending_p;
> +
> +  /* GDBARCH associated with this target.  */
> +  struct gdbarch *gdbarch;
>  };
>
>  /* Private data that we'll store in (struct thread_info)->private.  */
> @@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
>       rs->buf = xrealloc (rs->buf, rs->buf_size);
>     }
>
> +  /* Record our GDBARCH.  */
> +  rs->gdbarch = gdbarch;
> +
>   return rsa;
>  }
>
> @@ -3475,10 +3481,27 @@ remote_query_supported (void)
>   rs->buf[0] = 0;
>   if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
>     {
> -      if (rs->extended)
> -       putpkt ("qSupported:multiprocess+");
> +      const char *qsupported = gdbarch_qsupported (rs->gdbarch);
> +      if (qsupported)
> +       {
> +         char *q;
> +         if (rs->extended)
> +           q = concat ("qSupported:multiprocess+;", qsupported, NULL);
> +         else
> +           q = concat ("qSupported:", qsupported, NULL);
> +         putpkt (q);
> +         free (q);
> +
> +         /* Prepare qSupported ACK processing.  */
> +         gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NULL);
> +       }
>       else
> -       putpkt ("qSupported");
> +       {
> +         if (rs->extended)
> +           putpkt ("qSupported:multiprocess+");
> +         else
> +           putpkt ("qSupported");
> +       }
>
>       getpkt (&rs->buf, &rs->buf_size, 0);
>
> @@ -3564,6 +3587,9 @@ remote_query_supported (void)
>            feature->func (feature, is_supported, value);
>            break;
>          }
> +
> +      if (i >= ARRAY_SIZE (remote_protocol_features))
> +       gdbarch_qsupported_process_ack (rs->gdbarch, p, value);
>     }
>
>   /* If we increased the packet size, make sure to increase the global
>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03  4:03 RFC: Support target specific qSupported H.J. Lu
  2010-02-03  7:04 ` Hui Zhu
@ 2010-02-03 13:59 ` Daniel Jacobowitz
  2010-02-03 14:05   ` H.J. Lu
  1 sibling, 1 reply; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 13:59 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Tue, Feb 02, 2010 at 08:03:39PM -0800, H.J. Lu wrote:
> Hi,
> 
> Intel AVX has 256bit YMM registers. XMM registers from SSE are the
> aliases of the lower 128bit YMM registers. gdbserver on AVX machine
> may use 256bit vector registers, instead of 128bit vector registers,
> in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
> to find out the maxium common register size supported by both gdb and
> gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:

Have you seen the Target Descriptions chapter in the manual?  This is
exactly what it was designed to do.

You'll need a new gdb to talk to the new gdbserver (older ones will
give a warning on connect), but that's generally acceptable.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 13:59 ` Daniel Jacobowitz
@ 2010-02-03 14:05   ` H.J. Lu
  2010-02-03 14:15     ` Tristan Gingold
  2010-02-03 14:22     ` Daniel Jacobowitz
  0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 14:05 UTC (permalink / raw)
  To: H.J. Lu, GDB

On Wed, Feb 3, 2010 at 5:58 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Tue, Feb 02, 2010 at 08:03:39PM -0800, H.J. Lu wrote:
>> Hi,
>>
>> Intel AVX has 256bit YMM registers. XMM registers from SSE are the
>> aliases of the lower 128bit YMM registers. gdbserver on AVX machine
>> may use 256bit vector registers, instead of 128bit vector registers,
>> in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
>> to find out the maxium common register size supported by both gdb and
>> gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:
>
> Have you seen the Target Descriptions chapter in the manual?  This is
> exactly what it was designed to do.
>

Which gdb target does similar things I need for AVX?

Thanks.

-- 
H.J.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:05   ` H.J. Lu
@ 2010-02-03 14:15     ` Tristan Gingold
  2010-02-03 14:26       ` H.J. Lu
  2010-02-03 14:22     ` Daniel Jacobowitz
  1 sibling, 1 reply; 19+ messages in thread
From: Tristan Gingold @ 2010-02-03 14:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB


On Feb 3, 2010, at 3:05 PM, H.J. Lu wrote:

> On Wed, Feb 3, 2010 at 5:58 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>> On Tue, Feb 02, 2010 at 08:03:39PM -0800, H.J. Lu wrote:
>>> Hi,
>>> 
>>> Intel AVX has 256bit YMM registers. XMM registers from SSE are the
>>> aliases of the lower 128bit YMM registers. gdbserver on AVX machine
>>> may use 256bit vector registers, instead of 128bit vector registers,
>>> in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
>>> to find out the maxium common register size supported by both gdb and
>>> gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:
>> 
>> Have you seen the Target Descriptions chapter in the manual?  This is
>> exactly what it was designed to do.
>> 
> 
> Which gdb target does similar things I need for AVX?

I think that powerpc does.  Its general purpose registers may be 32 bits wide (standard powerpc) or
64 bits (either powerpc64 or spe variants).

Tristan.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:05   ` H.J. Lu
  2010-02-03 14:15     ` Tristan Gingold
@ 2010-02-03 14:22     ` Daniel Jacobowitz
  2010-02-03 14:34       ` H.J. Lu
  1 sibling, 1 reply; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 14:22 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Wed, Feb 03, 2010 at 06:05:39AM -0800, H.J. Lu wrote:
> Which gdb target does similar things I need for AVX?

See the Standard Target Features chapter, which has examples for ARM,
MIPS, M68K, and PowerPC.  ARM NEON support is the example I'm most
familiar with and it has several similar issues; there can be 16 or 32
D registers, for instance.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:15     ` Tristan Gingold
@ 2010-02-03 14:26       ` H.J. Lu
  0 siblings, 0 replies; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 14:26 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: GDB

On Wed, Feb 3, 2010 at 6:14 AM, Tristan Gingold <gingold@adacore.com> wrote:
>
> On Feb 3, 2010, at 3:05 PM, H.J. Lu wrote:
>
>> On Wed, Feb 3, 2010 at 5:58 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>>> On Tue, Feb 02, 2010 at 08:03:39PM -0800, H.J. Lu wrote:
>>>> Hi,
>>>>
>>>> Intel AVX has 256bit YMM registers. XMM registers from SSE are the
>>>> aliases of the lower 128bit YMM registers. gdbserver on AVX machine
>>>> may use 256bit vector registers, instead of 128bit vector registers,
>>>> in the g/G packet.  When gdb talks to gdbserver, they need to negotiate
>>>> to find out the maxium common register size supported by both gdb and
>>>> gdbserver. I added `x86:xstate=BYTES:xcr0=VALUE' to qSupported:
>>>
>>> Have you seen the Target Descriptions chapter in the manual?  This is
>>> exactly what it was designed to do.
>>>
>>
>> Which gdb target does similar things I need for AVX?
>
> I think that powerpc does.  Its general purpose registers may be 32 bits wide (standard powerpc) or
> 64 bits (either powerpc64 or spe variants).
>

That is a little different since they have 2 ISAs, 32bit and 64bit. On x86,
both 32bit and 64bit ISAs may have either 128bit SSE or 256bit AVX.
Registers like mxcsr, MMX and SSE may not be available for all 32bit
processors. rs6000 uses

./features/rs6000
./regformats/rs6000

Maybe I should do something similar for x86.

Thanks.


-- 
H.J.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:22     ` Daniel Jacobowitz
@ 2010-02-03 14:34       ` H.J. Lu
  2010-02-03 14:46         ` Daniel Jacobowitz
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 14:34 UTC (permalink / raw)
  To: H.J. Lu, GDB

On Wed, Feb 3, 2010 at 6:22 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Wed, Feb 03, 2010 at 06:05:39AM -0800, H.J. Lu wrote:
>> Which gdb target does similar things I need for AVX?
>
> See the Standard Target Features chapter, which has examples for ARM,
> MIPS, M68K, and PowerPC.  ARM NEON support is the example I'm most
> familiar with and it has several similar issues; there can be 16 or 32
> D registers, for instance.
>

We have our own remote gdb stub, which needs to talk to both old gdb,
which only understands SSE g/G packet, and new gdb, which understands
AVX g/G packet. Does the target description support negotiation so
that old gdb and new remote gdb stub can use SSE g/G packet?

Thanks.

-- 
H.J.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:34       ` H.J. Lu
@ 2010-02-03 14:46         ` Daniel Jacobowitz
  2010-02-03 15:08           ` H.J. Lu
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 14:46 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Wed, Feb 03, 2010 at 06:34:14AM -0800, H.J. Lu wrote:
> We have our own remote gdb stub, which needs to talk to both old gdb,
> which only understands SSE g/G packet, and new gdb, which understands
> AVX g/G packet. Does the target description support negotiation so
> that old gdb and new remote gdb stub can use SSE g/G packet?

The goal of target descriptions is to not need negotiation.
Everything is controlled by the target.  But with older GDBs, because
x86 did not get target-described register support right away, there's
a problem.

I suggest adding something to the GDB-side qSupported packet saying
that AVX is OK.  You don't need anything on the stub side of the
qSupported reply; you just need to reply to qXfer:features.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 14:46         ` Daniel Jacobowitz
@ 2010-02-03 15:08           ` H.J. Lu
  2010-02-03 15:31             ` Daniel Jacobowitz
                               ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 15:08 UTC (permalink / raw)
  To: H.J. Lu, GDB

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

On Wed, Feb 3, 2010 at 6:46 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Wed, Feb 03, 2010 at 06:34:14AM -0800, H.J. Lu wrote:
>> We have our own remote gdb stub, which needs to talk to both old gdb,
>> which only understands SSE g/G packet, and new gdb, which understands
>> AVX g/G packet. Does the target description support negotiation so
>> that old gdb and new remote gdb stub can use SSE g/G packet?
>
> The goal of target descriptions is to not need negotiation.
> Everything is controlled by the target.  But with older GDBs, because
> x86 did not get target-described register support right away, there's
> a problem.

It is not a trivial to implement target-described register support
for x86. But I think it is a good thing to do.

> I suggest adding something to the GDB-side qSupported packet saying
> that AVX is OK.  You don't need anything on the stub side of the
> qSupported reply; you just need to reply to qXfer:features.
>

How about this patch? It allows a target to add a field to qSupported.

Thanks.

-- 
H.J.
---
2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>

	* gdbarch.c (gdbarch): Add qsupported.
	(startup_gdbarch): Likewise.
	(gdbarch_alloc): Likewise.
	(verify_gdbarch): Likewise.
	(gdbarch_dump): Likewise.
	(gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.

	* gdbarch.h (gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.

	* remote.c (remote_state): Add gdbarch.
	(init_remote_state): Set gdbarch.
	(remote_query_supported): Support gdbarch_qsupported.

[-- Attachment #2: gdb-qsupported-2.patch --]
[-- Type: text/plain, Size: 5086 bytes --]

2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>

	* gdbarch.c (gdbarch): Add qsupported.
	(startup_gdbarch): Likewise.
	(gdbarch_alloc): Likewise.
	(verify_gdbarch): Likewise.
	(gdbarch_dump): Likewise.
	(gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.

	* gdbarch.h (gdbarch_qsupported): New.
	(set_gdbarch_qsupported): Likewise.

	* remote.c (remote_state): Add gdbarch.
	(init_remote_state): Set gdbarch.
	(remote_query_supported): Support gdbarch_qsupported.

diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 6448fc3..f54a181 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -252,6 +252,7 @@ struct gdbarch
   int has_global_breakpoints;
   gdbarch_has_shared_address_space_ftype *has_shared_address_space;
   gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
+  const char *qsupported;
 };
 
 
@@ -395,6 +396,7 @@ struct gdbarch startup_gdbarch =
   0,  /* has_global_breakpoints */
   default_has_shared_address_space,  /* has_shared_address_space */
   default_fast_tracepoint_valid_at,  /* fast_tracepoint_valid_at */
+  0,  /* qsupported */
   /* startup_gdbarch() */
 };
 
@@ -481,6 +483,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->target_signal_to_host = default_target_signal_to_host;
   gdbarch->has_shared_address_space = default_has_shared_address_space;
   gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
+  gdbarch->qsupported = NULL;
   /* gdbarch_alloc() */
 
   return gdbarch;
@@ -661,6 +664,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of has_global_breakpoints, invalid_p == 0 */
   /* Skip verify of has_shared_address_space, invalid_p == 0 */
   /* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
+  /* Skip verify of qsuppoted, invalid_p == 0 */
   buf = ui_file_xstrdup (log, &length);
   make_cleanup (xfree, buf);
   if (length > 0)
@@ -1184,6 +1188,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: write_pc = <%s>\n",
                       host_address_to_string (gdbarch->write_pc));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: qsupported = <%s>\n",
+		      gdbarch->qsupported);
   if (gdbarch->dump_tdep != NULL)
     gdbarch->dump_tdep (gdbarch, file);
 }
@@ -3576,6 +3583,22 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
   gdbarch->fast_tracepoint_valid_at = fast_tracepoint_valid_at;
 }
 
+const char *
+gdbarch_qsupported (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->qsupported != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported called\n");
+  return gdbarch->qsupported;
+}
+
+void
+set_gdbarch_qsupported (struct gdbarch *gdbarch,
+			const char *qsupported)
+{
+  gdbarch->qsupported = qsupported;
+}
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 661d34b..e77f027 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -923,6 +923,12 @@ typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, C
 extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
 extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
 
+/* Not NULL if a target has additonal field for qSupported.  */
+
+extern const char *gdbarch_qsupported (struct gdbarch *gdbarch);
+extern void set_gdbarch_qsupported (struct gdbarch *gdbarch,
+				    const char *qsupported);
+
 /* Definition for an unknown syscall, used basically in error-cases.  */
 #define UNKNOWN_SYSCALL (-1)
 
diff --git a/gdb/remote.c b/gdb/remote.c
index bf7568c..e091d4b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -327,6 +327,9 @@ struct remote_state
   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
      responded to that.  */
   int ctrlc_pending_p;
+
+  /* GDBARCH associated with this target.  */
+  struct gdbarch *gdbarch;
 };
 
 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
       rs->buf = xrealloc (rs->buf, rs->buf_size);
     }
 
+  /* Record our GDBARCH.  */
+  rs->gdbarch = gdbarch;
+
   return rsa;
 }
 
@@ -3475,10 +3481,24 @@ remote_query_supported (void)
   rs->buf[0] = 0;
   if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
     {
-      if (rs->extended)
-	putpkt ("qSupported:multiprocess+");
+      const char *qsupported = gdbarch_qsupported (rs->gdbarch);
+      if (qsupported)
+	{
+	  char *q;
+	  if (rs->extended)
+	    q = concat ("qSupported:multiprocess+;", qsupported, NULL);
+	  else
+	    q = concat ("qSupported:", qsupported, NULL);
+	  putpkt (q);
+	  free (q);
+	}
       else
-	putpkt ("qSupported");
+	{
+	  if (rs->extended)
+	    putpkt ("qSupported:multiprocess+");
+	  else
+	    putpkt ("qSupported");
+	}
 
       getpkt (&rs->buf, &rs->buf_size, 0);
 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 15:08           ` H.J. Lu
@ 2010-02-03 15:31             ` Daniel Jacobowitz
       [not found]             ` <20100203152350.GA1580@caradoc.them.org>
  2010-02-03 18:59             ` H.J. Lu
  2 siblings, 0 replies; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 15:31 UTC (permalink / raw)
  To: gdb-patches

[resent for the archives, I hit the spam filter - possibly by talking
about "free" stuff?]

On Wed, Feb 03, 2010 at 07:08:26AM -0800, H.J. Lu wrote:
> How about this patch? It allows a target to add a field to qSupported.

There are big comments at the top of gdbarch.c and gdbarch.h that
point at gdbarch.sh.  They are generated files.  Also, please
call xfree instead of free.  Otherwise, it looks fine, though.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
       [not found]             ` <20100203152350.GA1580@caradoc.them.org>
@ 2010-02-03 16:44               ` H.J. Lu
  2010-02-03 17:57                 ` Daniel Jacobowitz
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 16:44 UTC (permalink / raw)
  To: H.J. Lu, GDB

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

On Wed, Feb 3, 2010 at 7:23 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Wed, Feb 03, 2010 at 07:08:26AM -0800, H.J. Lu wrote:
>> How about this patch? It allows a target to add a field to qSupported.
>
> There are big comments at the top of gdbarch.c and gdbarch.h that
> point at gdbarch.sh.  They are generated files.  Also, please
> call XXXX instead of XXX.  Otherwise, it looks fine, though.
>

This is the patch I checked in.

Thanks.

-- 
H.J.

[-- Attachment #2: gdb-qsupported-3.patch --]
[-- Type: text/plain, Size: 5156 bytes --]

2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>

	* gdbarch.sh: Add qsupported.

	* gdbarch.c: Regenerated.
	* gdbarch.h: Likewise.

	* remote.c (remote_state): Add gdbarch.
	(init_remote_state): Set gdbarch.
	(remote_query_supported): Support gdbarch_qsupported.

diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 6448fc3..cfb042b 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -252,6 +252,7 @@ struct gdbarch
   int has_global_breakpoints;
   gdbarch_has_shared_address_space_ftype *has_shared_address_space;
   gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
+  const char * qsupported;
 };
 
 
@@ -395,6 +396,7 @@ struct gdbarch startup_gdbarch =
   0,  /* has_global_breakpoints */
   default_has_shared_address_space,  /* has_shared_address_space */
   default_fast_tracepoint_valid_at,  /* fast_tracepoint_valid_at */
+  0,  /* qsupported */
   /* startup_gdbarch() */
 };
 
@@ -661,6 +663,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of has_global_breakpoints, invalid_p == 0 */
   /* Skip verify of has_shared_address_space, invalid_p == 0 */
   /* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
+  /* Skip verify of qsupported, invalid_p == 0 */
   buf = ui_file_xstrdup (log, &length);
   make_cleanup (xfree, buf);
   if (length > 0)
@@ -1035,6 +1038,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                       "gdbarch_dump: push_dummy_code = <%s>\n",
                       host_address_to_string (gdbarch->push_dummy_code));
   fprintf_unfiltered (file,
+                      "gdbarch_dump: qsupported = %s\n",
+                      gdbarch->qsupported);
+  fprintf_unfiltered (file,
                       "gdbarch_dump: gdbarch_read_pc_p() = %d\n",
                       gdbarch_read_pc_p (gdbarch));
   fprintf_unfiltered (file,
@@ -3576,6 +3582,23 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
   gdbarch->fast_tracepoint_valid_at = fast_tracepoint_valid_at;
 }
 
+const char *
+gdbarch_qsupported (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of qsupported, invalid_p == 0 */
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported called\n");
+  return gdbarch->qsupported;
+}
+
+void
+set_gdbarch_qsupported (struct gdbarch *gdbarch,
+                        const char * qsupported)
+{
+  gdbarch->qsupported = qsupported;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 661d34b..1353ab1 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -923,6 +923,11 @@ typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, C
 extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
 extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
 
+/* Not NULL if a target has additonal field for qSupported. */
+
+extern const char * gdbarch_qsupported (struct gdbarch *gdbarch);
+extern void set_gdbarch_qsupported (struct gdbarch *gdbarch, const char * qsupported);
+
 /* Definition for an unknown syscall, used basically in error-cases.  */
 #define UNKNOWN_SYSCALL (-1)
 
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index e1d3ff5..0eaa0ef 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -766,6 +766,9 @@ m:int:has_shared_address_space:void:::default_has_shared_address_space::0
 
 # True if a fast tracepoint can be set at an address.
 m:int:fast_tracepoint_valid_at:CORE_ADDR addr, int *isize, char **msg:addr, isize, msg::default_fast_tracepoint_valid_at::0
+
+# Not NULL if a target has additonal field for qSupported.
+v:const char *:qsupported:::0:0::0:gdbarch->qsupported
 EOF
 }
 
diff --git a/gdb/remote.c b/gdb/remote.c
index bf7568c..2c3dfdb 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -327,6 +327,9 @@ struct remote_state
   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
      responded to that.  */
   int ctrlc_pending_p;
+
+  /* GDBARCH associated with this target.  */
+  struct gdbarch *gdbarch;
 };
 
 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
       rs->buf = xrealloc (rs->buf, rs->buf_size);
     }
 
+  /* Record our GDBARCH.  */
+  rs->gdbarch = gdbarch;
+
   return rsa;
 }
 
@@ -3475,10 +3481,24 @@ remote_query_supported (void)
   rs->buf[0] = 0;
   if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
     {
-      if (rs->extended)
-	putpkt ("qSupported:multiprocess+");
+      const char *qsupported = gdbarch_qsupported (rs->gdbarch);
+      if (qsupported)
+	{
+	  char *q;
+	  if (rs->extended)
+	    q = concat ("qSupported:multiprocess+;", qsupported, NULL);
+	  else
+	    q = concat ("qSupported:", qsupported, NULL);
+	  putpkt (q);
+	  xfree (q);
+	}
       else
-	putpkt ("qSupported");
+	{
+	  if (rs->extended)
+	    putpkt ("qSupported:multiprocess+");
+	  else
+	    putpkt ("qSupported");
+	}
 
       getpkt (&rs->buf, &rs->buf_size, 0);
 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 16:44               ` H.J. Lu
@ 2010-02-03 17:57                 ` Daniel Jacobowitz
  2010-02-03 18:31                   ` H.J. Lu
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 17:57 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Wed, Feb 03, 2010 at 08:44:03AM -0800, H.J. Lu wrote:
> @@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
>        rs->buf = xrealloc (rs->buf, rs->buf_size);
>      }
>  
> +  /* Record our GDBARCH.  */
> +  rs->gdbarch = gdbarch;
> +
>    return rsa;
>  }
>  

Sorry, I didn't notice this before.  Is target_gdbarch available at
this point?  That's the one I'd expect.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 17:57                 ` Daniel Jacobowitz
@ 2010-02-03 18:31                   ` H.J. Lu
  0 siblings, 0 replies; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 18:31 UTC (permalink / raw)
  To: H.J. Lu, GDB

On Wed, Feb 3, 2010 at 9:56 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Wed, Feb 03, 2010 at 08:44:03AM -0800, H.J. Lu wrote:
>> @@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch)
>>        rs->buf = xrealloc (rs->buf, rs->buf_size);
>>      }
>>
>> +  /* Record our GDBARCH.  */
>> +  rs->gdbarch = gdbarch;
>> +
>>    return rsa;
>>  }
>>
>
> Sorry, I didn't notice this before.  Is target_gdbarch available at
> this point?  That's the one I'd expect.
>

Yes, I can use target_gdbarch. I checked in this patch to remove gdbarch
from remote_state.

Thanks.


-- 
H.J.
--diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af536a7..ade4aa0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>

+	* remote.c (remote_state): Remove gdbarch.
+	(init_remote_state): Don't set gdbarch.
+	(remote_query_supported): Pass target_gdbarch instead of
+	rs->gdbarch to gdbarch_qsupported.
+
+2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* gdbarch.sh: Add qsupported.

 	* gdbarch.c: Regenerated.
diff --git a/gdb/remote.c b/gdb/remote.c
index 2c3dfdb..709e424 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -327,9 +327,6 @@ struct remote_state
   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
      responded to that.  */
   int ctrlc_pending_p;
-
-  /* GDBARCH associated with this target.  */
-  struct gdbarch *gdbarch;
 };

 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -569,9 +566,6 @@ init_remote_state (struct gdbarch *gdbarch)
       rs->buf = xrealloc (rs->buf, rs->buf_size);
     }

-  /* Record our GDBARCH.  */
-  rs->gdbarch = gdbarch;
-
   return rsa;
 }

@@ -3481,7 +3475,7 @@ remote_query_supported (void)
   rs->buf[0] = 0;
   if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
     {
-      const char *qsupported = gdbarch_qsupported (rs->gdbarch);
+      const char *qsupported = gdbarch_qsupported (target_gdbarch);
       if (qsupported)
 	{
 	  char *q;


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 15:08           ` H.J. Lu
  2010-02-03 15:31             ` Daniel Jacobowitz
       [not found]             ` <20100203152350.GA1580@caradoc.them.org>
@ 2010-02-03 18:59             ` H.J. Lu
  2010-02-03 19:03               ` Daniel Jacobowitz
  2 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 18:59 UTC (permalink / raw)
  To: H.J. Lu, GDB

On Wed, Feb 3, 2010 at 7:08 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Feb 3, 2010 at 6:46 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>> On Wed, Feb 03, 2010 at 06:34:14AM -0800, H.J. Lu wrote:
>>> We have our own remote gdb stub, which needs to talk to both old gdb,
>>> which only understands SSE g/G packet, and new gdb, which understands
>>> AVX g/G packet. Does the target description support negotiation so
>>> that old gdb and new remote gdb stub can use SSE g/G packet?
>>
>> The goal of target descriptions is to not need negotiation.
>> Everything is controlled by the target.  But with older GDBs, because
>> x86 did not get target-described register support right away, there's
>> a problem.
>
> It is not a trivial to implement target-described register support
> for x86. But I think it is a good thing to do.
>

I am working x86 target descriptions. MMX is alias of ST. How do
I do it?

Thanks.


-- 
H.J.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 18:59             ` H.J. Lu
@ 2010-02-03 19:03               ` Daniel Jacobowitz
  2010-02-03 19:06                 ` H.J. Lu
  2010-02-03 19:09                 ` Mark Kettenis
  0 siblings, 2 replies; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 19:03 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Wed, Feb 03, 2010 at 10:59:14AM -0800, H.J. Lu wrote:
> I am working x86 target descriptions. MMX is alias of ST. How do
> I do it?

You have many options.  One is to never describe the MMX registers
explicitly.  Make them pseudo-registers.  This is how ARM NEON
single-precision registers work.

Aren't they pseudos already?  You may not have to do anything
special.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 19:03               ` Daniel Jacobowitz
@ 2010-02-03 19:06                 ` H.J. Lu
  2010-02-03 19:17                   ` Daniel Jacobowitz
  2010-02-03 19:09                 ` Mark Kettenis
  1 sibling, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2010-02-03 19:06 UTC (permalink / raw)
  To: H.J. Lu, GDB

On Wed, Feb 3, 2010 at 11:03 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Wed, Feb 03, 2010 at 10:59:14AM -0800, H.J. Lu wrote:
>> I am working x86 target descriptions. MMX is alias of ST. How do
>> I do it?
>
> You have many options.  One is to never describe the MMX registers
> explicitly.  Make them pseudo-registers.  This is how ARM NEON
> single-precision registers work.

I will give it a try.

> Aren't they pseudos already?  You may not have to do anything
> special.
>

x86 has ah, al, ax, eax, rax and will have xmm and ymm.  Is there a way to
support them, like

(gdb) p $ax
(gdb) p $ah

Thanks.



-- 
H.J.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 19:03               ` Daniel Jacobowitz
  2010-02-03 19:06                 ` H.J. Lu
@ 2010-02-03 19:09                 ` Mark Kettenis
  1 sibling, 0 replies; 19+ messages in thread
From: Mark Kettenis @ 2010-02-03 19:09 UTC (permalink / raw)
  To: dan; +Cc: hjl.tools, gdb-patches

> Date: Wed, 3 Feb 2010 14:03:36 -0500
> From: Daniel Jacobowitz <dan@codesourcery.com>
> 
> On Wed, Feb 03, 2010 at 10:59:14AM -0800, H.J. Lu wrote:
> > I am working x86 target descriptions. MMX is alias of ST. How do
> > I do it?
> 
> You have many options.  One is to never describe the MMX registers
> explicitly.  Make them pseudo-registers.  This is how ARM NEON
> single-precision registers work.
> 
> Aren't they pseudos already?  You may not have to do anything
> special.

They are.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: RFC: Support target specific qSupported
  2010-02-03 19:06                 ` H.J. Lu
@ 2010-02-03 19:17                   ` Daniel Jacobowitz
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Jacobowitz @ 2010-02-03 19:17 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On Wed, Feb 03, 2010 at 11:06:49AM -0800, H.J. Lu wrote:
> x86 has ah, al, ax, eax, rax and will have xmm and ymm.  Is there a way to
> support them, like
> 
> (gdb) p $ax
> (gdb) p $ah

Those can be pseudos just like the MMX registers.  If you want to add
them, please do it separately, but it should be easy.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-02-03 19:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-03  4:03 RFC: Support target specific qSupported H.J. Lu
2010-02-03  7:04 ` Hui Zhu
2010-02-03 13:59 ` Daniel Jacobowitz
2010-02-03 14:05   ` H.J. Lu
2010-02-03 14:15     ` Tristan Gingold
2010-02-03 14:26       ` H.J. Lu
2010-02-03 14:22     ` Daniel Jacobowitz
2010-02-03 14:34       ` H.J. Lu
2010-02-03 14:46         ` Daniel Jacobowitz
2010-02-03 15:08           ` H.J. Lu
2010-02-03 15:31             ` Daniel Jacobowitz
     [not found]             ` <20100203152350.GA1580@caradoc.them.org>
2010-02-03 16:44               ` H.J. Lu
2010-02-03 17:57                 ` Daniel Jacobowitz
2010-02-03 18:31                   ` H.J. Lu
2010-02-03 18:59             ` H.J. Lu
2010-02-03 19:03               ` Daniel Jacobowitz
2010-02-03 19:06                 ` H.J. Lu
2010-02-03 19:17                   ` Daniel Jacobowitz
2010-02-03 19:09                 ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox