bfd_set_input_error
[deliverable/binutils-gdb.git] / gdb / xtensa-linux-nat.c
index 836d3f80ee481602fdb6aff0763c72ef63fbeff4..b8366c55a4144948d409c058fbf4c296ca188d6e 100644 (file)
@@ -1,6 +1,6 @@
 /* Xtensa GNU/Linux native support.
 
-   Copyright (C) 2007-2016 Free Software Foundation, Inc.
+   Copyright (C) 2007-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -82,6 +82,10 @@ fill_gregset (const struct regcache *regcache,
     regcache_raw_collect (regcache,
                          gdbarch_tdep (gdbarch)->sar_regnum,
                          &regs->sar);
+  if (regnum == gdbarch_tdep (gdbarch)->threadptr_regnum || regnum == -1)
+    regcache_raw_collect (regcache,
+                         gdbarch_tdep (gdbarch)->threadptr_regnum,
+                         &regs->threadptr);
   if (regnum >=gdbarch_tdep (gdbarch)->ar_base
       && regnum < gdbarch_tdep (gdbarch)->ar_base
                    + gdbarch_tdep (gdbarch)->num_aregs)
@@ -94,6 +98,20 @@ fill_gregset (const struct regcache *regcache,
                              gdbarch_tdep (gdbarch)->ar_base + i,
                              &regs->ar[i]);
     }
+  if (regnum >= gdbarch_tdep (gdbarch)->a0_base
+      && regnum < gdbarch_tdep (gdbarch)->a0_base + C0_NREGS)
+    regcache_raw_collect (regcache, regnum,
+                         &regs->ar[(4 * regs->windowbase + regnum
+                                    - gdbarch_tdep (gdbarch)->a0_base)
+                         % gdbarch_tdep (gdbarch)->num_aregs]);
+  else if (regnum == -1)
+    {
+      for (i = 0; i < C0_NREGS; ++i)
+       regcache_raw_collect (regcache,
+                             gdbarch_tdep (gdbarch)->a0_base + i,
+                             &regs->ar[(4 * regs->windowbase + i)
+                             % gdbarch_tdep (gdbarch)->num_aregs]);
+    }
 }
 
 static void
@@ -134,6 +152,10 @@ supply_gregset_reg (struct regcache *regcache,
     regcache_raw_supply (regcache,
                          gdbarch_tdep (gdbarch)->sar_regnum,
                          &regs->sar);
+  if (regnum == gdbarch_tdep (gdbarch)->threadptr_regnum || regnum == -1)
+    regcache_raw_supply (regcache,
+                         gdbarch_tdep (gdbarch)->threadptr_regnum,
+                         &regs->threadptr);
   if (regnum >=gdbarch_tdep (gdbarch)->ar_base
       && regnum < gdbarch_tdep (gdbarch)->ar_base
                    + gdbarch_tdep (gdbarch)->num_aregs)
@@ -146,6 +168,20 @@ supply_gregset_reg (struct regcache *regcache,
                              gdbarch_tdep (gdbarch)->ar_base + i,
                              &regs->ar[i]);
     }
+  if (regnum >= gdbarch_tdep (gdbarch)->a0_base
+      && regnum < gdbarch_tdep (gdbarch)->a0_base + C0_NREGS)
+    regcache_raw_supply (regcache, regnum,
+                        &regs->ar[(4 * regs->windowbase + regnum
+                                   - gdbarch_tdep (gdbarch)->a0_base)
+                        % gdbarch_tdep (gdbarch)->num_aregs]);
+  else if (regnum == -1)
+    {
+      for (i = 0; i < C0_NREGS; ++i)
+       regcache_raw_supply (regcache,
+                            gdbarch_tdep (gdbarch)->a0_base + i,
+                            &regs->ar[(4 * regs->windowbase + i)
+                            % gdbarch_tdep (gdbarch)->num_aregs]);
+    }
 }
 
 void
@@ -174,8 +210,8 @@ supply_fpregset (struct regcache *regcache,
 static void
 fetch_gregs (struct regcache *regcache, int regnum)
 {
-  int tid = ptid_get_lwp (inferior_ptid);
-  const gdb_gregset_t regs;
+  int tid = ptid_get_lwp (regcache_get_ptid (regcache));
+  gdb_gregset_t regs;
   int areg;
   
   if (ptrace (PTRACE_GETREGS, tid, 0, (long) &regs) < 0)
@@ -193,7 +229,7 @@ fetch_gregs (struct regcache *regcache, int regnum)
 static void
 store_gregs (struct regcache *regcache, int regnum)
 {
-  int tid = ptid_get_lwp (inferior_ptid);
+  int tid = ptid_get_lwp (regcache_get_ptid (regcache));
   gdb_gregset_t regs;
   int areg;
 
@@ -221,7 +257,7 @@ static int xtreg_high;
 static void
 fetch_xtregs (struct regcache *regcache, int regnum)
 {
-  int tid = ptid_get_lwp (inferior_ptid);
+  int tid = ptid_get_lwp (regcache_get_ptid (regcache));
   const xtensa_regtable_t *ptr;
   char xtregs [XTENSA_ELF_XTREG_SIZE];
 
@@ -237,7 +273,7 @@ fetch_xtregs (struct regcache *regcache, int regnum)
 static void
 store_xtregs (struct regcache *regcache, int regnum)
 {
-  int tid = ptid_get_lwp (inferior_ptid);
+  int tid = ptid_get_lwp (regcache_get_ptid (regcache));
   const xtensa_regtable_t *ptr;
   char xtregs [XTENSA_ELF_XTREG_SIZE];
 
@@ -302,8 +338,6 @@ ps_get_thread_area (struct ps_prochandle *ph,
   return PS_OK;
 }
 
-void _initialize_xtensa_linux_nat (void);
-
 void
 _initialize_xtensa_linux_nat (void)
 {
This page took 0.044913 seconds and 4 git commands to generate.