From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1+ZRLCe8w2oNDz0AWB0awg (envelope-from ) for ; Mon, 05 Oct 2026 11:03:03 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=JxZEaehO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 989F41E04E; Mon, 05 Oct 2026 11:03:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 363271E04E for ; Mon, 05 Oct 2026 11:03:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 594B04B9DB71 for ; Mon, 5 Oct 2026 15:03:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 594B04B9DB71 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=JxZEaehO Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 34BC54BA23F8 for ; Mon, 5 Oct 2026 15:02:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34BC54BA23F8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 34BC54BA23F8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791212556; cv=none; b=QzFP3cibQsBv9DMtdslLfB2U65MV+iYjdICaQc3aP59zHXuYPCiC6JQSwlSoQHr/U5e0gH5lGbx+3JWaLvhkmABZgyT5WTnhme6tSzETQiMkG9vg0uVesk42sBaVhDzXTyqm2njfAdj+T/JRuPr8fXQ+9LdOYPQQ1Y5RJ/xktDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791212556; c=relaxed/simple; bh=ByvB0+7BHeqYW47/aQk9vHRDNAklb7U2LdQ34tH49q8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Mqxvs7s8kuN3tbjGdopCXCApir0Y5OGehOgeiu7g839eAPRsxxQU3YIAP/6ywHfcjw2q2DhcyQDp5kQuBT9tA2/beZNHSD/4miYqiPioBeDjQpSITCw5IyJC+pRhJ4jt47Jka1mHZHhjjbubsf+DiYVjaVgQZxKdmu/9nj6YmLE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=JxZEaehO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34BC54BA23F8 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 695F2O5Q200675 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 5 Oct 2026 11:02:29 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 695F2O5Q200675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1791212552; bh=k0uEdiLGBAatFIQLh4kvsBDYqZYaxDxqCfRqrB/KRvg=; h=Date:Subject:To:Cc:From:In-Reply-To:From; b=JxZEaehOi1e7FvezPaZfXNl37jMZM2+Nhd5acc9INQN0ouP6fC6QJ1zsU6xWGxn+g QQrOvJQd54HC6T16u6IdZLVmsCkPW+19MMTT/eSS2B4MwhBGPLt6bn/dtrHrWOMMUo t1Z4CVQwt6Bf6SZYrTrvZQcKUYeIvK9Fi4g+lazn+5UaNxOj1y2SgL6T2fhi9E6ega xbUmR8TJDa05DEUGiNbZFgZ6q9DfOP3J+Rgg0RHWi+wHRRDxsJXVOxw3U3kmwpex4c KwsEXwnKy8G6I6fQUFGz+AI2OqQE/zf05XU/wYoIZxxxzIcP/sE6lVl24ySKMi0KyH 5bwtW031dMCLQ== Received: by simark.ca (Postfix) id F3DBF1E04E; Mon, 05 Oct 2026 11:02:23 -0400 (EDT) Message-ID: Date: Mon, 5 Oct 2026 11:02:23 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/4] Remove stale legacy code from rs6000-aix-nat.c file. To: Aditya Vidyadhar Kamath , ulrich.weigand@de.ibm.com, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com References: <20261005121609.31787-2-akamath996@gmail.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20261005121609.31787-2-akamath996@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 5 Oct 2026 15:02:24 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/5/26 8:16 AM, Aditya Vidyadhar Kamath wrote: > From: Aditya Vidyadhar Kamath > > GDB on AIX is built in 64 bit mode only. > > As per > https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-ptracex-ptrace64-subroutine > > though ptrace64 will also support 32-bit debugees if debugee is a 32 bit process, > the options that refer to GPRs or SPRs fail with errno = EIO. The existing code does this: if (!ARCH64 ()) *addr = rs6000_ptrace32 (PT_READ_GPR, pid, (int *) nr, 0, 0); So a 64-bit GDB debugging a 32-bit inferior, before this patch, would go into rs6000_ptrace32, which has: #ifdef HAVE_PTRACE64 int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf); #else int ret = ptrace (req, id, (int *)addr, data, buf); #endif So today it would get PT_READ_GPR using ptrace64, right? Does it already fail today? It would be clear that up first. We don't want this patch to mix removing legacy code and bug fixing. Note that while it uses ptrace64 in both cases, it uses it differently. When reading a GPR from a 64-bit process, the output is through an 8-byte buffer passed as an out parameter (the 5th parameter). When reading a GPR from a 32-bit process, the output is the return value. For the record, I asked Claude to test ptrace64 against both a 64-bit and a 32-bit debuggee, and it appears to work in both cases. But this is on AIX 7.3 (7300-01-02-2320), so maybe the behavior is different on 7.2. > This is something I have left in the comments of the code as well, so we do not miss > it while testing. > > When I built GDB as a 64 bit AIX application [Using ptrace () for 32 bit inferior debugee] > to just test, linking fails with: > > CXXLD gdb > ld: 0711-317 ERROR: Undefined symbol: .ptrace > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. > collect2: error: ld returned 8 exit status > gmake[2]: *** [Makefile:2367: gdb] Error 1 It's strange that this happens, since the doc clearly states that you can use ptrace in 64-bit applications. > > This clearly shows from AIX 7.2, the standard ptrace system call symbol is not > exported in 64-bit mode; 64 bit mode must use ptrace64 exclusively which is what > this patch does. > > As document mentioned, > ptrace: 32- or 64-bit GDB, 32-bit inferior > ptracex: 32-bit GDB, 64-bit inferior > ptrace64: 64-bit GDB, 64-bit inferior > > This is right, This sentence is incomplete. > > Legacy rs6000_ptrace32 and rs6000_ptrace64 wrappers conditionally called > ptrace/ptracex/ptrace64 and relied on ARCH3264 macro. This macro is now not needed. > We will only use ptrace64 going forward. > > This patch modernises rs6000-aix-nat.c for AIX 7.2+/7.3+ > > Here are my thoughts during implementation. > 1: Remove rs6000_ptrace32 () and rs6000_ptrace64 () completey. We will only use > ptrace64 for all operations. No ptracex/ptrace any more since GDB will not be > built in 32 bit mode. > 2: Wrote get_thread_id () helper to obtain kernel thread ID via getthrds64 () > 3: For a 32 bit debugee where process-level PT_READ_GPR, PT_WRITE_GPR and > PT_READ_FPR/PT_WRITE_FPR fail with EIO when called from 64 bit GDB via ptrace64 () > let us use thread-level PTT_READ_GPRS/PTT_WRITE_GPRS and PTT_READ_SPRS/PTT_WRITE_SPRS. > Likewise, PTT_READ_FPRS/PTT_WRITE_FPRS. > > I also ran tests for for both 64 bit and 32 bit mode. First result is 64 bit mode. Second summary is 32 bit. Ran the command in gdb/testsuite directory. > Command used: gmake check RUNTESTFLAGS='--directory=gdb.base CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"' > > Before this patch: > === gdb Summary === > # of unexpected core files 1 > # of expected passes 41792 > # of unexpected failures 2346 > # of unexpected successes 1 > # of expected failures 17 > # of known failures 30 > # of unresolved testcases 30 > # of untested testcases 104 > # of unsupported tests 179 > # of paths in test names 7 > # of duplicate test names 2 > > -------------------------------------------------- > === gdb Summary === > > # of unexpected core files 1 > # of expected passes 41687 > # of unexpected failures 2302 > # of unexpected successes 1 > # of expected failures 15 > # of known failures 30 > # of unresolved testcases 11 > # of untested testcases 107 > # of unsupported tests 179 > # of paths in test names 7 > # of duplicate test names 2 > > After this patch: > === gdb Summary === > > # of unexpected core files 1 > # of expected passes 41617 > # of unexpected failures 2297 > # of unexpected successes 1 > # of expected failures 15 > # of known failures 30 > # of unresolved testcases 10 > # of untested testcases 108 > # of unsupported tests 179 > # of paths in test names 7 > # of duplicate test names 2 > > ------------------------------------ > === gdb Summary === > > # of unexpected core files 1 > # of expected passes 41796 > # of unexpected failures 2346 > # of unexpected successes 1 > # of expected failures 17 > # of known failures 30 > # of unresolved testcases 31 > # of untested testcases 105 > # of unsupported tests 179 > # of paths in test names 7 > # of duplicate test names 2 Not sure what to think of those test results, it seems like some numbers got worse. Are you sure the 64 and 32 bit summaries are not swapped in one of those? Simon