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 CC1663858D28 for ; Thu, 18 Aug 2022 18:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC1663858D28 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27IIflpJ007748; Thu, 18 Aug 2022 18:59:28 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j1tx6requ-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 18:59:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H2A40ePLFW9RXCJ5R2COzuE0VVh3t7nUig+3KLI+AxASclrXzFPaYr716QTzE8ibwUO79iegY4bYTatWkfMUwq+8vKWgKeYBVcUqeHTM4SPTtExvcQDcCnWR+oAwfo+f1CGKIiYsbzRysg7gTiXvhGUbbWk1VdableVy8rv55usDVZdyuTY2FafcW1ZusxgZ9nnw1sJBJOngd9rJnqizdEhVqDTFEKjkqjxEtmDyKo2STvpyzxhlwwqsgXVbXfkP7WWsJVyhd1n6CEUKlSKUNhk6DvBkGGzN/4yPTaIO/AmgQxeUaZNDDPYxaAYF8+sUP9mL3FhIx/2o25iK8SKDyQ== 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=KmPqGv3doIh9tLLYeL6nTxmoz5/kPmsv5/Zmd3VF66Q=; b=lBqD5IUIzhPC3xkQ/f37zlvUaQkHQnVu5RVWh/pfDClrR1/QQ81bkxLM/3FqUQAJ3zJMI54ENhJpiynZ2cUaA+1XtR8173YS+rLGJ9TW9DyTwsSfLE0ZbsUfEK5vfY684+tqu5Gmey9I7y8hTPDXu+CArQwO/6y4WQ+oLdY55LL578lHV0r6Kh4E+phaxphFfjxjhuxVItrDYpZ4gSGKuVsER8gjy67jQE0Q55rbjV/2CdRd94hj/Sg5oLHUvYFu0VxTe2csXcgbkf/Hp/ytErhyIQLaqwUeajZuXUEjic3nsA3IVIEBokvpF/Jws9XbL6ajoYmUd2HBpiKOS6eFJQ== 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 SN6PR1501MB2176.namprd15.prod.outlook.com (2603:10b6:805:10::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 18:59:25 +0000 Received: from CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::802:6dec:b874:f15b]) by CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::802:6dec:b874:f15b%4]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 18:59:25 +0000 From: Aditya Kamath1 To: Simon Marchi , Ulrich Weigand , Aditya Kamath1 via Gdb-patches CC: Sangamesh Mallayya Thread-Topic: [EXTERNAL] Re: [PATCH] Enable multi process debugging for AIX Thread-Index: AQHYm4bOcAeVu+roE0qom9FKwssVZq2GCe4AgC8nV1s= Date: Thu, 18 Aug 2022 18:59:25 +0000 Message-ID: References: <44ad453e-6196-d334-312f-d5d0414f4476@simark.ca> In-Reply-To: <44ad453e-6196-d334-312f-d5d0414f4476@simark.ca> Accept-Language: en-IN, en-US Content-Language: en-IN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4c222ba6-3f56-438d-f0b7-08da814bc4ff x-ms-traffictypediagnostic: SN6PR1501MB2176:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uFInwO3pim/WpzWczUDUebQ/WuHQA+WJwT90MYOqLhY+qY8xfRUc9cVHPaO+4XsNr/mOEj3z7IYEI8FYLSgnf24Ogh9OrbjSzIkR6+SDPVZlJchJt+8XphQH94I0t6nncF4carGq0KgEIrvNGxElEruZ8GIs+6roJbooM9eBktzWCf3MoBvnc9M9sL68niMDGUXxw49YLhL0ThQETxAijiDxwmv7iAoLbkySe25LhrzEJz2DetQf9leUNHbA2PFsn4REXX5t63zNUE/kR+Z5yvV1ACtJbKB2DFUpCFPkoH+J90Xol9HUG+1m6snUmTvK/WTnYQ0M2mA2LlYsBkIS/HTxbmK/7Df2Afo77tmzaQoiLt5dwWvmKGBRnS1lxB491pdKg354WJuU/QL1yw7M12tGCQHASSZgAtXyiHL2SPrCA+vbu3z4K2VsGdNEMxbmfTiMpC+rP0L4bXcZgX0Py5bDH16vNc6JwSYnXs8Nx8/3J8qE4GHkx4U9HZ2BXX9EZ1M0EddFjMMeA7r4wrVs9EFV1KwGNq+SMkxiXboR/OMvNERIde3EA1+/0K9sSyAdge6HMNjIAfKlZMom1tMiUE5b5ztCMP/QGv237jxNnJ1azoVSU64OMAwlH6w5Q4bwfyCYd+ddWmn09kqWAfVGCy4vYUGRMOMXo0g16bckqeKJZ4LpDkzZEKs17Y0KwXRp/DNaIwMFBud2woBaDeaKLbSivJrNDtgaCL8OKAXIWnRy2piklwbNEy2l9IOOiwjAmWOLRZloxqfE4NQw6Nz4ztP7od4Y29EAcBzi/smOqc6Iryx9QOfYhzRAFIc1ZbCXOvglrNUcxybErZS42vAfpA== 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:(13230016)(396003)(136003)(346002)(366004)(39860400002)(376002)(316002)(110136005)(19627405001)(8936002)(52536014)(5660300002)(478600001)(9686003)(41300700001)(6506007)(7696005)(2906002)(53546011)(186003)(26005)(55016003)(33656002)(38070700005)(86362001)(83380400001)(76116006)(66946007)(66556008)(66476007)(66446008)(64756008)(8676002)(966005)(91956017)(4326008)(71200400001)(122000001)(38100700002)(99936003)(166002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eG6o0m3WZFd7Xw59/ayWPjJIDlGPKtayx7xB0oQWSdTuleieCIgtsCPmNzs/?= =?us-ascii?Q?hcfwi9Hsz1FFr7CnQrIbJnXbr+YSRI37R1MFKRBoaqZnEJkZivqrlkNwMSeU?= =?us-ascii?Q?1lrIYS6I21bwsPtSIRCYRh9rDZGLqdwSQ4MD1gx6lVWkpt/SIrWAxh4DZMLw?= =?us-ascii?Q?TfSJnCQSNwCVZT+iR3rofqN/LC7REoZftWgespy4dHXhKvvwC7Ic3dz+L2Ig?= =?us-ascii?Q?atIOcRpnjOt+kJED4vZ2f4vyUfyPfxOdJbWNcoxKeyiQDeLuGkEP6e9+B+PN?= =?us-ascii?Q?yShsnetSoz781aj7wkzTSO132mBEwD5tfMPEWdFP5uperkSO5j4o/drKfYwb?= =?us-ascii?Q?onBAslGh/ZesQsck5xPiYcLanHdERO3NCBnIP1i50QzUQRC8GSsGNdpcDqar?= =?us-ascii?Q?WzwFLRJUeSulafsBQ6UHQDL2Gw85g9RLFJj3zjQs7wsJOmM0xPBqfVOFSzVb?= =?us-ascii?Q?HNmLQlHd4IKsNtwDh25dqaKIFM7ZeXkgqVUJ84Jix0wGBy7USTkftF2vGmZD?= =?us-ascii?Q?EAM+41seZk04XjfF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9tx+ZAGC?= =?us-ascii?Q?2eeec8kvFz33MS6YceKKWW70y0b2X8QQSojv6/GgthacNEZwtbvBfTtn6cm2?= =?us-ascii?Q?aYt/qhXzf/4I9nR8MmtvUtC/JiwPC8I8mTWfS3dRs3APbkX82wfrKBPROSon?= =?us-ascii?Q?NB9M8G+2RWl92rcnlCDMVwOQcp18p1V7qEMOFMCg?= Content-Type: multipart/mixed; boundary="_004_CH2PR15MB3544B307E98ACD47FDC59C28D66D9CH2PR15MB3544namp_" 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: 4c222ba6-3f56-438d-f0b7-08da814bc4ff X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2022 18:59:25.3515 (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: DPbkth7y07Qj8U0FIcqm87lgi50TLv6bWfNIpOpzhzx6f0fFEX5rlkir3q5FUIYxRpET0TjVCcr65jA3jH4keQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR1501MB2176 X-Proofpoint-ORIG-GUID: 1-FyAiPtrj_q1wxbskE1CXRpfdaPEUHZ X-Proofpoint-GUID: 1-FyAiPtrj_q1wxbskE1CXRpfdaPEUHZ X-Proofpoint-UnRewURL: 4 URL's were un-rewritten MIME-Version: 1.0 Subject: RE: [PATCH] Enable multi process debugging for AIX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-18_14,2022-08-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208180066 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 18 Aug 2022 18:59:34 -0000 --_004_CH2PR15MB3544B307E98ACD47FDC59C28D66D9CH2PR15MB3544namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, Please find attached the patch. [See 0001-Enable-multi-process-debugging-fo= r-AIX.patch] The facts/steps to enable multi process debugging are :- * Enable PT_MULTI option in ptrace () call along with the process ID pa= rameter and the data parameter enabled. Usually one enables multi process d= ebugging 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 th= e waitpid () with the process ID. This can be used to detect a fork () even= t. * 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 w= ait event is generated by the parent in AIX. This is how we absorb the pare= nt 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. More about this can be read in the document https://www.ibm.com/docs/en/aix= /7.2?topic=3Dp-ptrace-ptracex-ptrace64-subroutine . I have left comments for the same and took into consideration the feedback = given last time. Thanks to our multi thread fix we need not do any changes = in aix-thread.c file any more like the last time. Kindly give me feedback on the same. Thanks and regards, Aditya. --------------------------------------------------- An example program is written below as follows with the gdb output: #include #include #include void hello_from_child(){ printf("Hello from child \n"); } void hello_from_parent(){ printf("Hello from Parent \n"); } int main(){ pid_t childpid; printf("I should not be printed after fork as I am executed \n"); childpid =3D fork(); if (childpid =3D=3D 0) hello_from_child(); else hello_from_parent(); return 0; } GDB Output:- (gdb) b hello_from_child Breakpoint 1 at 0x10000584: file test_fork.c, line 6. (gdb) set follow-fork-mode child (gdb) set detach-on-fork off (gdb) r Starting program: /home/test_fork I should not be printed after fork as I am executed [Attaching after process 23331156 fork to child process 23134700] [New inferior 2 (process 23134700)] [Switching to process 23134700] Thread 2.1 hit Breakpoint 1, hello_from_child () at test_fork.c:6 6 printf("Hello from child \n"); (gdb) c Continuing. Hello from child [Inferior 2 (process 23134700) exited normally] (gdb) The following are the results after running the "gdb.base" test suite:- With patch # of expected passes 26584 # of unexpected failures 3968 # of unexpected successes 1 # of expected failures 17 # of known failures 26 # of unresolved testcases 109 # of untested testcases 79 # of unsupported tests 62 # of paths in test names 1 # of duplicate test names 2 Without patch # of expected passes 26244 # of unexpected failures 4230 # of unexpected successes 1 # of expected failures 17 # of known failures 26 # of unresolved testcases 110 # of untested testcases 79 # of unsupported tests 62 # of paths in test names 1 # of duplicate test names 4 ________________________________ From: Simon Marchi Sent: 20 July 2022 00:21 To: Aditya Kamath1 ; Ulrich Weigand ; Aditya Kamath1 via Gdb-patches Cc: Sangamesh Mallayya Subject: [EXTERNAL] Re: [PATCH] Enable multi process debugging for AIX > From 1eab0bb05b1db09dfb98d31cc630722b40c081c4 Mon Sep 17 00:00:00 2001 > From: Aditya Vidyadhar Kamath > Date: Tue, 19 Jul 2022 10:39:00 -0500 > Subject: [PATCH] Enable multi process debugging for AIX > > The attached proposed patch adds multi process debugging feature in AIX. > > Till now AIX supported debugging only one inferior at a time, > > now we can be able to debug multi process. > > Users can use set follow fork mode in child or parent and > > set detach on fork on or off to enable/disable simultaneous debugging of = parent/child. There are a lot of unclear things about how AIX reports a fork event to the debugger. Is there some documentation on that somewhere? > --- > gdb/aix-thread.c | 4 ++++ > gdb/rs6000-aix-nat.c | 48 +++++++++++++++++++++++++++++++++++++++++--- > 2 files changed, 49 insertions(+), 3 deletions(-) > > diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c > index d47f5132592..f66b5904ae8 100644 > --- a/gdb/aix-thread.c > +++ b/gdb/aix-thread.c > @@ -1088,6 +1088,10 @@ aix_thread_target::wait (ptid_t ptid, struct targe= t_waitstatus *status, > pid-only ptids. */ > gdb_assert (ptid.is_pid ()); > > + /* In pd_activate to get PTHB_SUCCESS in pthread debug session init > + we need inferior_ptid set to update multiple threads. */ > + inferior_ptid =3D ptid; I would really prefer to avoid just setting inferior_ptid and hope things work magically, this is a step backwards. If some functions rely on the value of inferior_ptid on entry, change them so they don't rely on it anymore. > + > /* Check whether libpthdebug might be ready to be initialized. */ > if (!pd_active && status->kind () =3D=3D TARGET_WAITKIND_STOPPED > && status->sig () =3D=3D GDB_SIGNAL_TRAP) > diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c > index f604f7d503e..55844ca6dab 100644 > --- a/gdb/rs6000-aix-nat.c > +++ b/gdb/rs6000-aix-nat.c > @@ -91,10 +91,16 @@ class rs6000_nat_target final : public inf_ptrace_tar= get > > ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) ov= erride; > > + /* Fork detection related functions, For adding multi process debugging > + support. */ > + void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool) ove= rride; > + > + void mourn_inferior () override; > + > protected: > > - void post_startup_inferior (ptid_t ptid) override > - { /* Nothing. */ } > + void post_startup_inferior (ptid_t ptid) override; > + //{ /* Nothing. */ } > > private: > enum target_xfer_status > @@ -246,6 +252,22 @@ fetch_register (struct regcache *regcache, int regno) > } > } > > +void rs6000_nat_target::post_startup_inferior(ptid_t ptid){ > + rs6000_ptrace64(PT_MULTI,ptid.pid(),NULL,1,NULL); > +} > + > +void > +rs6000_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid, > + target_waitkind fork_kind, bool follow_child, > + bool detach_fork) > +{ > + inf_ptrace_target::follow_fork(child_inf, child_ptid, fork_kind, > + follow_child, detach_fork); > +} > + > +void rs6000_nat_target::mourn_inferior(){ > + inf_ptrace_target::mourn_inferior(); > +} Maybe I'm mistaken, but the two methods above seem unnecessary, since inf_ptrace_target is the direct base of rs6000_nat_target. > /* Store register REGNO back into the inferior. */ > > static void > @@ -539,8 +561,28 @@ rs6000_nat_target::wait (ptid_t ptid, struct target_= waitstatus *ourstatus, > if (status =3D=3D 0x57c) > ourstatus->set_loaded (); > /* signal 0. I have no idea why wait(2) returns with this status word= . */ > - else if (status =3D=3D 0x7f) > + /* 0x17f and 0x137f in hexadecimal are status returned if > + if we follow parent, > + a switch is made to a child post parent execution > + and child continues its execution [user switches to child and > + presses continue]. */ > + else if (status =3D=3D 0x7f || status =3D=3D 0x17f || status =3D=3D 0= x137f) > ourstatus->set_spurious (); > + /* When a process completes execution and any fork process exits statu= s. */ > + else if (WIFEXITED(status)) > + ourstatus->set_exited(0); Why is WIFEXITED now handled here? It used to be handled in the host_status_to_waitstatus call, which is still below. Why doesn't that work anymore? Also, why pass a literal 0 as the exit code, can't it be something else? > + /* 57e is the status number in AIX for fork event. > + If a breakpoint is attached to a parent or child then on fork, > + or after fork, once a breakpoint hits and the next or continue is > + pressed, post breakpoint status is 1406 but we need not set status > + to set_forked(), hence the condition find_inferior_pid() to set > + fork status only if a child is born. */ > + else if (status =3D=3D 0x57e && find_inferior_pid(this,pid)=3D=3D null= ptr) These magic numbers make the code really difficult to follow. Is this really the way AIX intends users to use the status that waitpid returns? Isn't there a set of macros to inspect it? Worst case, I suppose we can make our own, like: #define AIX_EVENT_FORK 0x57e That would already help. > + { > + ourstatus->set_forked (ptid_t(pid)); > + /* On a fork event return parent process ID to target wait */ > + return ptid_t(current_inferior()->pid); You should not use current_inferior() here, any inferior could be the current one on entry. Not necessarily the one that has forked. How does AIX document the events sent to the ptracer in case of a fork? We need to be able to figure out the pid of the parent and the pid of the child before returning the fork event to the core. On some platforms, like FreeBSD, the kernel sends separate events for the parent and the child, so we need a bit of special handling to consume both events: https://gitlab.com/gnutools/binutils-gdb/-/blob/9afca381e2e46ccee433ce090= 01506e7683b273f/gdb/fbsd-nat.c#L1003-1035 I don't know if that's the case here, but it sounds similar. Simon --_004_CH2PR15MB3544B307E98ACD47FDC59C28D66D9CH2PR15MB3544namp_ Content-Type: application/octet-stream; name="0001-Enable-multi-process-debugging-for-AIX.patch" Content-Description: 0001-Enable-multi-process-debugging-for-AIX.patch Content-Disposition: attachment; filename="0001-Enable-multi-process-debugging-for-AIX.patch"; size=4511; creation-date="Thu, 18 Aug 2022 18:58:48 GMT"; modification-date="Thu, 18 Aug 2022 18:59:25 GMT" Content-Transfer-Encoding: base64 RnJvbSA0MTEzNGYyMWM2MzAxN2YzNjQzNTM2MzBkNjBmN2ZlZDEwNmQ5NDczIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBZGl0eWEgVmlkeWFkaGFyIEthbWF0aCA8QWRpdHlhLkthbWF0 aDFAaWJtLmNvbT4KRGF0ZTogVGh1LCAxOCBBdWcgMjAyMiAxMzo1MDoyMiAtMDUwMApTdWJqZWN0 OiBbUEFUQ0hdIEVuYWJsZS1tdWx0aS1wcm9jZXNzLWRlYnVnZ2luZy1mb3ItQUlYCgotLS0KIGdk Yi9yczYwMDAtYWl4LW5hdC5jIHwgODAgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysrLS0KIDEgZmlsZSBjaGFuZ2VkLCA3NyBpbnNlcnRpb25zKCspLCAzIGRlbGV0aW9u cygtKQoKZGlmZiAtLWdpdCBhL2dkYi9yczYwMDAtYWl4LW5hdC5jIGIvZ2RiL3JzNjAwMC1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gPSBob3N0X3N0YXR1c190b193YWl0c3RhdHVzIChzdGF0dXMpOwotLSAK Mi4zMS4xCgo= --_004_CH2PR15MB3544B307E98ACD47FDC59C28D66D9CH2PR15MB3544namp_--