From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 3187E3858D28 for ; Tue, 12 Apr 2022 13:33:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3187E3858D28 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23CCT5pK027021; Tue, 12 Apr 2022 13:33:05 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fd70vvynb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Apr 2022 13:33:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i7k6T3e7OEfkSGcYxTJ5R6Ke+lanGe5CPZpiGGtPcUDyvRzFds3Pu+5Udr7K3CIhKDSoYACnpBHpSb4Z99FnzjQj4lTgomKe5TSubMLyBRkQsd1vxAhj1tL2dpodjldMngjoaJIiVDZr6qkQyM7UcpLuCJHQ4sGCdr5tVP7qkdiSFFbiHiz1vbxyDdL9uxZ7UiSJOj1tLCr425siF/odf+wnXY/4IXmCJrCS1vL3WJlrgzDUKsCxCJmT9Xztw6TCQuBZoCrZo/EgqSlpcd3b6zO8zg2ukRyOLpz6fiPbDctA6IkEx7T3OXDmHiDpm0khxtwmJNKO5/NpRjpk1bVqnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dOZDLUL5/Di3thUzsK2YtsKVpWNzQbaBVV3yO9qsfs4=; b=Pav69vtKLC1NwmcFO+l77QhGr2i8RccwsVV+XcX1Gx0otbGTfy1rjpHqpFO5XxEauFNXYQDiiw5Zo1D996j70za7lafk1NV9r6snaoPzMYgXbghdXQ1LgFCd8UZaNnv9GJeJVLp1oc0pVot8+l4v1bprXcsej5RWd3orxvOluiIhZt+uF2J3GxmNEoecrvgnFHOLqmLxV/h3g/e+xnbmA49Urts7WUh82ApD2Bla/s+syUkn7ThkwBMzqKVtE2eXYQJvVgoJYRFeXA9qe758BYxbijos2Td7CC5idu/fs8pCuJfpw64UVSQCzGUQ/to0B9FVnJPb+lFbb5rm5Ejsug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ibm.com; dmarc=pass action=none header.from=ibm.com; dkim=pass header.d=ibm.com; arc=none Received: from BN8PR15MB2867.namprd15.prod.outlook.com (2603:10b6:408:83::15) by CH2PR15MB3608.namprd15.prod.outlook.com (2603:10b6:610:12::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Tue, 12 Apr 2022 13:33:00 +0000 Received: from BN8PR15MB2867.namprd15.prod.outlook.com ([fe80::946a:26fb:3b14:d38e]) by BN8PR15MB2867.namprd15.prod.outlook.com ([fe80::946a:26fb:3b14:d38e%6]) with mapi id 15.20.5164.018; Tue, 12 Apr 2022 13:33:00 +0000 From: Aditya Vidyadhar Kamath To: Simon Marchi , Joel Brobecker via Gdb-patches CC: Sangamesh Mallayya Thread-Topic: [EXTERNAL] Re: [PATCH] Use current_inferior ()->pid for AIX Thread-Index: AQHYQzomuN6vfkBMD0KaGHkq0D0viKzWU60AgAGS5NqACWl/AIALCa68 Date: Tue, 12 Apr 2022 13:32:59 +0000 Message-ID: References: <5f142468-bc68-9128-d4d6-80cf36f12a48@polymtl.ca> <87169b93-8be2-5ccd-6b58-51b395a367bd@polymtl.ca> In-Reply-To: <87169b93-8be2-5ccd-6b58-51b395a367bd@polymtl.ca> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: suggested_attachment_session_id: c4bb0c60-7be0-283b-fb70-6311e16a3451 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d9f53b5d-bde5-451e-6362-08da1c88f661 x-ms-traffictypediagnostic: CH2PR15MB3608:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Km8mLF/SOnZxQqwrTw6c9PKhUIvPehMnNBN1yXtfxZ0zkAtnjgmut1qcW/AD7qolJAcpOqRMqGtBpoJ3s8HKp2AFGhLDJnrjvA/SLO7VPBWvjBv3xbmsSGDwgR3z2ldMS61wGCFYYTW2jqvPPVEgY51yvcYkyJRhTF+awTuuntsOc1JxCkR1HUauvp0Flr67nSGqhKZwpsEdiTvfvkqfrw6761z33/YS25fhHC7bgnthVyNVfdj5u6Hju5gGQ/hHdE0l6ISPVwWgkdWaes6uhwfRQKT0SFKCylf02B0XJqdiS0oyKu1/8gpEH5viuc0FXPbBkqlFSniUJyXdp4ZdChz/9lvuny2EHzcemKuBphmRMBmYrtM/iuDKCxIPr6zgdT5JRmowZrk+TN9ruIiQR25wRI/2bs3gkVQTCurwg5RlSYtMizAKLH0rdXSCE7rK/K0f43x71J5jtUxM8sD6xHHlvRx+VTDOERAe1H5sPKSPVJka0xB5hOgDUm5A0wSydu6RDj1f41JrfKOQlTf+Q/YJqMbqf88dPESyEBPUgDJ7d6EdW+FoIKdVvr/zh/CWDlF0TW8SvBNzwCFQOFAS/F/Umnnp6wAVh1/z5u0rCXPuvfp65bFczrHdy+XZmZKx5nx1HrLYkVYmLL/DEh+y8N+B5D30H9GljG2Ec4EASk7PM2X+8TMBXX22wUsp9+dUxGu6FrLZ9BEQL1zjM8wvaw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR15MB2867.namprd15.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(2906002)(53546011)(26005)(6506007)(7696005)(86362001)(186003)(38070700005)(9686003)(55016003)(99936003)(83380400001)(38100700002)(122000001)(33656002)(508600001)(110136005)(5660300002)(8936002)(52536014)(316002)(91956017)(76116006)(71200400001)(66446008)(8676002)(66556008)(66946007)(66476007)(64756008)(4326008)(19627405001)(30864003)(579004)(559001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?yXV7JFP04AfJ6So2Ktw1WepAA2YyOnHVQPvs76I2kewo+OVRi2Ws+IxRsBLq?= =?us-ascii?Q?WqYGRAfgl4+oEEm914JJm3Ytgkk81Vugo7DxNiNtGpczaGrnvy/11WyfOvg6?= =?us-ascii?Q?neEsBrE1fhZcFVKBQF85CdILCplEHsX07TvydX1tWzW+fnYo9V7OW78K3E2B?= =?us-ascii?Q?Hroqbg+YtRJQkkWAyzxgCakhw4HsgJE1mHPtkOpuUmxV8d3ZC9r5piU4Vg7y?= =?us-ascii?Q?SfrGfRwqFHHZlXGrqaVOgMRo36bkGZH9XhX1BnMWK34ocssPWmnCE5lU1eR/?= =?us-ascii?Q?+KLS6nFUK6KjB9g4VI2xuAFQSXeYyP01CLbr4jO0UcnlT9foAvPqdc3Tfg34?= =?us-ascii?Q?eeKqsVaq9B8ecnSOdQ1v8sREPV/IX4pWB6FUXX2HIMuzdWuJgSUqxQc66NAG?= =?us-ascii?Q?KFltDVVCp++ZxHZBqYh5/anWUYbbqxBqFLUHMd7OYuA8drcpwy+y3Kw/xg8G?= =?us-ascii?Q?Q1kNkdR3eCOQS4IKtgtGySYfXbuC0+wx+76eD/GZYF9ECbAzUt4AR28czhKl?= =?us-ascii?Q?Py+mUjT8/dsnhOcRfR1K1Tvrc6WuEUR+ECrQO3fmfn5cRZJ+bMbfxAJ3by3o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MF1HjEtLnTqRVH5qLcJlZenPlMi5F?= =?us-ascii?Q?7GgdgQ5nt5bEpi5ZOiCyLavMNfOW9y58WyQtdGMd5lSoUxVbOOxy77wZpluS?= =?us-ascii?Q?43NMtqpkL13yqTwHQNLXsxCuUeO3tfLJxEClMoviHg+RWS0kzOu2PZy0KYYP?= =?us-ascii?Q?OXwMpmr0GlppNmaSUSA8djCxVjlvPMAJCMiSXh6lfsk+qWiEqrLS9v2hErOp?= =?us-ascii?Q?0NnmlSbfF5VJutndqePLpu/FrwIvqth64c12uVnEmiKdAWWAnqVYFguWCFAU?= =?us-ascii?Q?YF1fqejjpgztXor0S5HQwfJ8CkK6E+E=3D?= Content-Type: multipart/mixed; boundary="_004_BN8PR15MB2867490F2E1E86011C613655B5ED9BN8PR15MB2867namp_" MIME-Version: 1.0 X-OriginatorOrg: ibm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR15MB2867.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9f53b5d-bde5-451e-6362-08da1c88f661 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2022 13:33:00.0116 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fcf67057-50c9-4ad4-98f3-ffca64add9e9 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 26PlyYY+246lyYMGVnOSt+D7YsOVtJUA07oV7Z5anb7uHXA8TF21BcW9xmI7XxPivUtFwjFaN5K2yeZ5eiG8bPzEcIXRNtkQXE2EPaNYtWc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR15MB3608 X-Proofpoint-GUID: TkneBYpFH4H3fGvDlJ-ZxqCx73Bn3v61 X-Proofpoint-ORIG-GUID: TkneBYpFH4H3fGvDlJ-ZxqCx73Bn3v61 Subject: RE: [PATCH] Use current_inferior ()->pid for AIX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-12_05,2022-04-12_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204120065 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_KAM_HTML_FONT_INVALID, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 13:33:20 -0000 --_004_BN8PR15MB2867490F2E1E86011C613655B5ED9BN8PR15MB2867namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, A case by case analysis as suggested by you the last time has been done. While the child process [the program to be debugged] is running inferior_pt= id.pid() will not contain the child process ID. One has to use pid_t(curren= t_inferior ()->pid) inorder to get the child process in AIX. GDB may allow = you to execute many programmes at the same time. Numerous threads of execut= ion can be initiated from multiple executables in each of multiple processe= s. GDB uses an inferior object to represent the status of each programme run. = An inferior usually correlates to a process, although it is more broad and = may be used to targets without processes as well. Inferiors can be produced= before a process runs and kept after it has completed. Inferiors have thei= r own unique IDs, which are not the same as process ids. Each inferior may = have several threads going through it. As a result, inferior ptid.pid may n= ot need to contain the current inferior thread id. To obtain the inferior p= rocess ID, we must utilise current inferior()->pid in particular areas. When the child process's pd_active variable is not set i.e. the process is = not active one has to use the pid_t(current_inferior ()->pid) instead of in= ferior_ptid.pid() in AIX. This can be demonstrated by the following code: #include #include int main() { int i =3D 1; return 0; } Sample output without patch changes only in aix-thread.c at line 883 and no= t in rs6000-aix-nat.c: inferior.c:303: internal-error: find_inferior_pid: Assertion `pid !=3D 0' f= ailed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0x100e87543 ??? 0x100e8770b ??? 0x10003724b ??? 0x100037697 ??? 0x1000363f3 ??? 0x1000593a3 ??? 0x1000594ff ??? 0x10053aa9b ??? 0x1002f6e7b ??? 0x1002f2ec3 ??? 0x100b26d43 ??? 0x100302a03 ??? 0x10077e413 ??? 0x10077b1a7 ??? 0x100001dff ??? 0x100002007 ??? 0x10000421b ??? 0x1000042ef ??? 0x100000a9f ??? 0x100000583 ??? --------------------- inferior.c:303: internal-error: find_inferior_pid: Assertion `pid !=3D 0' f= ailed. Sample output with patch changes in aix-thread.c and without patch changes = in rs6000-aix-nat.c: Child process unexpectedly missing: There are no child processes.. Program terminated with signal ?, Unknown signal. The program no longer exists. Output with patch: (gdb) b main Breakpoint 1 at 0x1000070c: file test.cc, line 3. (gdb) r Starting program: /home/gdb_tests/test Breakpoint 1, main () at test.cc:3 3 int i =3D 1; ------------------------------------------- When there are multiple threads running in a debugging process, inferior_pt= id will not have the exact current inferior thread. Instead we need to use = ptid_t (current_inferior ()->pid) to get it in AIX. This can be shown by the following program: #include #include #include #include #include pthread_barrier_t barrier; #define NUM_THREADS 2 void * thread_function (void *arg) { pthread_barrier_wait (&barrier); while (1); /* break here */ } int main (void) { int i; alarm (300); pthread_barrier_init (&barrier, NULL, NUM_THREADS); for (i =3D 0; i < NUM_THREADS; i++) { pthread_t thread; int res; res =3D pthread_create (&thread, NULL, thread_function, NULL); assert (res =3D=3D 0); } while (1) sleep (1); return 0; } Sample output without patch changes in aix-thread.c at line 921 and 883 and= not in rs6000-aix-nat.c: inferior.c:303: internal-error: find_inferior_pid: Assertion `pid !=3D 0' f= ailed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0x100e87543 ??? 0x100e8770b ??? 0x10003724b ??? 0x100037697 ??? 0x1000363f3 ??? 0x1000593a3 ??? 0x1000594ff ??? 0x10053aa9b ??? 0x1002f6e7b ??? 0x1002f2ec3 ??? 0x100b26d43 ??? 0x100302a03 ??? 0x10077e413 ??? 0x10077b1a7 ??? 0x100001dff ??? 0x100002007 ??? 0x10000421b ??? 0x1000042ef ??? 0x100000a9f ??? 0x100000583 ??? --------------------- inferior.c:303: internal-error: find_inferior_pid: Assertion `pid !=3D 0' f= ailed. Output with patch: (gdb) b main Breakpoint 1 at 0x1000070c: file test.cc, line 3. (gdb) r Starting program: /home/gdb_tests/test Breakpoint 1, main () at test.cc:3 3 int i =3D 1; Summary of the gdb.base testsuites. Without Patch ------------------------ # of expected passes 8096 # of unexpected failures 2160 # of unexpected successes 1 # of expected failures 4 # of known failures 5 # of unresolved testcases 113 # of untested testcases 83 # of unsupported tests 40 # of paths in test names 2 # of duplicate test names 13 With Patch ------------------------ # of expected passes 13822 # of unexpected failures 7399 # of unexpected successes 1 # of expected failures 11 # of known failures 6 # of unresolved testcases 78 # of untested testcases 88 # of unsupported tests 63 # of paths in test names 1 # of duplicate test names 2 (See attached file: 0001-Use-current_inferior-pid-for-AIX) Thanks and regards, Aditya. ________________________________ From: Simon Marchi Sent: Tuesday, April 5, 2022 6:17 PM To: Aditya Vidyadhar Kamath ; Joel Brobeck= er via Gdb-patches Cc: Sangamesh Mallayya Subject: [EXTERNAL] Re: [PATCH] Use current_inferior ()->pid for AIX Hi Aditya, I don't think that using current_inferior throughout is a good solution to your problems. It will be case by case, unfortunately there's no easy way out of this but to dig in GDB and understand its internals a bit. > From eb10e0ebc422d01f5ce96786f0bcf78a4f57d7ef Mon Sep 17 00:00:00 2001 > From: Aditya Vidyadhar Kamath > > Date: Wed, 30 Mar 2022 11:19:14 +0530 > Subject: [PATCH] Use current_inferior ()->pid for AIX. > > --- > gdb/aix-thread.c | 15 ++++++++------- > gdb/rs6000-aix-nat.c | 8 ++++---- > 2 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c > index 85be4c15f1c..9331de3beb2 100644 > --- a/gdb/aix-thread.c > +++ b/gdb/aix-thread.c > @@ -708,7 +708,7 @@ get_signaled_thread (void) > > while (1) > { > - if (getthrds (inferior_ptid.pid (), &thrinf, > + if (getthrds (current_inferior ()->pid, &thrinf, > sizeof (thrinf), &ktid, 1) !=3D 1) This function doesn't seem to depend on the current inferior/thread, so it could easily be changed to receive the pid as a parameter. > break; > > @@ -791,7 +791,7 @@ sync_threadlists (void) > > /* Apply differences between the two arrays to GDB's thread list. */ > > - infpid =3D inferior_ptid.pid (); > + infpid =3D current_inferior ()->pid; > for (pi =3D gi =3D 0; pi < pcount || gi < gcount;) > { > if (pi =3D=3D pcount) > @@ -883,11 +883,11 @@ pd_update (int set_infpid) > struct thread_info *thread =3D NULL; > > if (!pd_active) > - return inferior_ptid; > + return ptid_t (current_inferior ()->pid); > > status =3D pthdb_session_update (pd_session); > if (status !=3D PTHDB_SUCCESS) > - return inferior_ptid; > + return ptid_t (current_inferior ()->pid); Here, the pd_update function seems to want to return the event ptid unmodified. So, perhaps that ptid could be passed by the caller and returned here. Or, pd_update could be changed to return an optional and the caller deals with returning the right ptid. > > sync_threadlists (); > > @@ -897,7 +897,7 @@ pd_update (int set_infpid) > if (tid !=3D 0) > thread =3D iterate_over_threads (iter_tid, &tid); > if (!thread) > - ptid =3D inferior_ptid; > + ptid =3D ptid_t (current_inferior ()->pid); > else > { > ptid =3D thread->ptid; > @@ -921,7 +921,7 @@ pd_activate (int set_infpid) > &pd_session); > if (status !=3D PTHDB_SUCCESS) > { > - return inferior_ptid; > + return ptid_t (current_inferior ()->pid); This is the same idea as in pd_update. > } > pd_active =3D 1; > return pd_update (set_infpid); > @@ -932,11 +932,12 @@ pd_activate (int set_infpid) > static void > pd_deactivate (void) > { > + ptid_t ptdrtn =3D ptid_t (current_inferior ()->pid) > if (!pd_active) > return; > pthdb_session_destroy (pd_session); > > - pid_to_prc (&inferior_ptid); > + pid_to_prc (&ptdrtn); Since pid_to_prc only writes to ptdrtn, it essentially a no-op. I would try just removing that call. It was used to modify inferior_ptid after the thread layer was disabled, which does not seem useful to me. > diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c > index 8563aea313a..0b8e4d2c687 100644 > --- a/gdb/rs6000-aix-nat.c > +++ b/gdb/rs6000-aix-nat.c > @@ -397,7 +397,7 @@ rs6000_nat_target::xfer_partial (enum target_object o= bject, > ULONGEST offset, ULONGEST len, > ULONGEST *xfered_len) > { > - pid_t pid =3D inferior_ptid.pid (); > + pid_t pid =3D current_inferior ()->pid; > int arch64 =3D ARCH64 (); > > switch (object) Here, inferior_ptid should be valid, this change should not be necessary. > @@ -525,11 +525,11 @@ rs6000_nat_target::wait (ptid_t ptid, struct target= _waitstatus *ourstatus, > > /* Claim it exited with unknown signal. */ > ourstatus->set_signalled (GDB_SIGNAL_UNKNOWN); > - return inferior_ptid; > + return ptid_t (current_inferior ()->pid); > } > > /* Ignore terminated detached child processes. */ > - if (!WIFSTOPPED (status) && pid !=3D inferior_ptid.pid ()) > + if (!WIFSTOPPED (status) && pid !=3D pid_t(current_inferior ()->pi= d)) > pid =3D -1; > } > while (pid =3D=3D -1); The target_ops::wait method implemenattions should ne rely on the current inferior either. I don't think that this target supports debugging multiple processes at the same time, but imagine that it does, eventually. When rs6000_nat_target::wait gets called, the current inferior is one of the inferiors managed by that target, at random. So what the wait method needs to do is fetch an event from the OS, and returning, regardless of which inferior it applies to (except if a ptid argument is given). So, you should never need to use either inferior_ptid nor current_inferior in wait. > @@ -658,7 +658,7 @@ rs6000_nat_target::xfer_shared_libraries > if (writebuf) > return TARGET_XFER_E_IO; > > - gdb::byte_vector ldi_buf =3D rs6000_ptrace_ldinfo (inferior_ptid); > + gdb::byte_vector ldi_buf =3D rs6000_ptrace_ldinfo (ptid_t(current_infe= rior ()->pid)); > result =3D rs6000_aix_ld_info_to_xml (target_gdbarch (), ldi_buf.data = (), > readbuf, offset, len, 1); This is used by xfer_partial, where inferior_ptid should be valid, so this change shouldn't be necessary. Simon --_004_BN8PR15MB2867490F2E1E86011C613655B5ED9BN8PR15MB2867namp_ Content-Type: application/octet-stream; name="0001-Use-current_inferior-pid-for-AIX.patch" Content-Description: 0001-Use-current_inferior-pid-for-AIX.patch Content-Disposition: attachment; filename="0001-Use-current_inferior-pid-for-AIX.patch"; size=1476; creation-date="Tue, 12 Apr 2022 13:27:10 GMT"; modification-date="Tue, 12 Apr 2022 13:27:24 GMT" Content-Transfer-Encoding: base64 RnJvbSA4ZmZlOGY4MmUyN2NmZjg2NDM2NDRhNWYzYWM4YzllN2YzZTNhNDYwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiAiYWRpdHlhQGlibSIgPGFkaXR5YS52aWR5YWRoYXIua2FtYXRo QGlibS5jb20+CkRhdGU6IFR1ZSwgMTIgQXByIDIwMjIgMDc6MDg6NDYgLTA1MDAKU3ViamVjdDog W1BBVENIXSBVc2UgY3VycmVudF9pbmZlcmlvciAoKS0+cGlkIGZvciBBSVgKCi0tLQogZ2RiL2Fp eC10aHJlYWQuYyAgICAgfCA0ICsrLS0KIGdkYi9yczYwMDAtYWl4LW5hdC5jIHwgMiArLQogMiBm aWxlcyBjaGFuZ2VkLCAzIGluc2VydGlvbnMoKyksIDMgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0 IGEvZ2RiL2FpeC10aHJlYWQuYyBiL2dkYi9haXgtdGhyZWFkLmMKaW5kZXggNmE0YjQ2OTc4OGEu LjQ3ZDYxMmM5NjBiIDEwMD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