*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / i386-linux-nat.c
index 7a71c605285d930826bc3a3b62fd583f213f1a82..973cba78b6286c03feb5f9cce5fa6d1124ca5c9c 100644 (file)
@@ -162,7 +162,8 @@ fetch_register (struct regcache *regcache, int regno)
   errno = 0;
   val = ptrace (PTRACE_PEEKUSER, tid, 4 * regmap[regno], 0);
   if (errno != 0)
-    error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regno),
+    error (_("Couldn't read register %s (#%d): %s."), 
+          gdbarch_register_name (current_gdbarch, regno),
           regno, safe_strerror (errno));
 
   regcache_raw_supply (regcache, regno, &val);
@@ -189,7 +190,8 @@ store_register (const struct regcache *regcache, int regno)
   regcache_raw_collect (regcache, regno, &val);
   ptrace (PTRACE_POKEUSER, tid, 4 * regmap[regno], val);
   if (errno != 0)
-    error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regno),
+    error (_("Couldn't write register %s (#%d): %s."),
+          gdbarch_register_name (current_gdbarch, regno),
           regno, safe_strerror (errno));
 }
 \f
@@ -209,7 +211,7 @@ supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp)
   for (i = 0; i < I386_NUM_GREGS; i++)
     regcache_raw_supply (regcache, i, regp + regmap[i]);
 
-  if (I386_LINUX_ORIG_EAX_REGNUM < NUM_REGS)
+  if (I386_LINUX_ORIG_EAX_REGNUM < gdbarch_num_regs (current_gdbarch))
     regcache_raw_supply (regcache, I386_LINUX_ORIG_EAX_REGNUM,
                         regp + ORIG_EAX);
 }
@@ -230,7 +232,7 @@ fill_gregset (const struct regcache *regcache,
       regcache_raw_collect (regcache, i, regp + regmap[i]);
 
   if ((regno == -1 || regno == I386_LINUX_ORIG_EAX_REGNUM)
-      && I386_LINUX_ORIG_EAX_REGNUM < NUM_REGS)
+      && I386_LINUX_ORIG_EAX_REGNUM < gdbarch_num_regs (current_gdbarch))
     regcache_raw_collect (regcache, I386_LINUX_ORIG_EAX_REGNUM,
                          regp + ORIG_EAX);
 }
@@ -244,6 +246,7 @@ static void
 fetch_regs (struct regcache *regcache, int tid)
 {
   elf_gregset_t regs;
+  elf_gregset_t *regs_p = &regs;
 
   if (ptrace (PTRACE_GETREGS, tid, 0, (int) &regs) < 0)
     {
@@ -258,7 +261,7 @@ fetch_regs (struct regcache *regcache, int tid)
       perror_with_name (_("Couldn't get registers"));
     }
 
-  supply_gregset (regcache, (const elf_gregset_t *) &regs);
+  supply_gregset (regcache, (const elf_gregset_t *) regs_p);
 }
 
 /* Store all valid general-purpose registers in GDB's register array
@@ -457,7 +460,7 @@ i386_linux_fetch_inferior_registers (struct regcache *regcache, int regno)
     {
       int i;
 
-      for (i = 0; i < NUM_REGS; i++)
+      for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
        if (regno == -1 || regno == i)
          fetch_register (regcache, i);
 
@@ -529,7 +532,7 @@ i386_linux_store_inferior_registers (struct regcache *regcache, int regno)
     {
       int i;
 
-      for (i = 0; i < NUM_REGS; i++)
+      for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
        if (regno == -1 || regno == i)
          store_register (regcache, i);
 
@@ -736,11 +739,15 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
 
   if (step)
     {
-      CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid));
+      struct regcache *regcache = get_thread_regcache (pid_to_ptid (pid));
+      ULONGEST pc;
       gdb_byte buf[LINUX_SYSCALL_LEN];
 
       request = PTRACE_SINGLESTEP;
 
+      regcache_cooked_read_unsigned (regcache,
+                                    gdbarch_pc_regnum (current_gdbarch), &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 +760,21 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
       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.  */
This page took 0.024413 seconds and 4 git commands to generate.