* regset.h (supply_regset_ftype, collect_regset_ftype): New typedefs.
(struct regset): Use supply_regset_ftype. Add new
'collect_regset' member.
(regset_xmalloc): New declaration.
* regset.c: New file.
* am64-tdep.c (amd64_regset_from_core_section): Use
regset_xmalloc to construct regset structures.
* amd64obsd-tdep.c (amd64obsd_regset_from_core_section): Same.
* i386-tdep.c (i386_regset_from_core_section): Same.
* i386nbsd-tdep.c (i386nbsd_aout_regset_from_core_section): Same.
* i386obsd-tdep.c (i386obsd_aout_regset_from_core_section): Same.
* sparc64fbsd-tdep.c (sparc64fbsd_init_abi): Same.
* sparc64nbsd-tdep.c (sparc64nbsd_init_abi): Same.
* sparc64obsd-tdep.c (sparc64obsd_init_abi): Same.
* sparcnbsd-tdep.c (sparc32nbsd_init_abi): Same.
* Makefile.in (COMMON_OBS): Add regset.o.
(regset.o): New rule.
+2004-05-19 Jim Blandy <jimb@redhat.com>
+
+ Use a constructor function to create regset structures.
+ * regset.h (supply_regset_ftype, collect_regset_ftype): New typedefs.
+ (struct regset): Use supply_regset_ftype. Add new
+ 'collect_regset' member.
+ (regset_xmalloc): New declaration.
+ * regset.c: New file.
+ * am64-tdep.c (amd64_regset_from_core_section): Use
+ regset_xmalloc to construct regset structures.
+ * amd64obsd-tdep.c (amd64obsd_regset_from_core_section): Same.
+ * i386-tdep.c (i386_regset_from_core_section): Same.
+ * i386nbsd-tdep.c (i386nbsd_aout_regset_from_core_section): Same.
+ * i386obsd-tdep.c (i386obsd_aout_regset_from_core_section): Same.
+ * sparc64fbsd-tdep.c (sparc64fbsd_init_abi): Same.
+ * sparc64nbsd-tdep.c (sparc64nbsd_init_abi): Same.
+ * sparc64obsd-tdep.c (sparc64obsd_init_abi): Same.
+ * sparcnbsd-tdep.c (sparc32nbsd_init_abi): Same.
+ * Makefile.in (COMMON_OBS): Add regset.o.
+ (regset.o): New rule.
+
2004-05-19 Joel Brobecker <brobecker@gnat.com>
* config/djgpp/fnchange.lst: Add entries for pthread_cond_wait.exp
and pthread_cond_wait.c.
-2004-05-18 Jim Blandy <jimb@redhat.com>
-
- * rs6000-tdep.c (rs6000_gdbarch_init): Initialize tdep fields
- before the mach-specific switch, and then let the individual cases
- override the defaults, rather than leaving them uninitialized
- until the switch and then setting them in each case.
-
2004-05-18 Randolph Chung <tausq@debian.org>
* hppa-tdep.c (hppa_frame_cache): Check for validity of r31 for
frame-base.o \
gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o cp-support.o \
cp-namespace.o \
- reggroups.o \
+ reggroups.o regset.o \
trad-frame.o \
tramp-frame.o
$(gdb_string_h) $(gdbcmd_h) $(observer_h)
reggroups.o: reggroups.c $(defs_h) $(reggroups_h) $(gdbtypes_h) \
$(gdb_assert_h) $(regcache_h) $(command_h) $(gdbcmd_h)
+regset.o: regset.c $(defs_h) $(regset_h) $(gdb_assert_h)
remote.o: remote.c $(defs_h) $(gdb_string_h) $(inferior_h) $(bfd_h) \
$(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) $(gdb_stabs_h) \
$(gdbthread_h) $(remote_h) $(regcache_h) $(value_h) $(gdb_assert_h) \
if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
{
if (tdep->fpregset == NULL)
- {
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->descr = tdep;
- tdep->fpregset->supply_regset = amd64_supply_fpregset;
- }
+ tdep->fpregset = regset_xmalloc (tdep, amd64_supply_fpregset, NULL);
return tdep->fpregset;
}
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
{
if (tdep->gregset == NULL)
- {
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = tdep;
- tdep->gregset->supply_regset = amd64obsd_supply_regset;
- }
+ tdep->gregset = regset_xmalloc (tdep, amd64obsd_supply_regset, NULL);
return tdep->gregset;
}
if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
{
if (tdep->gregset == NULL)
- {
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = tdep;
- tdep->gregset->supply_regset = i386_supply_gregset;
- }
+ tdep->gregset = regset_xmalloc (tdep, i386_supply_gregset, NULL);
return tdep->gregset;
}
&& sect_size == I387_SIZEOF_FXSAVE))
{
if (tdep->fpregset == NULL)
- {
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->descr = tdep;
- tdep->fpregset->supply_regset = i386_supply_fpregset;
- }
+ tdep->fpregset = regset_xmalloc (tdep, i386_supply_fpregset, NULL);
return tdep->fpregset;
}
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
- {
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = tdep;
- tdep->gregset->supply_regset = i386nbsd_aout_supply_regset;
- }
+ tdep->gregset
+ = regset_xmalloc (tdep, i386nbsd_aout_supply_regset, NULL);
return tdep->gregset;
}
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
- {
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = tdep;
- tdep->gregset->supply_regset = i386obsd_aout_supply_regset;
- }
+ tdep->gregset
+ = regset_xmalloc (tdep, i386obsd_aout_supply_regset, NULL);
return tdep->gregset;
}
--- /dev/null
+/* Regset support functions, for GDB.
+
+ Copyright 2004 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "regset.h"
+#include "gdb_assert.h"
+
+
+struct regset *
+regset_xmalloc (void *descr,
+ supply_regset_ftype *supply_regset,
+ collect_regset_ftype *collect_regset)
+{
+ struct regset *r = (struct regset *) xmalloc (sizeof (*r));
+
+ r->descr = descr;
+ r->supply_regset = supply_regset;
+ r->collect_regset = collect_regset;
+
+ return r;
+}
struct regcache;
/* Data structure describing a register set. */
+typedef void (supply_regset_ftype) (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+typedef void (collect_regset_ftype) (const struct regset *,
+ const struct regcache *,
+ int, const void *, size_t);
struct regset
{
providing some sort of description of the register set. */
const void *descr;
- /* Function supplying a register set to a register cache. */
- void (*supply_regset) (const struct regset *, struct regcache *,
- int, const void *, size_t);
+ /* Function supplying values in a register set to a register cache. */
+ supply_regset_ftype *supply_regset;
+
+ /* Function collecting values in a register set from a register cache. */
+ collect_regset_ftype *collect_regset;
};
+
+/* Allocate a fresh 'struct regset' whose descr is DESCR, whose
+ supply_regset function is SUPPLY_REGSET, and whose collect_regset
+ function is COLLECT_REGSET. If the regset has no collect function,
+ pass NULL for COLLECT_REGSET.
+
+ The object returned is allocated using xmalloc. */
+extern struct regset *regset_xmalloc (void *descr,
+ supply_regset_ftype *supply_regset,
+ collect_regset_ftype *collect_regset);
+
+
#endif /* regset.h */
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = &sparc64fbsd_gregset;
- tdep->gregset->supply_regset = sparc64fbsd_supply_gregset;
+ tdep->gregset
+ = regset_xmalloc (&sparc64fbsd_gregset, sparc64fbsd_supply_gregset, NULL);
tdep->sizeof_gregset = 256;
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->supply_regset = sparc64fbsd_supply_fpregset;
+ tdep->fpregset = regset_xmalloc (NULL, sparc64fbsd_supply_fpregset, NULL);
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64fbsd_sigtramp_frame_sniffer);
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = &sparc64nbsd_gregset;
- tdep->gregset->supply_regset = sparc64nbsd_supply_gregset;
+ tdep->gregset
+ = regset_xmalloc (&sparc64nbsd_gregset, sparc64nbsd_supply_gregset, NULL);
tdep->sizeof_gregset = 160;
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->supply_regset = sparc64nbsd_supply_fpregset;
+ tdep->fpregset = regset_xmalloc (NULL, sparc64nbsd_supply_fpregset, NULL);
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = &sparc64obsd_core_gregset;
- tdep->gregset->supply_regset = sparc64obsd_supply_gregset;
+ tdep->gregset = regset_xmalloc (&sparc64obsd_core_gregset,
+ sparc64obsd_supply_gregset,
+ NULL);
tdep->sizeof_gregset = 832;
frame_unwind_append_sniffer (gdbarch, sparc64obsd_sigtramp_frame_sniffer);
set_gdbarch_long_double_bit (gdbarch, 64);
set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = &sparc32nbsd_gregset;
- tdep->gregset->supply_regset = sparc32nbsd_supply_gregset;
+ tdep->gregset
+ = regset_xmalloc (&sparc32nbsd_gregset, sparc32nbsd_supply_gregset, NULL);
tdep->sizeof_gregset = 20 * 4;
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->supply_regset = sparc32nbsd_supply_fpregset;
+ tdep->fpregset = regset_xmalloc (NULL, sparc32nbsd_supply_fpregset, NULL);
tdep->sizeof_fpregset = 33 * 4;
frame_unwind_append_sniffer (gdbarch, sparc32nbsd_sigtramp_frame_sniffer);