linux-nat.c: fix a few lin_lwp_attach_lwp issues
[deliverable/binutils-gdb.git] / gdb / nios2-linux-tdep.c
index b2a3c3e20a336cc1f3e156f2e0706cf447404c3f..b829569c9c43694bc21c1ee23d1321325af27aca 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-dependent code for GNU/Linux on Nios II.
-   Copyright (C) 2012-2014 Free Software Foundation, Inc.
+   Copyright (C) 2012-2015 Free Software Foundation, Inc.
    Contributed by Mentor Graphics, Inc.
 
    This file is part of GDB.
@@ -49,6 +49,11 @@ static const int reg_offsets[NIOS2_NUM_REGS] =
   -1, -1, -1, -1, -1, -1, -1, -1
 };
 
+/* General register set size.  Should match sizeof (struct pt_regs) +
+   sizeof (struct switch_stack) from the NIOS2 Linux kernel patch.  */
+
+#define NIOS2_GREGS_SIZE (4 * 34)
+
 /* Implement the supply_regset hook for core files.  */
 
 static void
@@ -71,23 +76,41 @@ nios2_supply_gregset (const struct regset *regset,
       }
 }
 
+/* Implement the collect_regset hook for core files.  */
+
+static void
+nios2_collect_gregset (const struct regset *regset,
+                      const struct regcache *regcache,
+                      int regnum, void *gregs_buf, size_t len)
+{
+  gdb_byte *gregs = gregs_buf;
+  int regno;
+
+  for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
+    if (regnum == -1 || regnum == regno)
+      {
+       if (reg_offsets[regno] != -1)
+         regcache_raw_collect (regcache, regno,
+                               gregs + 4 * reg_offsets[regno]);
+      }
+}
+
 static const struct regset nios2_core_regset =
 {
   NULL,
   nios2_supply_gregset,
-  NULL,
+  nios2_collect_gregset
 };
 
-/* Implement the regset_from_core_section gdbarch method.  */
+/* Iterate over core file register note sections.  */
 
-static const struct regset *
-nios2_regset_from_core_section (struct gdbarch *gdbarch,
-                                const char *sect_name, size_t sect_size)
+static void
+nios2_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                   iterate_over_regset_sections_cb *cb,
+                                   void *cb_data,
+                                   const struct regcache *regcache)
 {
-  if (strcmp (sect_name, ".reg") == 0)
-    return &nios2_core_regset;
-
-  return NULL;
+  cb (".reg", NIOS2_GREGS_SIZE, &nios2_core_regset, NULL, cb_data);
 }
 
 /* Initialize a trad-frame cache corresponding to the tramp-frame.
@@ -162,8 +185,8 @@ nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
   /* Core file support.  */
-  set_gdbarch_regset_from_core_section (gdbarch,
-                                        nios2_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, nios2_iterate_over_regset_sections);
   /* Linux signal frame unwinders.  */
   tramp_frame_prepend_unwinder (gdbarch,
                                 &nios2_linux_rt_sigreturn_tramp_frame);
This page took 0.026306 seconds and 4 git commands to generate.