From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102879 invoked by alias); 31 Mar 2015 18:32:44 -0000 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 Received: (qmail 102864 invoked by uid 89); 31 Mar 2015 18:32:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Mar 2015 18:32:42 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id AE3CDA80A3F; Tue, 31 Mar 2015 20:32:39 +0200 (CEST) Date: Tue, 31 Mar 2015 18:32:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [patch/cygwin] Remove dependency on __COPY_CONTEXT_SIZE Message-ID: <20150331183239.GA14520@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <20150330100454.GA8372@calimero.vinschen.de> <551A9443.5010907@redhat.com> <20150331143643.GA10846@calimero.vinschen.de> <551AB630.4010800@redhat.com> <20150331154215.GL13285@calimero.vinschen.de> <551ACB9E.2080902@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <551ACB9E.2080902@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01065.txt.bz2 --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3532 On Mar 31 17:30, Pedro Alves wrote: > On 03/31/2015 04:42 PM, Corinna Vinschen wrote: > > On Mar 31 15:58, Pedro Alves wrote: > >> On 03/31/2015 03:36 PM, Corinna Vinschen wrote: > >>> On Mar 31 13:34, Pedro Alves wrote: > >>>> On 03/30/2015 11:04 AM, Corinna Vinschen wrote: > >>>> > >>>>> @@ -820,7 +819,7 @@ handle_output_debug_string (struct target_waits= tatus *ourstatus) > >>>>> #endif > >>>>> warning (("%s"), s); > >>>>> } > >>>>> -#ifdef __COPY_CONTEXT_SIZE > >>>>> +#ifdef __CYGWIN__ > >>>>> else > >>>>> { > >>>>> /* Got a cygwin signal marker. A cygwin signal is followed = by > >>>>> @@ -847,8 +846,8 @@ handle_output_debug_string (struct target_waits= tatus *ourstatus) > >>>>> else if ((x =3D (LPCVOID) (uintptr_t) strtoull (p, NULL, 0)) > >>>>> && ReadProcessMemory (current_process_handle, x, > >>>>> &saved_context, > >>>>> - __COPY_CONTEXT_SIZE, &n) > >>>>> - && n =3D=3D __COPY_CONTEXT_SIZE) > >>>>> + sizeof (CONTEXT), &n) > >>>> > >>>> Is that really wise? AFAIK, the size of the CONTEXT structure can > >>>> grow as MSFT adds more registers to support newer machines. > >>> > >>> No, that's not possible. The CONTEXT structure matches the platform. > >>> It doesn't even contain a version number. Consider that the structure > >>> is available in user space. If Microsoft changes the size on a given > >>> platform, applications built for this platform might crash due to > >>> overwritten memory. They wouldn't do that. > >> > >> That's not true. GetThreadContext takes a size parameter, > >> and only writes to the bits that the caller requests with > >> context.ContextFlags. > >=20 > > The ContextFlags member is not a size parameter, >=20 > I didn't say it was. The GetThreadContext function takes > an IN+OUT size parameter in _addition to the ContextFlags flag. Uhm...no, it doesn't. The prototype is BOOL WINAPI GetThreadContext( _In_ HANDLE hThread, _Inout_ LPCONTEXT lpContext ); Only the ContextFlags member qualifies what's written to *lpContext. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms679362%28v=3Dvs.= 85%29.aspx > > Right, but this does not change the size of the CONTEXT datatype. The > > additional AVX values require more space than available in the CONTEXT > > struct. That's why using CONTEXT_XSTATE and the AVX functions require > > to use InitializeContext; the size required to get these values is > > larger than CONTEXT, thus the function returns ERROR_INSUFFICIENT_BUFFER > > if ContextLength is =3D=3D sizeof (CONTEXT) only. >=20 > I'm almost sure in the old days, the CONTEXT structure didn't have > the ExtendedRegisters field at all. I don't know about that. But the fact that CONTEXT is not a opaque structure but exposed to user space speaks against that. Every time a Win32 datatype needs a change, MSFT kept the old datatype intact and added an "Ex" or "2" type instead, just as with the functions. > I think it's bad to hard code > the size of the CONTEXT structure, but won't argue further. Patch > is OK if you'd really like to apply it as is. Thanks. But incidentally I retract the patch. It seems we made a mistake both, on 32 and 64 bit Cygwin as far as the definition of __COPY_CONTEXT_SIZE is concerned. Changing that to sizeof(CONTEXT) now would potentially break backward compatibility with all Cygwin versions up to today. Oh well. Sorry for the longish discussion for nothing :( Corinna --=20 Corinna Vinschen Cygwin Maintainer Red Hat --rwEMma7ioTxnRzrJ Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVGuhHAAoJEPU2Bp2uRE+gxFIP/AnGOho8THtZ7+xahOcFNrmK b1Rq6PGOUOw2ruN6dZFV8N3/uwCQcl4h/g/YCt2Ed5gJ8MFA62jATdgqFh+1eoGR dP5Mg56U1J/7n2RJpJJeZBJeOZfefb6GCQHnMaipgy0Qq8ewnHlXGU0secB2rVou oslQWn1bQwym8ZetU2nU37AvFbKZo+zyTxAV4p9QDcZEXwzHAuIpyqTFlP1M0X15 Pso7iYb6dXyXyaKBHHYA2oWDsMcWkGm0V1ASeR0lIAEuKImQ/2LgxtPi4Gla6GiU N4G7UOQFaVKX8G5F4DF3ZbOpbXQIChBGyI0MovYuYEG/MgN6vZBGEuWHazTuDzre captgvfZq10EAH/Ta547FOdyQ/ry+3HnFz0ZWbqBQp/UuKSfQ4f3NB2N3q84a9am 7coCMYpDV3NfbRH//Ssdu7P+QF7+p6SG8gpusY2iDERhYLN7g7ihPHWvYO6wwxR3 POiPsXSGQTJQcCN9PSD9uEW4Or/PkVTz4jWiRB6CVQ4JWqI3MlCekaRoqnMLQ1a7 m21ZW/u2X+nsSdqz6CcPZpm2ZLzj2V7QsHJ6opxyIAAoBRiHY7mumdDj4gJGal0m sWKZgyWu8VIurObzNgy7Kwy3k+ab4rT62Kl1nVv2XXVs8nhCgmzvRL4gtCwEV1Nm 3XIbi9CEYx7NQIoZjK/o =EFep -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ--