From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27662 invoked by alias); 22 Sep 2009 22:35:16 -0000 Received: (qmail 27653 invoked by uid 22791); 22 Sep 2009 22:35:15 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Sep 2009 22:35:11 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.2/jtpda-5.5pre1) with ESMTP id n8MMZ9k9029840 for ; Wed, 23 Sep 2009 00:35:09 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id n8MMZ8rX025517 for ; Wed, 23 Sep 2009 00:35:08 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) Received: from d620muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id n8MMZ8wo017682 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Wed, 23 Sep 2009 00:35:08 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) From: "Pierre Muller" To: References: <001d01ca3ace$4878c9f0$d96a5dd0$@u-strasbg.fr> <20090921222637.GC17886@ednor.casa.cgf.cx> <000001ca3b0b$d8310250$889306f0$@u-strasbg.fr> <000601ca3b0f$6b694610$423bd230$@u-strasbg.fr> <20090922133158.GF28499@ednor.casa.cgf.cx> In-Reply-To: <20090922133158.GF28499@ednor.casa.cgf.cx> Subject: RE: [RFA-v2] windows-nat.c Cygwin saved_context fix Date: Tue, 22 Sep 2009 22:35:00 -0000 Message-ID: <001c01ca3bd4$f4409860$dcc1c920$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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: 2009-09/txt/msg00717.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Christopher Faylor > Envoy=E9=A0: Tuesday, September 22, 2009 3:32 PM > =C0=A0: gdb-patches@sourceware.org; Pierre Muller > Objet=A0: Re: [RFA-v2] windows-nat.c Cygwin saved_context fix >=20 > On Tue, Sep 22, 2009 at 01:01:13AM +0200, Pierre Muller wrote: > >After testing, > >setting suspended field to -1 > >seems to work equally well for me. > > > > Here is an updated patch: > > > > > >2009-09-22 Pierre Muller > > > > * windows-nat.c (saved_threadid): New variable. > > (do_windows_fetch_inferior_registers): Check for correct thread > id > > and set suspended field to -1 if it is zero. > > (handle_output_debug_string): Set saved_threadid. >=20 > Please try my previous suggestion of removing the have_saved_context =3D > 0; Christopher,=20 I will try to explain what happens if=20 you just remove the 'have_saved_context =3D 0'. The first time you call do_windows_fetch_inferior_registers the copied context does copy the saved_context to the context struct inside *current_thread. So far, so good... If there is any call to thread_rec with get_context=3D1, this will set current_thread->reload_context to 1 again, because current_thread->suspended is still 0. This means that the next call to do_windows_fetch_inferior_registers will again write saved_context to current_thread->context. This still looks good, but it will fail if we try to change any of these registers, for instance (gdb) set $ebp =3D 0 windows_store_inferior_registers callsthread_rec with get_context=3D1 which again sets current_thread->reload_context to 1. Then the current_thread->context.Ebp gets changed to 0, but set_command later calls a cascade of frame functions that end up by refetching $eip, at which point current_thread->context.Ebp gets restored to the value in=20 saved_context. =20=20 Finally the change of $ebp register failed. This can be avoid with the second patch I sent, that sets suspended to -1. Pierre