From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12114 invoked by alias); 14 Mar 2004 22:11:37 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12090 invoked from network); 14 Mar 2004 22:11:32 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 14 Mar 2004 22:11:32 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2EMBUuK000329 for ; Sun, 14 Mar 2004 23:11:30 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2EMBULG015522 for ; Sun, 14 Mar 2004 23:11:30 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id i2EMBUMI015519; Sun, 14 Mar 2004 23:11:30 +0100 (CET) Date: Sun, 14 Mar 2004 22:11:00 -0000 Message-Id: <200403142211.i2EMBUMI015519@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb-patches@sources.redhat.com Subject: [PATCH] amd64-linux-nat.c cleanup X-SW-Source: 2004-03.o/txt/msg00309.txt This makes it more similar to what's done on the various BSD's. Should make my life a bit easier. Committed to mainline, Mark Index: ChangeLog from Mark Kettenis * amd64-linux-nat.c (GETFPREGS_SUPPLIES): Remove macro. (fetch_regs, fetch_fpregs, store_regs, store_fpregs): Remove functions. (fetch_inferior_registers, store_inferior_registers): Rewrite. Index: amd64-linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/amd64-linux-nat.c,v retrieving revision 1.5 diff -u -p -r1.5 amd64-linux-nat.c --- amd64-linux-nat.c 4 Mar 2004 10:35:57 -0000 1.5 +++ amd64-linux-nat.c 14 Mar 2004 22:09:01 -0000 @@ -96,12 +96,6 @@ static int amd64_linux_gregset32_reg_off -1, -1, -1, -1, -1, -1, -1, -1, -1, ORIG_RAX * 8 /* "orig_eax" */ }; - -/* Which ptrace request retrieves which registers? - These apply to the corresponding SET requests as well. */ - -#define GETFPREGS_SUPPLIES(regno) \ - (FP0_REGNUM <= (regno) && (regno) <= MXCSR_REGNUM) /* Transfering the general-purpose registers between GDB, inferiors @@ -126,38 +120,6 @@ fill_gregset (elf_gregset_t *gregsetp, i amd64_collect_native_gregset (current_regcache, gregsetp, regnum); } -/* Fetch all general-purpose registers from process/thread TID and - store their values in GDB's register cache. */ - -static void -fetch_regs (int tid) -{ - elf_gregset_t regs; - - if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't get registers"); - - supply_gregset (®s); -} - -/* Store all valid general-purpose registers in GDB's register cache - into the process/thread specified by TID. */ - -static void -store_regs (int tid, int regnum) -{ - elf_gregset_t regs; - - if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't get registers"); - - fill_gregset (®s, regnum); - - if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't write registers"); -} - - /* Transfering floating-point registers between GDB, inferiors and cores. */ /* Fill GDB's register cache with the floating-point and SSE register @@ -178,37 +140,6 @@ fill_fpregset (elf_fpregset_t *fpregsetp { amd64_collect_fxsave (current_regcache, regnum, fpregsetp); } - -/* Fetch all floating-point registers from process/thread TID and store - thier values in GDB's register cache. */ - -static void -fetch_fpregs (int tid) -{ - elf_fpregset_t fpregs; - - if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't get floating point status"); - - supply_fpregset (&fpregs); -} - -/* Store all valid floating-point registers in GDB's register cache - into the process/thread specified by TID. */ - -static void -store_fpregs (int tid, int regnum) -{ - elf_fpregset_t fpregs; - - if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't get floating point status"); - - fill_fpregset (&fpregs, regnum); - - if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't write floating point status"); -} /* Transferring arbitrary registers between GDB and inferior. */ @@ -229,19 +160,25 @@ fetch_inferior_registers (int regnum) if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { - fetch_regs (tid); + elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't get registers"); + + amd64_supply_native_gregset (current_regcache, ®s, -1); if (regnum != -1) return; } - if (regnum == -1 || GETFPREGS_SUPPLIES (regnum)) + if (regnum == -1 || regnum >= AMD64_ST0_REGNUM) { - fetch_fpregs (tid); - return; - } + elf_fpregset_t fpregs; - internal_error (__FILE__, __LINE__, - "Got request for bad register number %d.", regnum); + if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't get floating point status"); + + amd64_supply_fxsave (current_regcache, -1, &fpregs); + } } /* Store register REGNUM back into the child process. If REGNUM is @@ -260,19 +197,34 @@ store_inferior_registers (int regnum) if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { - store_regs (tid, regnum); + elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't get registers"); + + amd64_collect_native_gregset (current_regcache, ®s, regnum); + + if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't write registers"); + if (regnum != -1) return; } - if (regnum == -1 || GETFPREGS_SUPPLIES (regnum)) + if (regnum == -1 || regnum >= AMD64_ST0_REGNUM) { - store_fpregs (tid, regnum); + elf_fpregset_t fpregs; + + if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't get floating point status"); + + amd64_collect_fxsave (current_regcache, regnum, &fpregs); + + if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't write floating point status"); + return; } - - internal_error (__FILE__, __LINE__, - "Got request to store bad register number %d.", regnum); } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12114 invoked by alias); 14 Mar 2004 22:11:37 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12090 invoked from network); 14 Mar 2004 22:11:32 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 14 Mar 2004 22:11:32 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2EMBUuK000329 for ; Sun, 14 Mar 2004 23:11:30 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2EMBULG015522 for ; Sun, 14 Mar 2004 23:11:30 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id i2EMBUMI015519; Sun, 14 Mar 2004 23:11:30 +0100 (CET) Date: Fri, 19 Mar 2004 00:09:00 -0000 Message-ID: <200403142211.i2EMBUMI015519@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb-patches@sources.redhat.com Subject: [PATCH] amd64-linux-nat.c cleanup X-SW-Source: 2004-03/txt/msg00309.txt.bz2 Message-ID: <20040319000900.Kb2V-Fj_kKWQVHvDgPYp7uqaNf6XmhO7mgRYNroEFRE@z> This makes it more similar to what's done on the various BSD's. Should make my life a bit easier. Committed to mainline, Mark Index: ChangeLog from Mark Kettenis * amd64-linux-nat.c (GETFPREGS_SUPPLIES): Remove macro. (fetch_regs, fetch_fpregs, store_regs, store_fpregs): Remove functions. (fetch_inferior_registers, store_inferior_registers): Rewrite. Index: amd64-linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/amd64-linux-nat.c,v retrieving revision 1.5 diff -u -p -r1.5 amd64-linux-nat.c --- amd64-linux-nat.c 4 Mar 2004 10:35:57 -0000 1.5 +++ amd64-linux-nat.c 14 Mar 2004 22:09:01 -0000 @@ -96,12 +96,6 @@ static int amd64_linux_gregset32_reg_off -1, -1, -1, -1, -1, -1, -1, -1, -1, ORIG_RAX * 8 /* "orig_eax" */ }; - -/* Which ptrace request retrieves which registers? - These apply to the corresponding SET requests as well. */ - -#define GETFPREGS_SUPPLIES(regno) \ - (FP0_REGNUM <= (regno) && (regno) <= MXCSR_REGNUM) /* Transfering the general-purpose registers between GDB, inferiors @@ -126,38 +120,6 @@ fill_gregset (elf_gregset_t *gregsetp, i amd64_collect_native_gregset (current_regcache, gregsetp, regnum); } -/* Fetch all general-purpose registers from process/thread TID and - store their values in GDB's register cache. */ - -static void -fetch_regs (int tid) -{ - elf_gregset_t regs; - - if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't get registers"); - - supply_gregset (®s); -} - -/* Store all valid general-purpose registers in GDB's register cache - into the process/thread specified by TID. */ - -static void -store_regs (int tid, int regnum) -{ - elf_gregset_t regs; - - if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't get registers"); - - fill_gregset (®s, regnum); - - if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) - perror_with_name ("Couldn't write registers"); -} - - /* Transfering floating-point registers between GDB, inferiors and cores. */ /* Fill GDB's register cache with the floating-point and SSE register @@ -178,37 +140,6 @@ fill_fpregset (elf_fpregset_t *fpregsetp { amd64_collect_fxsave (current_regcache, regnum, fpregsetp); } - -/* Fetch all floating-point registers from process/thread TID and store - thier values in GDB's register cache. */ - -static void -fetch_fpregs (int tid) -{ - elf_fpregset_t fpregs; - - if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't get floating point status"); - - supply_fpregset (&fpregs); -} - -/* Store all valid floating-point registers in GDB's register cache - into the process/thread specified by TID. */ - -static void -store_fpregs (int tid, int regnum) -{ - elf_fpregset_t fpregs; - - if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't get floating point status"); - - fill_fpregset (&fpregs, regnum); - - if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name ("Couldn't write floating point status"); -} /* Transferring arbitrary registers between GDB and inferior. */ @@ -229,19 +160,25 @@ fetch_inferior_registers (int regnum) if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { - fetch_regs (tid); + elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't get registers"); + + amd64_supply_native_gregset (current_regcache, ®s, -1); if (regnum != -1) return; } - if (regnum == -1 || GETFPREGS_SUPPLIES (regnum)) + if (regnum == -1 || regnum >= AMD64_ST0_REGNUM) { - fetch_fpregs (tid); - return; - } + elf_fpregset_t fpregs; - internal_error (__FILE__, __LINE__, - "Got request for bad register number %d.", regnum); + if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't get floating point status"); + + amd64_supply_fxsave (current_regcache, -1, &fpregs); + } } /* Store register REGNUM back into the child process. If REGNUM is @@ -260,19 +197,34 @@ store_inferior_registers (int regnum) if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { - store_regs (tid, regnum); + elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't get registers"); + + amd64_collect_native_gregset (current_regcache, ®s, regnum); + + if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) + perror_with_name ("Couldn't write registers"); + if (regnum != -1) return; } - if (regnum == -1 || GETFPREGS_SUPPLIES (regnum)) + if (regnum == -1 || regnum >= AMD64_ST0_REGNUM) { - store_fpregs (tid, regnum); + elf_fpregset_t fpregs; + + if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't get floating point status"); + + amd64_collect_fxsave (current_regcache, regnum, &fpregs); + + if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) + perror_with_name ("Couldn't write floating point status"); + return; } - - internal_error (__FILE__, __LINE__, - "Got request to store bad register number %d.", regnum); }