public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "simark@simark.ca" <simark@simark.ca>,
	Aditya Kamath1 <Aditya.Kamath1@ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Enable multi process debugging for AIX
Date: Mon, 22 Aug 2022 13:25:39 +0000	[thread overview]
Message-ID: <b5f0a3ba2f59d9ed28ef2f0ae4b9c99a50565cfc.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB3544B307E98ACD47FDC59C28D66D9@CH2PR15MB3544.namprd15.prod.outlook.com>

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Enable PT_MULTI option in ptrace () call along with the process ID
>parameter and the data parameter enabled. Usually one enables multi
>process debugging for all the process debugged in post_startup_inferior
>() function like in the Linux world.
>On a fork () event either the child can report a wait event first or
>the parent. 
>A status of 57e in hexadecimal or 1406 in decimal is returned from the
>waitpid () with the process ID. This can be used to detect a fork ()
>event.  
>Since the child process will not have an inferior, we check with the
>find_inferior_pid () to see if the child reports first. If it is the
>next wait event is generated by the parent in AIX. This is how we
>absorb the parent and child event to fetch their process ID. 
>The vice versa of the above can be done if the parent process reports a
>fork () event first. 
>Once it is done we tell the gdb core that we forked with ourstatus by
passing the child ptid. 

Simon already commented on this in his initial review, and I think this
is still not completely addressed.  Most importantly, your code simply
assumes that it is guaranteed that the two wait events for parent and
child will arrive immediately after one another, and the only uncertain
issue is the sequence between the two.

Is is actually guaranteed that this is the case?  Or could we also have
random other wait events (e.g. from other threads / processes) that can
be reported in between?   In that case, your implementation now
introduces a race condition where some event might get lost.

A proper fix might then have to be more involved, e.g. by storing those
event on some sort of "pending list" and only report a fork event to
common code once both sides have checked in, similar to the FreeBSD
approach Simon already pointed out to you.


As to this:
+# define AIX_FORK_EVENT 0x57e 

It would be much preferable to use the official names for these
constants.  For example, the document you mention here:

>More about this can be read in the document 
>https://www.ibm.com/docs/en/aix/7.2?topic=p-ptrace-ptracex-ptrace64-
subroutine

talks about:
  W_SFWTED
  Process stopped during execution of the fork subroutine.

Is this the 0x57e event?  If so, we should call it W_SFWTED in GDB as
well, and not some made-up name.

It would be great if you could find the official names for all the
other "magic" constants like 0x7f, 0x17f, 0x137f etc. as well.


Bye,
Ulrich


  parent reply	other threads:[~2022-08-22 13:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 15:53 Aditya Kamath1
2022-07-19 18:51 ` Simon Marchi
2022-07-22 16:56   ` Aditya Kamath1
2022-08-18 18:59   ` Aditya Kamath1
2022-08-21 17:15     ` Aditya Kamath1
2022-08-22 13:25     ` Ulrich Weigand [this message]
2022-08-22 14:19       ` Simon Marchi
2022-08-23  6:52       ` Aditya Kamath1
2022-10-19 10:57       ` Aditya Kamath1
2022-10-19 10:57         ` Aditya Kamath1
2022-10-28 10:59         ` Ulrich Weigand
2022-11-01 13:55           ` Aditya Kamath1
2022-11-02  8:56             ` Ulrich Weigand
2022-11-10 10:39               ` Aditya Kamath1
2022-11-14 18:24                 ` Ulrich Weigand
2022-11-15  7:13                   ` Aditya Kamath1
2022-11-15 10:53                     ` Ulrich Weigand
2022-11-15 12:01                       ` Aditya Kamath1
2022-11-15 12:43                         ` Ulrich Weigand
2022-11-15 18:13                           ` Aditya Kamath1

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=b5f0a3ba2f59d9ed28ef2f0ae4b9c99a50565cfc.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simark@simark.ca \
    /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).