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 794EC3858D34 for ; Mon, 15 Apr 2024 14:38:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 794EC3858D34 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 794EC3858D34 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=148.163.156.1 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713191883; cv=pass; b=psjhbOfQ+CvSgPxtNjff93ByRbrbLpbAodJZLzXosXLnUnB9ZnM73V4TH6RITHGQo8mkY2KgSHnxxDF32bwKPM/kIi05WUGzWzmSCwyjNzHvyDi9bxuhDhn8gGWJYG/w+9hmNDgcOmLKQd1LruQZSx34QH6Ncc/1na832is6rOM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713191883; c=relaxed/simple; bh=r8F2vulA2A0f/7HDHLSY4M5U1W3fSEvPD/zfZoHNyMg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PHVELwj/XJ+2WoDZXvizvAlPLOfjbzC5zCdqV+SaHugEXI7oSHQKwnorCORONrtArYLnAQF1F8UItTAu+5WPrcwhwV7KmQHVqg2cZnYiHZ3gl88uUS2JuAzOAMrCHCN1gKuHVC+mWTzvjiwwssCJOMXwdXgKinWtjTmcWNR5spY= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43FEU1VG011649 for ; Mon, 15 Apr 2024 14:37:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=pp1; bh=zG3tUohGdTeR4E/pue4verxcfJDRQ/PPmdoJ9QC4io8=; b=dHw/LQdviG+TXhs/YHwqmY66j/f6iVIzZSTdDyeOYUYyMmdkR0mBtUDzZr1N9j2Ogr7N ws42zNVx8wHp9nEP6iihwQLhuaz5mng2YWndJSsj6eIMyVZv5mJmvysPpx5HuXAS9rov c5gcOQ6qIMjL2wWGe/xyPSHESlN0WUihqXVoR+3mUjsLC2mPk1BulbBqHOJ0ituMytu0 plSG5uKIvs21kCbL2IzX8PL6BZ05QwnS3AB5zyEkNVj1aI79yMUUOtFFsfnHr23JfZI+ 4VSnvnV3sAp4WnT+jFuyAw6vNMvBaVs5aUs8TVE0oEjyk2/pS2l9Ttm6/cFHrTBV/KzD aA== Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2041.outbound.protection.outlook.com [104.47.57.41]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xfj6gv1us-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Apr 2024 14:37:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RGz0kOh90l/XC+S4UGCdKvg9xIpW9G23o5cTdxIk/z48M1Em6UPLTrbZIOE2vO8HzC5bzGxYq60C6WLZLiUtikbIVGb9Zx2WdudQ+QYKZw1yOE3migFVHbt1VRTKo0pOkGhPMPLPOaJU+ocwrZskp9lR63+xB4FFogiDkBlVqYCuCJwccW5qcnHVd9MjIt3u8i8BmJqziywuqvG3+iAC+LZxC3c2tWrY4/AeC4KYmEzy55BegJVTN++Kirsv/MHg5fmmfmwmPJicBQ8k9Cp8vp8gn5NCPUCpHRATn0bTAbFgioVdIaA8ijVCZDabv2WZsnSDXojTc9dpAPy+XtZ44w== 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=zG3tUohGdTeR4E/pue4verxcfJDRQ/PPmdoJ9QC4io8=; b=fF6GIEIuEL2yklovLjePwGTLLe9G5llp5L/dYOJZRSiAe8CMjhsPRuOc6+tD98/Miytyj28JNlHJCLwitKHnQpPddrDoPykNlA8LZxBlr2m7CIq4ODeP2zw9PdzHGiVsF0lHCBuy95hlvpaKCo/mx9bveC475JO14o11zUNAhk2p/ZPK+lKalu+j+auvtpfiK8xOqJBOy8TlSyDtOLKrciteqOT59XliTlPs0E5ftqqUFLA6zRgEydgtIpDJPGBPJyyftKQQMgMFcMTOMVyJTeGjh5Z3fQqhHtDkc6yS5ElJBIq7JJnGruJ3IO2muvOq0NskpArMpgAbVf9dLOc4+g== 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 CH2PR15MB3544.namprd15.prod.outlook.com (2603:10b6:610:5::26) by SA1PR15MB4888.namprd15.prod.outlook.com (2603:10b6:806:1d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Mon, 15 Apr 2024 14:37:01 +0000 Received: from CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::86ba:f8f8:c478:6919]) by CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::86ba:f8f8:c478:6919%3]) with mapi id 15.20.7452.049; Mon, 15 Apr 2024 14:37:01 +0000 From: Aditya Kamath1 To: Aditya Kamath1 via Gdb-patches , Ulrich Weigand CC: Sangamesh Mallayya Subject: [RFC] Using all three fields of ptid and handling thread events from rs6000-aix-nat.c Thread-Topic: [RFC] Using all three fields of ptid and handling thread events from rs6000-aix-nat.c Thread-Index: AQHajzm4IrvbbpCcN0mvhhhTYzpQGA== Date: Mon, 15 Apr 2024 14:37:01 +0000 Message-ID: Accept-Language: en-IN, en-US Content-Language: en-IN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR15MB3544:EE_|SA1PR15MB4888:EE_ x-ms-office365-filtering-correlation-id: 68b287f9-942f-4282-f2ba-08dc5d598370 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NERjU0lX7NAEB2SxEC0eIC9Qxufh5GMWGTbR+c+8ii2e3/vOIXAoCCtkttsx3agqfhfO0m2xtmyrzMJKDnfjrVEKpIupL/PMlO4YeWcoaSrJo40WHJTAPVsaR1MNzDNGiELYSdmSP6ywWgLb68drRk3MS/Wap3+saZTyLHdG8BuyVDx7YxPyLpGMD0FslKEvc2LHeyeva4U1EgKyBZAOi54D4/S/EbCcbSQGG6EnPwJDEfnU+lRhZbRPHRkdQ/hMqabbTBzL6L6SBJMDJx6WyTXbAOCUf/9s9u1zlzU+nT+81JIw8zKEUmlrR6qOW99G9JFbvsVNYjVRHnkdr4HZRY/phUGnQuzCNfZy42hlbFVsQqN8mYOWPBkiAwmFi/aMgidlUjh8R1/q9hx0M7RvYZvLjkkT9TN40YxwZ+ouYxExjM6VveWlyQG0i7USjm+MkK9sal07RWGK8lxv0v70PQbsTzgtWn3iOSiLO2EZ0RZmt/u3t/h+yNF1QXCanBaM2LDRpOG6764hmVc3gfP9g9elQ9CFzpkQAQDk3u6j+/hqpK2/LSUPFoKK1UIcKMrNgOTlrUGXScNtL/0JcW0erdhoi0LvI2Eo7nME1n10mLLL20+oJM8UL/qcrjNCXvjrFZp9hPm9Ri1JN/IX/p8HM09iRGZTMVnxFt7zmQAv3Nk= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR15MB3544.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?Dmfh90Cez9rvc0L0LkdpTyhfhfBKhUEvUrqd7Afc6xpEvSVJ0rgKw1aV?= =?Windows-1252?Q?nU/q/qXod9Rp0k+nxXov+ijLaTo9uc8qC7ExFXfkzVaVkRKFIP9Ybhh0?= =?Windows-1252?Q?zFrZncsAlQxMT69yNaqbBW8KGsl2DuHZaNjcLmhPyaMyA/aVNihzQ/q/?= =?Windows-1252?Q?8wRP0CxFld8m6dYAHbb6EJE7/WyDaz6N2RhwvZLTguE0WPxYn165l7RY?= =?Windows-1252?Q?HLynhwZOuLmAJK2uhEJJPgrqlKdjrQyXn7F4kcvAGofvWUFv3uzNuRP0?= =?Windows-1252?Q?Bn08g+DteNe2YaRMJNNRMUDVyQl/rqXb3muh5+kWTjJtar17zNLoh4lO?= =?Windows-1252?Q?L61iSHopBb1TpT+w+7ADFG5XMpEN9jT84JR1hfB84ora8++c5y9NmRGL?= =?Windows-1252?Q?3tNSuUq/9qhYpPz0HSMLPE0MMFUfLvBWlk6oAwL7KNbwVImDe7vHAHY7?= =?Windows-1252?Q?jEVJ4LJMxOReBgERokG6/c0tVN49XnX5yERJhhxnKKlnk9YaaDP+ctnl?= =?Windows-1252?Q?/OdvHOJkB1Q80urPk3Bj9j3XaQfLS3CKLvAifJ0W8KWIvqMd79u2bfvP?= =?Windows-1252?Q?1CGqFQ17G83ZmgtG/Zg03gPB2zYH7rZzP3w20MezcHyo8i0IF14EjFkO?= =?Windows-1252?Q?4qnDBbImNPX4oxIjSnpYjT8tiJURZ/3cRnvyHPqE13Uc8O6fhCxRHSiP?= =?Windows-1252?Q?TmwQucM3VNj8k3IRRtZKKZqLCZdfXvd9WpOB+mjWl4XVielhdgFQV1Pl?= =?Windows-1252?Q?6jCyaWNOG/E3daeAlQenycMO4fR0wdzg8kXRZK0JLJunjpMxZncuvBwS?= =?Windows-1252?Q?5+WCDLbARvjsB85rFF0i2OXPTE+LWNXkc5n2QEnJEdBYn8gcQTLhe5IT?= =?Windows-1252?Q?Gpvnsa0qJu5AEaRmz97AMjeoDDfaTAur3+UnmsWdFVX+ZgD69mM90vbW?= =?Windows-1252?Q?3yBXNTWD4jiLPEXRNPRQdzmUCXZV+PMVPTNGrJhfLB3NOjnJleH+z6Xj?= =?Windows-1252?Q?XyYoRH+W+soToTyutXM7kqXvINR+IgR/ZD0JeASEXbHZF2ysakzcoKXj?= =?Windows-1252?Q?cTp1ZWetWQ7IveHG6J6+KtQMjih/lLIqBWEvZ36AJvsiav9IdHDVeD1b?= =?Windows-1252?Q?8vQGxR2x6FdZZoGGyr+K+lAz5Ipgfhd9IM2smYEPzIyyMpjaxSveNPhz?= =?Windows-1252?Q?rYlMyDK9bbcZlxUrzGBdoaxPsiYQeIeuoGwEul67O7m3iVnpHdGPeOXm?= =?Windows-1252?Q?nssVJKKunwAJLsI9RsKAEMyGXvMA5xZZ3KsGELNpkzQmPfse/ECCLnlm?= =?Windows-1252?Q?O4ZyV70JvytP2b8w6T58n8OpHXvoHpTLn0tc2MsRkQWcb/aBY7hWT5pU?= =?Windows-1252?Q?mLu7gRroMslSb8dETRr8ARaJNsy9ekwGtlh6U0DV33f5Ulx4Ev0R4R6b?= =?Windows-1252?Q?FeMt1L4emBGGad674S5pqFF6fBjGJWknM6/IOCKD+xY2Dn43Wd5VgfF8?= =?Windows-1252?Q?iXcqP2G0QwGjBt2UOOYDQK+KsXeQ9N+ItfS1TrJVXBTMveAdCe/w2C0D?= =?Windows-1252?Q?0au3Z7T2TBReuoI0AQX+RmaRzpEAagCNUJOhw6tCM73Shje1oSqwPHhu?= =?Windows-1252?Q?CqdY0mK+yE2Ms3pUBzxet6oSWS9hF0r/ium/YQVfaIJRC5bPmG9ivDmZ?= =?Windows-1252?Q?ut7zyXLIVrddWITR+g118QgK/+BpJDxL7fIrC4RMAUo0czyeVdwMuRVn?= =?Windows-1252?Q?Tr3XoaAg7FLgWnLvsC/yNHHKknnwN2v+JJWKcmqC+Qkpvw5LBSv56OyI?= =?Windows-1252?Q?ThHKIA=3D=3D?= Content-Type: multipart/alternative; boundary="_000_CH2PR15MB3544A54C0069F64093476A2BD6092CH2PR15MB3544namp_" X-OriginatorOrg: ibm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR15MB3544.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68b287f9-942f-4282-f2ba-08dc5d598370 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2024 14:37:01.8058 (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: RrHyPVDCdvhmVMRcti+3IZbARsw8rLCDrXRb+kycxbZ7Q9ITIo63QmtV/Zntgs3g4d2Hj0ucJTtN/gjg0rdWpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR15MB4888 X-Proofpoint-GUID: lHaVJrvkklKPBeCTbPxhKfaOGLFwBjwq X-Proofpoint-ORIG-GUID: lHaVJrvkklKPBeCTbPxhKfaOGLFwBjwq X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-15_12,2024-04-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 spamscore=0 clxscore=1011 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404150095 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --_000_CH2PR15MB3544A54C0069F64093476A2BD6092CH2PR15MB3544namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Respected community members, Hi, I am currently working on fixing a bug on handling the thread exit event in= AIX and displaying the same in UI. Currently, in AIX we miss the event res= ulting in incorrect display of info threads. For example, for the program 1 pasted below this email. This is a single pr= ocess creating three more threads. The GDB output in AIX is:- (gdb) b main Breakpoint 1 at 0x10000788: file //gdb_tests/continue-pending-status_exit_t= est.c, line 44. (gdb) r Starting program: /gdb_tests/continue-pending-status_exit_test Breakpoint 1, main () at //gdb_tests/continue-pending-status_exit_test.c:44 44 alarm (300); (gdb) c Hello World Hello World Hello World [New Thread 258] [New Thread 515] [New Thread 772] Thread 1 received signal SIGINT, Interrupt. 0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o) (gdb) info threads Id Target Id Frame * 1 Thread 1 (tid 26607979) (tid 26607979, running) 0xd0611d70 in _p_= nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o) 2 Thread 258 (tid 30998799) (tid 30998799, finished) aix-thread: ptrac= e (52, 30998799) returned -1 (errno =3D 3 The process does not exist.) The Linux output for the same is (gdb) b main Breakpoint 1 at 0x10000990: file test_thread.c, line 27. (gdb) r Starting program: /home/buildusr/binutils-gdb/gdb/test_thread [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 1, main () at test_thread.c:27 27 alarm (300); (gdb) c Continuing. [New Thread 0x7ffff7c7f170 (LWP 4032543)] [New Thread 0x7ffff746f170 (LWP 4032544)] [New Thread 0x7ffff6c5f170 (LWP 4032545)] Hello World Hello World Hello World [Thread 0x7ffff6c5f170 (LWP 4032545) exited] [Thread 0x7ffff746f170 (LWP 4032544) exited] [Thread 0x7ffff7c7f170 (LWP 4032543) exited] ^C Thread 1 "test_thread" received signal SIGINT, Interrupt. 0x00007ffff7da5b04 in nanosleep () from /lib64/libc.so.6 (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7ff3e00 (LWP 4032541) 0x00007ffff7da5b04 in nanosleep () from /lib64/libc.so.6 (gdb) Reason why this happened. In Linux, I see in the linux-nat.c /* Check if the thread has exited. */ 2278 if (WIFEXITED (status) || WIFSIGNALED (= status)) 2279 { This is where it gets handled when wait () is called. But in AIX, in sync_threadlist () despite having the code we miss the bus. = If we observe the sync_threadlists () code our pcount and gcount remain the= same despite the threads exiting resulting in, we not capturing the exit. The debugger checks why it had to wait (), goes to pd_activate (), then to = pd_update (), then to sync_threadlists () where the event of threads born a= re captured. One interesting thing here is that in Linux the print =93Hello World=94 hap= pens after the thread born event is captured but in AIX it happens before. Are we missing something in AIX?? One information I want to give is we do g= o to wait () before the print Hello world happens, but we do not call pd_ac= tivate () and even if we do [We call it on purpose skipping the if conditio= n in wait () in aix-thread.c], the thread debug session is not successful. = In the next wait () event is when we capture the new thread or add_thread (= ) event. There is one more wait () event that happens after this, but here as well A= IX fails to capture the thread_exit event in sync_threadlists () since the = pcount and gcount are the same. So, neither could we capture the thread exit nor found a way to correct it = later because we missed the same. Kindly let me know the reasons you think from your experience on why this h= appened. This will help us fix this issue on AIX. Are all these thread rela= ted issues got to do with the fact that GDB core is expecting certain callb= acks in the rs6000-aix-nat.c which currently does not exist? So, looking at the UI of Linux and this bug I also want to do two things in= GDB code: 1: Move the kernel thread handling part to rs6000-aix-nat.c by using all th= e three fields in ptid i.e. pid, lwp and tid, so we can be in sync with Lin= ux both in terms of event handling and UI display. [As Ulrich mentions here= ] 2: Contribute this test case as well to make sure these bugs are captured. = So, is there anything similar already? In continuous-pending-status.exp, wi= th the while (1) in the thread this issue I missed. Kindly let me know if the community is okay with the above or anything we h= ave to keep in mind. Have a nice day ahead. Thanks and regards, Aditya. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Program 1:- #include #include #include #include #include pthread_barrier_t barrier; #define NUM_THREADS 3 void * thread_function (void *arg) { /* This ensures that the breakpoint is only hit after both threads are created, so the test can always switch to the non-event thread when the breakpoint triggers. */ pthread_barrier_wait (&barrier); printf ("Hello World \n"); /* 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; } --_000_CH2PR15MB3544A54C0069F64093476A2BD6092CH2PR15MB3544namp_--