This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA-v2] windows-nat.c Cygwin saved_context fix
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Christopher Faylor
> Envoyé?: Tuesday, September 22, 2009 3:32 PM
> À?: gdb-patches@sourceware.org; Pierre Muller
> Objet?: Re: [RFA-v2] windows-nat.c Cygwin saved_context fix
>
> 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 <muller@ics.u-strasbg.fr>
> >
> > * 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.
>
> Please try my previous suggestion of removing the have_saved_context =
> 0;
Christopher,
I will try to explain what happens if
you just remove the 'have_saved_context = 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=1,
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 = 0
windows_store_inferior_registers callsthread_rec with get_context=1
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
saved_context.
Finally the change of $ebp register failed.
This can be avoid with the second patch I sent,
that sets suspended to -1.
Pierre