Use XCNEW rather than xcalloc (1, ...) in linux-x86-low.c
[deliverable/binutils-gdb.git] / gdb / amd64obsd-tdep.c
index 94463180b488e8543054fd863a136cdebdbca490..ef0c0c2f8534e7b72e7b58f882619b8e1d19a667 100644 (file)
@@ -29,9 +29,6 @@
 #include "target.h"
 #include "trad-frame.h"
 
-#include "gdb_assert.h"
-#include <string.h>
-
 #include "obsd-tdep.h"
 #include "amd64-tdep.h"
 #include "i387-tdep.h"
@@ -45,7 +42,8 @@ amd64obsd_supply_regset (const struct regset *regset,
                         struct regcache *regcache, int regnum,
                         const void *regs, size_t len)
 {
-  const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE);
 
@@ -54,6 +52,11 @@ amd64obsd_supply_regset (const struct regset *regset,
                       ((const gdb_byte *)regs) + tdep->sizeof_gregset);
 }
 
+static const struct regset amd64obsd_combined_regset =
+  {
+    NULL, amd64obsd_supply_regset, NULL
+  };
+
 static const struct regset *
 amd64obsd_regset_from_core_section (struct gdbarch *gdbarch,
                                    const char *sect_name, size_t sect_size)
@@ -65,11 +68,7 @@ amd64obsd_regset_from_core_section (struct gdbarch *gdbarch,
 
   if (strcmp (sect_name, ".reg") == 0
       && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
-    {
-      if (tdep->gregset == NULL)
-        tdep->gregset = regset_alloc (gdbarch, amd64obsd_supply_regset, NULL);
-      return tdep->gregset;
-    }
+    return &amd64obsd_combined_regset;
 
   return NULL;
 }
This page took 0.023901 seconds and 4 git commands to generate.