public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH v3 5/7] gdb/remote.c: refactor pending fork status functions
Date: Fri, 3 Dec 2021 22:03:58 -0500	[thread overview]
Message-ID: <01523b8a-386f-9b11-d36d-f9d6c1a9eb43@polymtl.ca> (raw)
In-Reply-To: <6e7bb618-0b22-c95d-93d0-3a84d81b38e4@palves.net>

On 2021-12-03 18:43, Pedro Alves wrote:
> On 2021-12-01 14:44, Simon Marchi via Gdb-patches wrote:
>> From: Simon Marchi <simon.marchi@efficios.com>
>>
>> In preparation for a following patch, refactor a few things that I did
>> find a bit awkward, and to make them a bit more reusable.
>>
>>  - Pass an inferior to kill_new_fork_children instead of a pid.  That
>>    allows iterating on only this inferior's threads and avoid further
>>    filtering on the thread's pid.
>>  - Change thread_pending_fork_status to return a non-nullptr value only
>>    if the thread does have a pending fork status.
>>  - Remove is_pending_fork_parent_thread, as one can just use
>>    thread_pending_fork_status and check for nullptr.
>>  - Replace is_pending_fork_parent with is_fork_status, which just
>>    returns if the given targeet_waitkind if a fork or a vfork.  Push
> 
> typo "targeet_waitkind".

Fixed.

>> -/* Return the thread's pending status used to determine whether the
>> -   thread is a fork parent stopped at a fork event.  */
>> +/* Return THREAD's pending status if the it is a pending fork parent, else
>> +   return nullptr.  */
> 
> Some typo in "if the it is".

Fixed.

>> -static const target_waitstatus &
>> +static const target_waitstatus *
>>  thread_pending_fork_status (struct thread_info *thread)
>>  {
> 
> 
>> -/* Kill any new fork children of process PID that haven't been
>> +/* Kill any new fork children of inferior INF that haven't been
>>     processed by follow_fork.  */
>>  
>>  void
>> -remote_target::kill_new_fork_children (int pid)
>> +remote_target::kill_new_fork_children (inferior *inf)
>>  {
>>    remote_state *rs = get_remote_state ();
>>    struct notif_client *notif = &notif_client_stop;
>>  
>>    /* Kill the fork child threads of any threads in process PID
>>       that are stopped at a fork event.  */
> 
> Stale comment, refers to PID.

Fixed.

>> -  for (thread_info *thread : all_non_exited_threads (this))
>> +  for (thread_info *thread : inf->non_exited_threads ())
>>      {
>> -      const target_waitstatus &ws = thread->pending_follow;
>> +      const target_waitstatus *ws = thread_pending_fork_status (thread);
>>  
>> -      if (is_pending_fork_parent (ws, pid, thread->ptid))
>> -	{
>> -	  int child_pid = ws.child_ptid ().pid ();
>> -	  int res;
>> +      if (ws == nullptr)
>> +	continue;
>>  
>> -	  res = remote_vkill (child_pid);
>> -	  if (res != 0)
>> -	    error (_("Can't kill fork child process %d"), child_pid);
>> -	}
>> +      int child_pid = ws->child_ptid ().pid ();
>> +      int res = remote_vkill (child_pid);
>> +
>> +      if (res != 0)
>> +	error (_("Can't kill fork child process %d"), child_pid);
>>      }
>>  
>>    /* Check for any pending fork events (not reported or processed yet)
>>       in process PID and kill those fork child threads as well.  */
> 
> Ditto.

Fixed.

> Otherwise LGTM.

Thanks,

Simon

  reply	other threads:[~2021-12-04  3:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 14:44 [PATCH v3 0/7] Fix handling of pending fork events Simon Marchi
2021-12-01 14:44 ` [PATCH v3 1/7] gdbserver: hide fork child threads from GDB Simon Marchi
2021-12-03 23:30   ` Pedro Alves
2021-12-01 14:44 ` [PATCH v3 2/7] gdb/linux-nat: factor ptrace-detach code to new detach_one_pid function Simon Marchi
2021-12-03 23:30   ` Pedro Alves
2021-12-01 14:44 ` [PATCH v3 3/7] gdbserver: suppress "Detaching from process" message Simon Marchi
2021-12-03 23:42   ` Pedro Alves
2021-12-04  2:57     ` Simon Marchi
2021-12-01 14:44 ` [PATCH v3 4/7] gdb/remote.c: move some things up Simon Marchi
2021-12-03 23:42   ` Pedro Alves
2021-12-01 14:44 ` [PATCH v3 5/7] gdb/remote.c: refactor pending fork status functions Simon Marchi
2021-12-03 23:43   ` Pedro Alves
2021-12-04  3:03     ` Simon Marchi [this message]
2021-12-01 14:44 ` [PATCH v3 6/7] gdb: move clearing of tp->pending_follow to follow_fork_inferior Simon Marchi
2021-12-03 23:43   ` Pedro Alves
2021-12-01 14:45 ` [PATCH v3 7/7] gdb, gdbserver: detach fork child when detaching from fork parent Simon Marchi
2021-12-03 23:44   ` Pedro Alves
2021-12-04  3:36     ` Simon Marchi
2021-12-07 23:25       ` Pedro Alves
2021-12-08 19:54         ` Simon Marchi

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=01523b8a-386f-9b11-d36d-f9d6c1a9eb43@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=simon.marchi@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).