From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10297 invoked by alias); 12 May 2007 00:20:54 -0000 Received: (qmail 10286 invoked by uid 22791); 12 May 2007 00:20:53 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate8.de.ibm.com (HELO mtagate8.de.ibm.com) (195.212.29.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 12 May 2007 00:20:51 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate8.de.ibm.com (8.13.8/8.13.8) with ESMTP id l4C0Kmon149816 for ; Sat, 12 May 2007 00:20:48 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l4C0Km9Z4137142 for ; Sat, 12 May 2007 02:20:48 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l4C0Kmdu028252 for ; Sat, 12 May 2007 02:20:48 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id l4C0KmCm028249 for ; Sat, 12 May 2007 02:20:48 +0200 Message-Id: <200705120020.l4C0KmCm028249@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 12 May 2007 02:20:48 +0200 Subject: [commit] Eliminate read_register et al from ia64/i386-linux-nat.c To: gdb-patches@sourceware.org Date: Sat, 12 May 2007 00:20:00 -0000 From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-05/txt/msg00217.txt.bz2 Hello, the only two -nat files using read_register_pid and write_register_pid are i386-linux-nat.c and ia64-linux-nat.c. This patch removes those uses and replaces them by regcache functions. It does introduce references to current_regcache instead; I'm planning to remove all of those in a follow-on patch. Tested on i386-linux and ia64-linux. Committed to mainline. Bye, Ulrich ChangeLog: * i386-linux-nat.c (i386_linux_resume): Use regcache functions instead of read_register and read_register_pid. * ia64-linux-nat.c (enable_watchpoints_in_psr): Use REGCACHE argument instead of PTID. Use regcache functions instead of read_register_pid. (ia64_linux_insert_watchpoint): Update call. (ia64_linux_stopped_data_address): Use regcache functions instead of read_register_pid and write_register_pid. diff -urNp gdb-orig/gdb/i386-linux-nat.c gdb-head/gdb/i386-linux-nat.c --- gdb-orig/gdb/i386-linux-nat.c 2007-05-03 01:29:25.000000000 +0200 +++ gdb-head/gdb/i386-linux-nat.c 2007-05-04 20:18:22.280201984 +0200 @@ -736,11 +736,16 @@ i386_linux_resume (ptid_t ptid, int step if (step) { - CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid)); + struct cleanup *old_chain = save_inferior_ptid (); + struct regcache *regcache = current_regcache; + ULONGEST pc; gdb_byte buf[LINUX_SYSCALL_LEN]; request = PTRACE_SINGLESTEP; + inferior_ptid = pid_to_ptid (pid); + regcache_cooked_read_unsigned (regcache, PC_REGNUM, &pc); + /* Returning from a signal trampoline is done by calling a special system call (sigreturn or rt_sigreturn, see i386-linux-tdep.c for more information). This system call @@ -753,18 +758,21 @@ i386_linux_resume (ptid_t ptid, int step if (read_memory_nobpt (pc, buf, LINUX_SYSCALL_LEN) == 0 && memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0) { - int syscall = read_register_pid (LINUX_SYSCALL_REGNUM, - pid_to_ptid (pid)); + ULONGEST syscall; + regcache_cooked_read_unsigned (regcache, + LINUX_SYSCALL_REGNUM, &syscall); /* Then check the system call number. */ if (syscall == SYS_sigreturn || syscall == SYS_rt_sigreturn) { - CORE_ADDR sp = read_register (I386_ESP_REGNUM); - CORE_ADDR addr = sp; + ULONGEST sp, addr; unsigned long int eflags; + regcache_cooked_read_unsigned (regcache, I386_ESP_REGNUM, &sp); if (syscall == SYS_rt_sigreturn) addr = read_memory_integer (sp + 8, 4) + 20; + else + addr = sp; /* Set the trace flag in the context that's about to be restored. */ @@ -774,6 +782,8 @@ i386_linux_resume (ptid_t ptid, int step write_memory (addr, (gdb_byte *) &eflags, 4); } } + + do_cleanups (old_chain); } if (ptrace (request, pid, 0, target_signal_to_host (signal)) == -1) diff -urNp gdb-orig/gdb/ia64-linux-nat.c gdb-head/gdb/ia64-linux-nat.c --- gdb-orig/gdb/ia64-linux-nat.c 2007-05-03 01:29:25.000000000 +0200 +++ gdb-head/gdb/ia64-linux-nat.c 2007-05-04 20:27:06.853135926 +0200 @@ -477,16 +477,16 @@ fill_fpregset (const struct regcache *re #define IA64_PSR_DD (1UL << 39) static void -enable_watchpoints_in_psr (ptid_t ptid) +enable_watchpoints_in_psr (struct regcache *regcache) { - CORE_ADDR psr; + ULONGEST psr; - psr = read_register_pid (IA64_PSR_REGNUM, ptid); + regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr); if (!(psr & IA64_PSR_DB)) { psr |= IA64_PSR_DB; /* Set the db bit - this enables hardware watchpoints and breakpoints. */ - write_register_pid (IA64_PSR_REGNUM, psr, ptid); + regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr); } } @@ -591,7 +591,7 @@ ia64_linux_insert_watchpoint (CORE_ADDR } store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask); - enable_watchpoints_in_psr (ptid); + enable_watchpoints_in_psr (current_regcache); return 0; } @@ -628,6 +628,7 @@ ia64_linux_stopped_data_address (struct int tid; struct siginfo siginfo; ptid_t ptid = inferior_ptid; + struct regcache *regcache = current_regcache; tid = TIDGET(ptid); if (tid == 0) @@ -640,10 +641,10 @@ ia64_linux_stopped_data_address (struct (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */) return 0; - psr = read_register_pid (IA64_PSR_REGNUM, ptid); + regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr); psr |= IA64_PSR_DD; /* Set the dd bit - this will disable the watchpoint for the next instruction */ - write_register_pid (IA64_PSR_REGNUM, psr, ptid); + regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr); *addr_p = (CORE_ADDR)siginfo.si_addr; return 1; -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com