summaryrefslogtreecommitdiff
path: root/gdb/amd64-linux-nat.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-03-14 22:11:25 +0000
committerMark Kettenis <kettenis@gnu.org>2004-03-14 22:11:25 +0000
commit88668fa34dab3b110b7d465eecd49669a594fc22 (patch)
treeaac1bff76167f4e324fda7c0bf1c2f5caa47cc5a /gdb/amd64-linux-nat.c
parent25aa88bec7b1ee34330abe4aa7f548073d736cc9 (diff)
downloadgdb-88668fa34dab3b110b7d465eecd49669a594fc22.tar.gz
* 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.
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r--gdb/amd64-linux-nat.c116
1 files changed, 34 insertions, 82 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 63417c40b09..4d94065c49c 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -96,12 +96,6 @@ static int amd64_linux_gregset32_reg_offset[] =
-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, int regnum)
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) &regs) < 0)
- perror_with_name ("Couldn't get registers");
-
- supply_gregset (&regs);
-}
-
-/* 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) &regs) < 0)
- perror_with_name ("Couldn't get registers");
-
- fill_gregset (&regs, regnum);
-
- if (ptrace (PTRACE_SETREGS, tid, 0, (long) &regs) < 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, int regnum)
{
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) &regs) < 0)
+ perror_with_name ("Couldn't get registers");
+
+ amd64_supply_native_gregset (current_regcache, &regs, -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;
+
+ if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0)
+ perror_with_name ("Couldn't get floating point status");
- internal_error (__FILE__, __LINE__,
- "Got request for bad register number %d.", regnum);
+ 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) &regs) < 0)
+ perror_with_name ("Couldn't get registers");
+
+ amd64_collect_native_gregset (current_regcache, &regs, regnum);
+
+ if (ptrace (PTRACE_SETREGS, tid, 0, (long) &regs) < 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);
}