Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pedro Alves <palves@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH/gdbserver] Remove current_inferior's save/restore when call get_thread_regcache.
Date: Fri, 04 May 2012 13:08:00 -0000	[thread overview]
Message-ID: <4FA3D4B6.2040502@codesourcery.com> (raw)
In-Reply-To: <4FA3CC30.70401@redhat.com>

On 05/04/2012 08:31 PM, Pedro Alves wrote:
>> > -  regcache = get_thread_regcache (current_inferior, 1);
>> > +  regcache = get_thread_regcache (get_lwp_thread (lwp), 1);
>> >    pc = (*the_low_target.get_pc) (regcache);
> 
> No, the_low_target.get_pc also needs to go to the right inferior.
> 

I thought the_low_target.get_pc is to extract value of pc from regcache,
so inferior is not needed.  I examined linux-foo-low.c files again, and
find only ppc_get_pc needs the right inferior, sigh.

>> >  
>> >    return child;
>> > diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c
>> > index 5584dab..d4c17a2 100644
>> > --- a/gdb/gdbserver/proc-service.c
>> > +++ b/gdb/gdbserver/proc-service.c
>> > @@ -99,20 +99,15 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
>> >  {
>> >  #ifdef HAVE_REGSETS
>> >    struct lwp_info *lwp;
>> > -  struct thread_info *reg_inferior, *save_inferior;
>> >    struct regcache *regcache;
>> >  
>> >    lwp = find_lwp_pid (pid_to_ptid (lwpid));
>> >    if (lwp == NULL)
>> >      return PS_ERR;
>> >  
>> > -  reg_inferior = get_lwp_thread (lwp);
>> > -  save_inferior = current_inferior;
>> > -  current_inferior = reg_inferior;
>> > -  regcache = get_thread_regcache (current_inferior, 1);
>> > +  regcache = get_thread_regcache (get_lwp_thread (lwp), 1);
>> >    gregset_info ()->fill_function (regcache, gregset);
> 
> Ditto the whole gregset_info ()->fill_function line, particularly
> after my multi-process/multi-arch series, while the fill_function
> depends on inferior.
> 

So any code needs inferior should be wrapped in the follow manner?

save_inferior = current_inferior;
current_inferior = reg_inferior;
....
....
current_inferior = save_inferior;

The following question is what functions need inferior?  AFAICS, all the
methods in the_low_target and functions in `struct regset_info' need
inferior.  Anything else?

If methods in the_low_target may need inferior, all the usage of
the_low_target methods should be wrapped by the block above.  Is it
correct?  I hope I am wrong :)

-- 
Yao (齐尧)


  reply	other threads:[~2012-05-04 13:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04 10:52 Yao Qi
2012-05-04 12:32 ` Pedro Alves
2012-05-04 13:08   ` Yao Qi [this message]
2012-05-04 13:45     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FA3D4B6.2040502@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox