From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18897 invoked by alias); 3 Feb 2010 07:04:49 -0000 Received: (qmail 18475 invoked by uid 22791); 3 Feb 2010 07:04:47 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SARE_SUB_OBFU_Q1,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f183.google.com (HELO mail-pz0-f183.google.com) (209.85.222.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Feb 2010 07:04:41 +0000 Received: by pzk13 with SMTP id 13so248240pzk.24 for ; Tue, 02 Feb 2010 23:04:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.143.21.5 with SMTP id y5mr688690wfi.324.1265180680094; Tue, 02 Feb 2010 23:04:40 -0800 (PST) In-Reply-To: <20100203040339.GA24984@lucon.org> References: <20100203040339.GA24984@lucon.org> From: Hui Zhu Date: Wed, 03 Feb 2010 07:04:00 -0000 Message-ID: Subject: Re: RFC: Support target specific qSupported To: "H.J. Lu" Cc: GDB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00060.txt.bz2 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 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. =A0When 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=3DBYTES:xcr0=3DVALUE' to qSupported: > > gdb will send > > =A0 =A0`x86:xstate=3DBYTES:xcr0=3DVALUE' > =A0 =A0 =A0 =A0 =A0This feature indicates that GDB supports x86 XSAVE ext= ended > =A0 =A0 =A0 =A0 =A0state. BYTES specifies the maximum size in bytes of x8= 6 XSAVE > =A0 =A0 =A0 =A0 =A0extended state GDB supports. VALUE specifies the maxim= um > =A0 =A0 =A0 =A0 =A0value of the extended control register 0 (the > =A0 =A0 =A0 =A0 =A0XFEATURE_ENABLED_MASK register) GDB supports. =A0GDB d= oes not > =A0 =A0 =A0 =A0 =A0enable x86 XSAVE extended state support unless the stu= b also > =A0 =A0 =A0 =A0 =A0reports that it supports them by including > =A0 =A0 =A0 =A0 =A0`x86:xstate=3DBYTES:xcr0=3DVALUE' in its `qSupported' = reply. > =A0 =A0 =A0 =A0 =A0BYTES and VALUE are encoded as ASCII string in hexadec= imal or > =A0 =A0 =A0 =A0 =A0decimal numbers. > > in qSupported query. =A0The remote sub will send back > > =A0 =A0`x86:xstate=3DBYTES:xcr0=3DVALUE' > =A0 =A0 =A0 =A0 =A0The remote stub supports x86 XSAVE extended state with= the > =A0 =A0 =A0 =A0 =A0extended state size in BYTES and the extended control > =A0 =A0 =A0 =A0 =A0register 0 (the XFEATURE_ENABLED_MASK register) of VAL= UE. > =A0 =A0 =A0 =A0 =A0BYTES and VALUE are encoded as ASCII string in hexadec= imal or > =A0 =A0 =A0 =A0 =A0decimal numbers. > > in qSupported reply. =A0gdb 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 > > =A0 =A0 =A0 =A0 =A0/* Prepare qSupported ACK processing. =A0*/ > =A0 =A0 =A0 =A0 =A0gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NUL= L); > > in remote_query_supported so that I could clear the static variable > before setting it with qSupported ACK. =A0Any comments? Does anyone have > better ideas to accomplish what I need? > > Thanks. > > > H.J. > ---- > 2010-02-02 =A0H.J. Lu =A0 > > =A0 =A0 =A0 =A0* gdbarch.c (gdbarch): Add qsupported and qsupported_proce= ss_ack. > =A0 =A0 =A0 =A0(startup_gdbarch): Likewise. > =A0 =A0 =A0 =A0(gdbarch_alloc): Likewise. > =A0 =A0 =A0 =A0(verify_gdbarch): Likewise. > =A0 =A0 =A0 =A0(gdbarch_dump): Likewise. > =A0 =A0 =A0 =A0(gdbarch_qsupported): New. > =A0 =A0 =A0 =A0(set_gdbarch_qsupported): Likewise. > =A0 =A0 =A0 =A0(gdbarch_qsupported_process_ack): Likewise. > =A0 =A0 =A0 =A0(set_gdbarch_qsupported_process_ack): Likewise. > > =A0 =A0 =A0 =A0* gdbarch.h (gdbarch_qsupported): New. > =A0 =A0 =A0 =A0(set_gdbarch_qsupported): Likewise. > =A0 =A0 =A0 =A0(gdbarch_qsupported_process_ack_ftype): Likewise. > =A0 =A0 =A0 =A0(gdbarch_qsupported_process_ack): Likewise. > =A0 =A0 =A0 =A0(set_gdbarch_qsupported_process_ack): Likewise. > > =A0 =A0 =A0 =A0* remote.c (remote_state): Add gdbarch. > =A0 =A0 =A0 =A0(init_remote_state): Set gdbarch. > =A0 =A0 =A0 =A0(remote_query_supported): Support gdbarch_qsupported and > =A0 =A0 =A0 =A0gdbarch_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 > =A0 int has_global_breakpoints; > =A0 gdbarch_has_shared_address_space_ftype *has_shared_address_space; > =A0 gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at; > + =A0const char *qsupported; > + =A0gdbarch_qsupported_process_ack_ftype *qsupported_process_ack; > =A0}; > > > @@ -395,6 +397,8 @@ struct gdbarch startup_gdbarch =3D > =A0 0, =A0/* has_global_breakpoints */ > =A0 default_has_shared_address_space, =A0/* has_shared_address_space */ > =A0 default_fast_tracepoint_valid_at, =A0/* fast_tracepoint_valid_at */ > + =A00, =A0/* qsupported */ > + =A00, =A0/* qsupported_process_ack */ > =A0 /* startup_gdbarch() */ > =A0}; > > @@ -481,6 +485,8 @@ gdbarch_alloc (const struct gdbarch_info *info, > =A0 gdbarch->target_signal_to_host =3D default_target_signal_to_host; > =A0 gdbarch->has_shared_address_space =3D default_has_shared_address_spac= e; > =A0 gdbarch->fast_tracepoint_valid_at =3D default_fast_tracepoint_valid_a= t; > + =A0gdbarch->qsupported =3D NULL; > + =A0gdbarch->qsupported_process_ack =3D NULL; > =A0 /* gdbarch_alloc() */ > > =A0 return gdbarch; > @@ -661,6 +667,8 @@ verify_gdbarch (struct gdbarch *gdbarch) > =A0 /* Skip verify of has_global_breakpoints, invalid_p =3D=3D 0 */ > =A0 /* Skip verify of has_shared_address_space, invalid_p =3D=3D 0 */ > =A0 /* Skip verify of fast_tracepoint_valid_at, invalid_p =3D=3D 0 */ > + =A0/* Skip verify of qsuppoted, invalid_p =3D=3D 0 */ > + =A0/* Skip verify of qsupported_process_ack, invalid_p =3D=3D 0 */ > =A0 buf =3D ui_file_xstrdup (log, &length); > =A0 make_cleanup (xfree, buf); > =A0 if (length > 0) > @@ -1184,6 +1192,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_f= ile *file) > =A0 fprintf_unfiltered (file, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "gdbarch_dump: write_pc =3D <= %s>\n", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 host_address_to_string (gdbar= ch->write_pc)); > + =A0fprintf_unfiltered (file, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"gdbarch_dump: qsupported = =3D <%s>\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gdbarch->qsupported); > + =A0fprintf_unfiltered (file, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"gdbarch_dump: qsupported_pr= ocess_ack =3D <%s>\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0host_address_to_string (gdba= rch->qsupported_process_ack)); > =A0 if (gdbarch->dump_tdep !=3D NULL) > =A0 =A0 gdbarch->dump_tdep (gdbarch, file); > =A0} > @@ -3576,6 +3590,41 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbar= ch *gdbarch, > =A0 gdbarch->fast_tracepoint_valid_at =3D fast_tracepoint_valid_at; > =A0} > > +const char * > +gdbarch_qsupported (struct gdbarch *gdbarch) > +{ > + =A0gdb_assert (gdbarch !=3D NULL); > + =A0gdb_assert (gdbarch->qsupported !=3D NULL); > + =A0if (gdbarch_debug >=3D 2) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported called\n"); > + =A0return gdbarch->qsupported; > +} > + > +void > +set_gdbarch_qsupported (struct gdbarch *gdbarch, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *qsupported) > +{ > + =A0gdbarch->qsupported =3D qsupported; > +} > + > +void > +gdbarch_qsupported_process_ack (struct gdbarch *gdbarch, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char = *ack, const char *value) > +{ > + =A0gdb_assert (gdbarch !=3D NULL); > + =A0if (gdbarch_debug >=3D 2) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, "gdbarch_qsupported_process_ack = called\n"); > + =A0if (gdbarch->qsupported_process_ack !=3D NULL) > + =A0 =A0gdbarch->qsupported_process_ack (gdbarch, ack, value); > +} > + > +void > +set_gdbarch_qsupported_process_ack > + =A0(struct gdbarch *gdbarch, > + =A0 gdbarch_qsupported_process_ack_ftype *qsupported_process_ack) > +{ > + =A0gdbarch->qsupported_process_ack =3D qsupported_process_ack; > +} > > =A0/* Keep a registry of per-architecture data-pointers required by GDB > =A0 =A0modules. */ > 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 > =A0extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, = CORE_ADDR addr, int *isize, char **msg); > =A0extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdba= rch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at); > > +/* Not NULL if a target has additonal field for qSupported. =A0*/ > + > +extern const char *gdbarch_qsupported (struct gdbarch *gdbarch); > +extern void set_gdbarch_qsupported (struct gdbarch *gdbarch, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 con= st char *qsupported); > + > +/* Not NULL if a target has additonal process for qSupported ACK. =A0*/ > + > +typedef void (gdbarch_qsupported_process_ack_ftype) > + =A0(struct gdbarch *gdbarch, const char *ack, const char *value); > +extern void gdbarch_qsupported_process_ack (struct gdbarch *gdbarch, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 const char *ack, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 const char *value); > +extern void set_gdbarch_qsupported_process_ack > + =A0(struct gdbarch *gdbarch, > + =A0 gdbarch_qsupported_process_ack_ftype *qsupported_process_ack); > + > =A0/* Definition for an unknown syscall, used basically in error-cases. = =A0*/ > =A0#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 > =A0 /* Nonzero if the user has pressed Ctrl-C, but the target hasn't > =A0 =A0 =A0responded to that. =A0*/ > =A0 int ctrlc_pending_p; > + > + =A0/* GDBARCH associated with this target. =A0*/ > + =A0struct gdbarch *gdbarch; > =A0}; > > =A0/* Private data that we'll store in (struct thread_info)->private. =A0= */ > @@ -566,6 +569,9 @@ init_remote_state (struct gdbarch *gdbarch) > =A0 =A0 =A0 rs->buf =3D xrealloc (rs->buf, rs->buf_size); > =A0 =A0 } > > + =A0/* Record our GDBARCH. =A0*/ > + =A0rs->gdbarch =3D gdbarch; > + > =A0 return rsa; > =A0} > > @@ -3475,10 +3481,27 @@ remote_query_supported (void) > =A0 rs->buf[0] =3D 0; > =A0 if (remote_protocol_packets[PACKET_qSupported].support !=3D PACKET_DI= SABLE) > =A0 =A0 { > - =A0 =A0 =A0if (rs->extended) > - =A0 =A0 =A0 putpkt ("qSupported:multiprocess+"); > + =A0 =A0 =A0const char *qsupported =3D gdbarch_qsupported (rs->gdbarch); > + =A0 =A0 =A0if (qsupported) > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 char *q; > + =A0 =A0 =A0 =A0 if (rs->extended) > + =A0 =A0 =A0 =A0 =A0 q =3D concat ("qSupported:multiprocess+;", qsupport= ed, NULL); > + =A0 =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 q =3D concat ("qSupported:", qsupported, NULL); > + =A0 =A0 =A0 =A0 putpkt (q); > + =A0 =A0 =A0 =A0 free (q); > + > + =A0 =A0 =A0 =A0 /* Prepare qSupported ACK processing. =A0*/ > + =A0 =A0 =A0 =A0 gdbarch_qsupported_process_ack (rs->gdbarch, NULL, NULL= ); > + =A0 =A0 =A0 } > =A0 =A0 =A0 else > - =A0 =A0 =A0 putpkt ("qSupported"); > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 if (rs->extended) > + =A0 =A0 =A0 =A0 =A0 putpkt ("qSupported:multiprocess+"); > + =A0 =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 putpkt ("qSupported"); > + =A0 =A0 =A0 } > > =A0 =A0 =A0 getpkt (&rs->buf, &rs->buf_size, 0); > > @@ -3564,6 +3587,9 @@ remote_query_supported (void) > =A0 =A0 =A0 =A0 =A0 =A0feature->func (feature, is_supported, value); > =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0} > + > + =A0 =A0 =A0if (i >=3D ARRAY_SIZE (remote_protocol_features)) > + =A0 =A0 =A0 gdbarch_qsupported_process_ack (rs->gdbarch, p, value); > =A0 =A0 } > > =A0 /* If we increased the packet size, make sure to increase the global >