Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Gary Benson <gbenson@redhat.com>, Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tromey@redhat.com>
Subject: Re: [PATCH 05/11 v5] Add target/target.h
Date: Wed, 20 Aug 2014 14:49:00 -0000	[thread overview]
Message-ID: <53F4B55B.3020207@redhat.com> (raw)
In-Reply-To: <20140807134840.GC19737@blade.nx>

On 08/07/2014 02:48 PM, Gary Benson wrote:
> Doug Evans wrote:
>> Gary Benson writes:
>>> @@ -284,37 +253,18 @@ agent_run_command (int pid, const char *cmd,
>>>        int was_non_stop = non_stop;
>>>        /* Stop thread PTID.  */
>>>        DEBUG_AGENT ("agent: stop helper thread\n");
>>> -#ifdef GDBSERVER
>>> -      {
>>> -        struct thread_resume resume_info;
>>> -
>>> -        resume_info.thread = ptid;
>>> -        resume_info.kind = resume_stop;
>>> -        resume_info.sig = GDB_SIGNAL_0;
>>> -        (*the_target->resume) (&resume_info, 1);
>>> -      }
>>> -
>>> -      non_stop = 1;
>>> -      mywait (ptid, &status, 0, 0);
>>> -#else
>>>        non_stop = 1;
>>>        target_stop (ptid);
>>>  
>>>        memset (&status, 0, sizeof (status));
>>>        target_wait (ptid, &status, 0);
>>> -#endif
>>>        non_stop = was_non_stop;
>>
>> The old gdbserver code set non_stop = 1 *after* asking the target to
>> stop, whereas now it'll be done before (right?).  Just checking that
>> that's ok.
>> E.g., I see a test for non_stop in linux_resume (which feels weird to be
>> using in this context given that we're talking about target_stop :-)).
> 
> Good catch!  I did not notice that change.  I also don't know if it's
> ok.
> 
> In the gdbserver case forcing non_stop to 1 causes need_step_over
> in linux_resume to become maybe set.  

> If non_stop had been 0
> need_step_over would definitely be NULL. 

That isn't really true, see:

  any_pending = 0;
  if (!non_stop)
    find_inferior (&all_threads, resume_status_pending_p, &any_pending); #1
...
  if (!any_pending && supports_breakpoints ())
    need_step_over
      = (struct thread_info *) find_inferior (&all_threads,
					      need_step_over_p, NULL);

If non_stop is 0, then we execute #1 above, true.  But, that may well
return with ANY_PENDING still clear/0, and so 'need_step_over' may end
up set anyway.

So looks fine to me.

> So forcing non_stop to 1
> beforehand like this patch does means a step over might take place
> that would otherwise not have.

See above.

> 
> In the GDB case forcing non_stop to 1 before target_stop forces GDB
> to send a SIGSTOP to each LWP. 

Note we're just really just stopping one LWP here, the agent helper
thread, specified in PTID, not all threads.

> If non_stop had been 0 linux_nat_stop
> would have fallen back to inf_ptrace_stop which sends one SIGINT to
> the process group.
> 

Yeah, we definitely want SIGSTOP, not SIGINT here.  Really, GDB_SIGNAL_0:
SIGSTOP is how we implement "quiesce with no signal" on Linux -- the
SIGSTOP is not visible to the target_wait caller.  Unfortunately we have
a mixup of "interrupt/ctrl-c" vs "quiesce" in the interface.

> I don't know enough about this to know which is the best solution.
> Pedro would know, but he's away for the next two weeks.  If what is
> happening currently is correct in both cases then maybe a new target
> method "target_stop_all" is required to encompass the whole block of
> code.
> 
> In the interests of keeping things moving would you be ok for me to
> commit the following until Pedro is back and able to advise?
> 
>       /* FIXME: This conditional code needs removing, either by
>          setting non_stop in the same place for both cases or by
> 	 implementing a new client method for this whole block
> 	 (less the printing code) from "int was_non_stop = non_stop;"
> 	 to "non_stop = was_non_stop;".  */
> #ifdef GDBSERVER
>       target_stop (ptid);
>       non_stop = 1;
> #else
>       non_stop = 1;
>       target_stop (ptid);
> #endif

Thanks,
Pedro Alves


  reply	other threads:[~2014-08-20 14:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 10:19 [PATCH 00/11 v5] Common code cleanups Gary Benson
2014-08-01 10:19 ` [PATCH 02/11 v5] Introduce common-types.h Gary Benson
2014-08-06 16:34   ` Doug Evans
2014-08-01 10:19 ` [PATCH 03/11 v5] Move print-utils.h to common-defs.h Gary Benson
2014-08-06 16:51   ` Doug Evans
2014-08-06 17:05     ` Gary Benson
2014-08-01 10:19 ` [PATCH 04/11 v5] Introduce and use debug_printf and debug_vprintf Gary Benson
2014-08-06 17:08   ` Doug Evans
2014-08-07  9:22     ` Gary Benson
2014-08-01 10:22 ` [PATCH 07/11 v5] Introduce get_thread_regcache_for_ptid Gary Benson
2014-08-06 18:15   ` Doug Evans
2014-08-01 10:22 ` [PATCH 09/11 v5] Remove GDBSERVER uses from linux-btrace.c Gary Benson
2014-08-06 18:27   ` Doug Evans
2014-08-01 10:27 ` [PATCH 10/11 v5] Remove GDBSERVER uses from i386-dregs.c Gary Benson
2014-08-06 18:32   ` Doug Evans
2014-08-07 12:28     ` Gary Benson
2014-08-01 10:27 ` [PATCH 08/11 v5] Include common-defs.h instead of defs.h/server.h in shared code Gary Benson
2014-08-06 18:16   ` Doug Evans
2014-08-01 10:28 ` [PATCH 05/11 v5] Add target/target.h Gary Benson
2014-08-06 17:49   ` Doug Evans
2014-08-07 13:48     ` Gary Benson
2014-08-20 14:49       ` Pedro Alves [this message]
2014-08-20 15:01         ` Gary Benson
2014-08-20 15:08           ` Pedro Alves
2014-08-20 12:00   ` Pedro Alves
2014-08-20 12:01   ` Pedro Alves
2014-08-20 13:38     ` Gary Benson
2014-08-01 10:28 ` [PATCH 06/11 v5] Add target/symbol.h Gary Benson
2014-08-06 18:08   ` Doug Evans
2014-08-07 10:42     ` Gary Benson
2014-08-20 11:16   ` Pedro Alves
2014-08-20 12:14     ` Gary Benson
2014-08-20 14:17       ` Pedro Alves
2014-08-01 10:30 ` [PATCH 01/11 v5] Introduce common/errors.h Gary Benson
2014-08-06 16:20   ` Doug Evans
2014-08-06 16:29     ` Gary Benson
2014-08-06 16:40       ` Doug Evans
2014-08-01 10:41 ` [PATCH 11/11 v5] Remove one GDBSERVER use from linux-waitpid.c Gary Benson
2014-08-06 18:35   ` Doug Evans
2014-08-07 12:39     ` Gary Benson
2014-08-20 15:04       ` 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=53F4B55B.3020207@redhat.com \
    --to=palves@redhat.com \
    --cc=dje@google.com \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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