From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ibv1EQwUzmpU7gAAWB0awg (envelope-from ) for ; Tue, 13 Oct 2026 07:20:44 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pgXf+3Dc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 242A31E051; Tue, 13 Oct 2026 07:20:44 -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,FREEMAIL_FROM,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 9DDE81E04E for ; Tue, 13 Oct 2026 07:20:39 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2D0A4BA7998 for ; Tue, 13 Oct 2026 11:20:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2D0A4BA7998 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pgXf+3Dc Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 691754BA23C9 for ; Tue, 13 Oct 2026 11:20:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 691754BA23C9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 691754BA23C9 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791890405; cv=none; b=jgNxiWy0rrjnOamx0EDhNPRsA0actUhve/QcOS/Ilr5CJvQbY33sGwfTCJYSu10nxR+tfOyZAvK9lQKuo5i/1itYjZ5HoRzURjHvatNVrTwWRmGwkEmsvgokeIVgzw6k6rfTnt3HydI/0YE2wkq7FFI0N3DC57gDdKZqhxC6QLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791890405; c=relaxed/simple; bh=CJvMWwoflIbvCftzMqGiF+T/fCY8K+hEkfg+AoWCYc4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rzLFYjYUFDkvBO8BQ0kSyXRRLDr0iRIhQfBAC5LO4p8+rikfuEGD2pAKhumzFhW3KcqOGuyYtKdC2b5FywNKdhP8mrlG0ePnp+XfsZnX185yrBkMGLuDLeWhv+zm3jbga+WHpbvXq857OoHIyXk1bj7q0XAdeQ5WAWRHX+vK3v4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pgXf+3Dc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 691754BA23C9 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-892734ce7e6so979382b3a.1 for ; Tue, 13 Oct 2026 04:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791890404; x=1792495204; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=PEOpoXbo8w8crx3GpL6Xi/YPR6cfIyk7etje4bPU6xY=; b=pgXf+3DcnzTVJaUIVjfaX+5j4mj4xWyH4xrlIEVkn5uXd5mZPnYDog+4cSrTRbaEtw pqda/Z3n/YQ6hhfq+X0O5oeUNkLPughdWFxpKzIb8vpB+UUxRFOQbarWKE4cLRGIkLAD Vjya3faq31h5MRap9vHGmR9kSFi8oC/eL7jWvcrbeRRRXvJXlzJdT3pX2YFUy8AiS3ZM OjndjtEEF8YbyDiXMnM7MU4EXpLqSLHNtnLkwl4FBYC5uJAgQhEu/DRtDXDw0cYlTGm+ 33XDi4Xradnth3Vf3w0CG8k4UyUqBq8/TwhFyKUds2sIYNz8Nlz7floMioi1n8LOvkzU yMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791890404; x=1792495204; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PEOpoXbo8w8crx3GpL6Xi/YPR6cfIyk7etje4bPU6xY=; b=DO7HrjssFnyCavsXJbWq3HDngj1XlIBOLMj7r+vGFd2DoDjRKlrT5u8jCSWppaKQ8P JrfRtWr5MlX0kiIpxHzOCU/TmhvfJI0g1Wma2vhe/BvnlsSUygs7m3l/1boQReWGJdXF HdlCva2vBXyma1Shyt1+E7GqTfiYLBoetAT23W1LaAykbSILlzDNVrK9joxxD+oNN9uF +KhUthww7xLn+/krYiPx650iOzFjjm4dzjNlzOPrwuXLYNOKNoCSY3WvvSAXHm+EcZaq 4Pr6qT7haAmf9/tT2IPBBDpWSQzjDCsl6JRpXiJPle8fTNtR5rss+3rf18BzbmN3Dxi6 HtEw== X-Gm-Message-State: AFq9FYIMZ+bwJKpzOuFwWDWQElGJwMQIPEtnTTi0rjPaORYHPDNmK+h9 6b8rGYQvMaJRFkPdVxKHHGA+ixAUf6O4A3f0tTg0i2xuNQMbZqGTt6fRrrXQr+4U X-Gm-Gg: AYBFou2bBcmpbIqeTrq6YOlZnbtWeL+1+1gHqP+1QjqA+7/QuPkPYLtMaINSaQ68B6u 3hsFxreIL9Fm9PnmwDTiaYpkSJWzSjZC6BGxga1OUVyF+axI8h3bAJKTG6ZGBD28J+VEstBcXJ/ lwayj5Jt+kOtAKJgXo3wP2Qg/tQcVd0itCIvpd1dZAYrWfdipzKxkquxYM7o+lJKGKhRAcQ0EaP RIeaS7vtMID4rpFf7KbAIhggD49oD1kTROzsaU7AKudnHl9DT4x3BAf8j2pwjDpekJln0ondhgn cpdrP27OeFtMIVuiCq+BJPzBxrlKtktCto33r/qhMGJbweiPMt1NQcZXY1wVTnjz3blpdBW2cAq jbst3mCSKHdrSWwI7jHx9KHifKgmrWkVbrxxMmtfCvUByoeuLx2XVWCuxpKLmAIGLzrZ8QmIWc7 rLgQdb0BoQLwNQEnBj2JAlGWgFrlA8zEtuh5/Xl1wqceZaG6WD8r9V3adf2MDy+peJrgNmnQHM7 uojIy4hbFvvH/5qEBzJ6Ts+flLCK30FXjSL X-Received: by 2002:a05:6a00:90a8:b0:88b:76e3:cd8a with SMTP id d2e1a72fcca58-897c76e44a7mr10449618b3a.38.1791890404168; Tue, 13 Oct 2026 04:20:04 -0700 (PDT) Received: from dhcp-9-123-1-12.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-896c469ea49sm4858351b3a.53.2026.10.13.04.20.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Oct 2026 04:20:03 -0700 (PDT) From: Aditya Vidyadhar Kamath To: ulrich.weigand@de.ibm.com, simon.marchi@polymtl.ca, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com, Aditya Vidyadhar Kamath Subject: [PATCH v5 1/4] Remove stale legacy code from rs6000-aix-nat.c file. Date: Tue, 13 Oct 2026 16:49:15 +0530 Message-ID: <20261013111917.68981-2-akamath996@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Aditya Vidyadhar Kamath GDB on AIX is built in 64-bit mode only. A 64-bit program cannot link against the legacy 32-bit ptrace () and ptracex () symbols; trying to do so 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 A 64-bit GDB must use ptrace64 () exclusively. The rs6000_ptrace32 () and rs6000_ptrace64 () wrappers conditionally called ptrace (), ptracex () or ptrace64 () and relied on the ARCH3264 macro. With 32-bit GDB builds deprecated and ptrace64 () available on AIX 7.2 and 7.3, neither the wrappers nor ARCH3264 are needed. The IBM documentation for ptrace64 () https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-ptracex-ptrace64-subroutine says that calling it with a 32-bit debuggee makes GPR/SPR requests fail with EIO. Testing shows that ptrace64 () handles 32-bit debuggees correctly: 1: For 32-bit debuggees, PT_READ_GPR returns the register value as the return value of ptrace64 (), and PT_WRITE_GPR takes the register value by value in the data argument. 2: For 64-bit debuggees, PT_READ_GPR and PT_WRITE_GPR use an 8-byte buffer passed as the 5th argument. 3: PT_READ_FPR and PT_WRITE_FPR work for both 32-bit and 64-bit debuggees. The changes are: 1: Remove rs6000_ptrace32 () and rs6000_ptrace64 () and call ptrace64 () directly. 2: Simplify ARCH64 () to check the inferior register size, and remove the ARCH3264 macro. 3: Move the duplicated kernel thread ID lookup for the VSX and AltiVec requests into get_thread_id (). 4: Remove the dead "#if 0" block in fetch_register. Testing I ran the gdb.base testsuite before and after this patch, from the gdb/testsuite directory, with 64-bit and 32-bit test programs. 64-bit: 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"' 32-bit (same command without -maix64): 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" \ CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf"' 64-bit 32-bit before after before after expected passes 41792 41802 41687 41541 unexpected failures 2346 2343 2302 2294 unexpected successes 1 1 1 1 expected failures 17 17 15 15 known failures 30 30 30 30 unresolved testcases 30 29 11 86 untested testcases 104 104 107 107 unsupported tests 179 178 179 179 The number of unexpected failures does not go up in either mode. The failures that remain were there before this patch. I grouped the 64-bit failures by test file to check that none of them are in code touched here. Group Failures Test files --------------------------------- -------- -------------------------- Casts in whatis-ptype-typedefs 1060 whatis-ptype-typedefs (gdb reports "Cannot access memory at address 0xefffffff") Type printing, alignment, value 336 max-depth-c, max-depth-c++, size and print limits align-c, align-c++, limited-length, max-value-size, printcmds Inferior function calls, stores 208 nodebug, store, and no-debug-info symbols return-nodebug, callfuncs, recurse, backtrace-through-cu-nodebug fork, vfork and follow-exec 158 vfork-follow-parent, multi-forks, foll-fork, catch-fork-kill, fork-running-state, kill-detach-inferiors-cmd, and 3 more Signals 98 sigstep, catch-signal, exitsignal, sigaltstack, and 4 more Attach, background execution and 108 attach, infcall-timeout, interrupt (mostly timeouts) cli-suppress-notification, bg-execution-repeat, dprintf-detach, quit-live, and 14 more Everything else (83 test files) 375 dump (34), bp-permanent (24), skip-tree (22), value-history-unavailable (19), memattr (17), find (16), list-ambiguous and -readnow (28), and others --------------------------------- -------- Total 2343 Similarly even 32 bit failures as the above table. --- gdb/rs6000-aix-nat.c | 207 ++++++++++--------------------------------- 1 file changed, 47 insertions(+), 160 deletions(-) diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c index 276df378824..3d1cf2542db 100644 --- a/gdb/rs6000-aix-nat.c +++ b/gdb/rs6000-aix-nat.c @@ -60,24 +60,9 @@ /* Header files for alti-vec reg. */ #include -/* On AIX4.3+, sys/ldr.h provides different versions of struct ld_info for - debugging 32-bit and 64-bit processes. Define a typedef and macros for - accessing fields in the appropriate structures. */ - -/* In 32-bit compilation mode (which is the only mode from which ptrace() - works on 4.3), __ld_info32 is #defined as equivalent to ld_info. */ - -#if defined (__ld_info32) || defined (__ld_info64) -# define ARCH3264 -#endif - /* Return whether the current architecture is 64-bit. */ -#ifndef ARCH3264 -# define ARCH64() 0 -#else -# define ARCH64() (register_size (current_inferior ()->arch (), 0) == 8) -#endif +#define ARCH64() (register_size (current_inferior ()->arch (), 0) == 8) class rs6000_nat_target final : public inf_ptrace_target { @@ -246,42 +231,20 @@ regmap (struct gdbarch *gdbarch, int regno, int *isfloat) return -1; } -/* Call ptrace(REQ, ID, ADDR, DATA, BUF). */ +/* Return the thread ID of the first kernel thread in PID, or 0 on + failure. Used to call PTT_* requests which require a tid rather + than a pid. */ -static int -rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf) +static tid64_t +get_thread_id (pid_t pid) { -#ifdef HAVE_PTRACE64 - int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf); -#else - int ret = ptrace (req, id, (int *)addr, data, buf); -#endif -#if 0 - printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n", - req, id, (unsigned int)addr, data, (unsigned int)buf, ret); -#endif - return ret; -} - -/* Call ptracex(REQ, ID, ADDR, DATA, BUF). */ + struct thrdentry64 thrdentry; + tid64_t thrd_i = 0; -static int -rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf) -{ -#ifdef ARCH3264 -# ifdef HAVE_PTRACE64 - int ret = ptrace64 (req, id, addr, data, (PTRACE_TYPE_ARG5) buf); -# else - int ret = ptracex (req, id, addr, data, (PTRACE_TYPE_ARG5) buf); -# endif -#else - int ret = 0; -#endif -#if 0 - printf ("rs6000_ptrace64 (%d, %d, %s, %08x, 0x%x) = 0x%x\n", - req, id, hex_string (addr), data, (unsigned int)buf, ret); -#endif - return ret; + if (getthrds64 (pid, &thrdentry, sizeof (struct thrdentry64), + &thrd_i, 1) == 1) + return thrdentry.ti_tid; + return 0; } /* Store the vsx registers. */ @@ -292,32 +255,21 @@ store_vsx_register_aix (struct regcache *regcache, int regno) int ret; struct gdbarch *gdbarch = regcache->arch (); ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct thrdentry64 thrdentry; __vsx_context_t vsx; pid_t pid = inferior_ptid.pid (); - tid64_t thrd_i = 0; - - if (getthrds64(pid, &thrdentry, sizeof(struct thrdentry64), - &thrd_i, 1) == 1) - thrd_i = thrdentry.ti_tid; + tid64_t thrd_i = get_thread_id (pid); memset(&vsx, 0, sizeof(__vsx_context_t)); if (__power_vsx() && thrd_i > 0) { - if (ARCH64 ()) - ret = rs6000_ptrace64 (PTT_READ_VSX, thrd_i, (long long) &vsx, 0, 0); - else - ret = rs6000_ptrace32 (PTT_READ_VSX, thrd_i, (int *)&vsx, 0, 0); + ret = ptrace64 (PTT_READ_VSX, thrd_i, (long long) &vsx, 0, 0); if (ret < 0) return; regcache->raw_collect (regno, &(vsx.__vsr_dw1[0])+ regno - tdep->ppc_vsr0_upper_regnum); - if (ARCH64 ()) - ret = rs6000_ptrace64 (PTT_WRITE_VSX, thrd_i, (long long) &vsx, 0, 0); - else - ret = rs6000_ptrace32 (PTT_WRITE_VSX, thrd_i, (int *) &vsx, 0, 0); + ret = ptrace64 (PTT_WRITE_VSX, thrd_i, (long long) &vsx, 0, 0); if (ret < 0) perror_with_name (_("Unable to write VSX registers after reading it")); @@ -332,32 +284,21 @@ store_altivec_register_aix (struct regcache *regcache, int regno) int ret; struct gdbarch *gdbarch = regcache->arch (); ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct thrdentry64 thrdentry; __vmx_context_t vmx; pid_t pid = inferior_ptid.pid (); - tid64_t thrd_i = 0; - - if (getthrds64(pid, &thrdentry, sizeof(struct thrdentry64), - &thrd_i, 1) == 1) - thrd_i = thrdentry.ti_tid; + tid64_t thrd_i = get_thread_id (pid); memset(&vmx, 0, sizeof(__vmx_context_t)); if (__power_vmx() && thrd_i > 0) { - if (ARCH64 ()) - ret = rs6000_ptrace64 (PTT_READ_VEC, thrd_i, (long long) &vmx, 0, 0); - else - ret = rs6000_ptrace32 (PTT_READ_VEC, thrd_i, (int *) &vmx, 0, 0); + ret = ptrace64 (PTT_READ_VEC, thrd_i, (long long) &vmx, 0, 0); if (ret < 0) return; regcache->raw_collect (regno, &(vmx.__vr[0]) + regno - tdep->ppc_vr0_regnum); - if (ARCH64 ()) - ret = rs6000_ptrace64 (PTT_WRITE_VEC, thrd_i, (long long) &vmx, 0, 0); - else - ret = rs6000_ptrace32 (PTT_WRITE_VEC, thrd_i, (int *) &vmx, 0, 0); + ret = ptrace64 (PTT_WRITE_VEC, thrd_i, (long long) &vmx, 0, 0); if (ret < 0) perror_with_name (_("Unable to store AltiVec register after reading it")); } @@ -385,22 +326,14 @@ supply_vrregset_aix (struct regcache *regcache, __vmx_context_t *vmx) static void fetch_altivec_registers_aix (struct regcache *regcache) { - struct thrdentry64 thrdentry; __vmx_context_t vmx; pid_t pid = current_inferior ()->pid; - tid64_t thrd_i = 0; - - if (getthrds64(pid, &thrdentry, sizeof(struct thrdentry64), - &thrd_i, 1) == 1) - thrd_i = thrdentry.ti_tid; + tid64_t thrd_i = get_thread_id (pid); memset(&vmx, 0, sizeof(__vmx_context_t)); if (__power_vmx() && thrd_i > 0) { - if (ARCH64 ()) - rs6000_ptrace64 (PTT_READ_VEC, thrd_i, (long long) &vmx, 0, 0); - else - rs6000_ptrace32 (PTT_READ_VEC, thrd_i, (int *) &vmx, 0, 0); + ptrace64 (PTT_READ_VEC, thrd_i, (long long) &vmx, 0, 0); supply_vrregset_aix (regcache, &vmx); } } @@ -423,38 +356,27 @@ supply_vsxregset_aix (struct regcache *regcache, __vsx_context_t *vsx) static void fetch_vsx_registers_aix (struct regcache *regcache) { - struct thrdentry64 thrdentry; __vsx_context_t vsx; pid_t pid = current_inferior ()->pid; - tid64_t thrd_i = 0; - - if (getthrds64(pid, &thrdentry, sizeof(struct thrdentry64), - &thrd_i, 1) == 1) - thrd_i = thrdentry.ti_tid; + tid64_t thrd_i = get_thread_id (pid); memset(&vsx, 0, sizeof(__vsx_context_t)); if (__power_vsx() && thrd_i > 0) { - if (ARCH64 ()) - rs6000_ptrace64 (PTT_READ_VSX, thrd_i, (long long) &vsx, 0, 0); - else - rs6000_ptrace32 (PTT_READ_VSX, thrd_i, (int *) &vsx, 0, 0); + ptrace64 (PTT_READ_VSX, thrd_i, (long long) &vsx, 0, 0); supply_vsxregset_aix (regcache, &vsx); } } void rs6000_nat_target::post_startup_inferior (ptid_t ptid) { - /* In AIX to turn on multi process debugging in ptrace PT_MULTI is the option to be passed, with the process ID which can fork () and - the data parameter [fourth parameter] must be 1. */ + the data parameter [fourth parameter] must be 1. ptrace64 is + used for both 32-bit and 64-bit inferiors. */ - if (!ARCH64 ()) - rs6000_ptrace32 (PT_MULTI, ptid.pid(), 0, 1, 0); - else - rs6000_ptrace64 (PT_MULTI, ptid.pid(), 0, 1, 0); + ptrace64 (PT_MULTI, ptid.pid (), 0, 1, 0); } void @@ -477,10 +399,7 @@ rs6000_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid, if (detach_fork && !follow_child) { - if (ARCH64 ()) - rs6000_ptrace64 (PT_DETACH, child_ptid.pid (), 0, 0, 0); - else - rs6000_ptrace32 (PT_DETACH, child_ptid.pid (), 0, 0, 0); + ptrace64 (PT_DETACH, child_ptid.pid (), 0, 0, 0); } } @@ -528,7 +447,7 @@ fetch_register (struct regcache *regcache, int regno) /* Floating-point registers. */ if (isfloat) - rs6000_ptrace32 (PT_READ_FPR, pid, addr, nr, 0); + ptrace64 (PT_READ_FPR, pid, (long long) addr, nr, 0); /* Bogus register number. */ else if (nr < 0) @@ -543,31 +462,24 @@ fetch_register (struct regcache *regcache, int regno) /* Fixed-point registers. */ else { - if (!ARCH64 ()) - *addr = rs6000_ptrace32 (PT_READ_GPR, pid, (int *) nr, 0, 0); - else + if (ARCH64 ()) { - /* PT_READ_GPR requires the buffer parameter to point to long long, - even if the register is really only 32 bits. */ + /* The buffer parameter must point to a long long area. */ long long buf; - rs6000_ptrace64 (PT_READ_GPR, pid, nr, 0, &buf); + ptrace64 (PT_READ_GPR, pid, nr, 0, (PTRACE_TYPE_ARG5) &buf); if (register_size (gdbarch, regno) == 8) memcpy (addr, &buf, 8); else *addr = buf; } + else + *addr = ptrace64 (PT_READ_GPR, pid, nr, 0, 0); } if (!errno) regcache->raw_supply (regno, (char *) addr); else - { -#if 0 - /* FIXME: this happens 3 times at the start of each 64-bit program. */ - perror (_("ptrace read")); -#endif - errno = 0; - } + errno = 0; } /* Store register REGNO back into the inferior. */ @@ -602,7 +514,7 @@ store_register (struct regcache *regcache, int regno) /* Floating-point registers. */ if (isfloat) - rs6000_ptrace32 (PT_WRITE_FPR, pid, addr, nr, 0); + ptrace64 (PT_WRITE_FPR, pid, (long long) addr, nr, 0); /* Bogus register number. */ else if (nr < 0) @@ -616,22 +528,18 @@ store_register (struct regcache *regcache, int regno) /* Fixed-point registers. */ else { - /* The PT_WRITE_GPR operation is rather odd. For 32-bit inferiors, - the register's value is passed by value, but for 64-bit inferiors, - the address of a buffer containing the value is passed. */ - if (!ARCH64 ()) - rs6000_ptrace32 (PT_WRITE_GPR, pid, (int *) nr, *addr, 0); - else + if (ARCH64 ()) { - /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte - area, even if the register is really only 32 bits. */ + /* The buffer parameter must point to an 8-byte area. */ long long buf; if (register_size (gdbarch, regno) == 8) memcpy (&buf, addr, 8); else buf = *addr; - rs6000_ptrace64 (PT_WRITE_GPR, pid, nr, 0, &buf); + ptrace64 (PT_WRITE_GPR, pid, nr, 0, (PTRACE_TYPE_ARG5) &buf); } + else + ptrace64 (PT_WRITE_GPR, pid, nr, *addr, 0); } if (errno) @@ -760,7 +668,6 @@ rs6000_nat_target::xfer_partial (enum target_object object, ULONGEST *xfered_len) { pid_t pid = inferior_ptid.pid (); - int arch64 = ARCH64 (); switch (object) { @@ -801,14 +708,8 @@ rs6000_nat_target::xfer_partial (enum target_object object, < rounded_offset + sizeof (PTRACE_TYPE_RET))) { /* Need part of initial word -- fetch it. */ - if (arch64) - buffer.word = rs6000_ptrace64 (PT_READ_I, pid, - rounded_offset, 0, NULL); - else - buffer.word = rs6000_ptrace32 (PT_READ_I, pid, - (int *) (uintptr_t) - rounded_offset, - 0, NULL); + buffer.word = ptrace64 (PT_READ_I, pid, + rounded_offset, 0, NULL); } /* Copy data to be written over corresponding part of @@ -817,13 +718,8 @@ rs6000_nat_target::xfer_partial (enum target_object object, writebuf, partial_len); errno = 0; - if (arch64) - rs6000_ptrace64 (PT_WRITE_D, pid, - rounded_offset, buffer.word, NULL); - else - rs6000_ptrace32 (PT_WRITE_D, pid, - (int *) (uintptr_t) rounded_offset, - buffer.word, NULL); + ptrace64 (PT_WRITE_D, pid, + rounded_offset, buffer.word, NULL); if (errno) return TARGET_XFER_EOF; } @@ -831,13 +727,8 @@ rs6000_nat_target::xfer_partial (enum target_object object, if (readbuf) { errno = 0; - if (arch64) - buffer.word = rs6000_ptrace64 (PT_READ_I, pid, - rounded_offset, 0, NULL); - else - buffer.word = rs6000_ptrace32 (PT_READ_I, pid, - (int *)(uintptr_t)rounded_offset, - 0, NULL); + buffer.word = ptrace64 (PT_READ_I, pid, + rounded_offset, 0, NULL); if (errno) return TARGET_XFER_EOF; @@ -1014,12 +905,8 @@ rs6000_ptrace_ldinfo (ptid_t ptid) while (1) { - if (ARCH64 ()) - rc = rs6000_ptrace64 (PT_LDINFO, pid, (unsigned long) ldi.data (), - ldi.size (), NULL); - else - rc = rs6000_ptrace32 (PT_LDINFO, pid, (int *) ldi.data (), - ldi.size (), NULL); + rc = ptrace64 (PT_LDINFO, pid, (long long) ldi.data (), ldi.size (), + NULL); if (rc != -1) break; /* Success, we got the entire ld_info data. */ -- 2.51.2