diff options
author | Jim Blandy <jimb@codesourcery.com> | 2004-05-20 00:53:06 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2004-05-20 00:53:06 +0000 |
commit | be07a590ed0a975673fb86e13d07362ff930c750 (patch) | |
tree | 45203347f4831ce8f5b982aaaa4174eb971ccd92 | |
parent | e14ad0e71ad3ddfb0b603ef48b28f530c49024e7 (diff) | |
download | gdb-be07a590ed0a975673fb86e13d07362ff930c750.zip gdb-be07a590ed0a975673fb86e13d07362ff930c750.tar.gz gdb-be07a590ed0a975673fb86e13d07362ff930c750.tar.bz2 |
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.
-rw-r--r-- | gdb/ChangeLog | 28 | ||||
-rw-r--r-- | gdb/Makefile.in | 3 | ||||
-rw-r--r-- | gdb/amd64-tdep.c | 6 | ||||
-rw-r--r-- | gdb/amd64obsd-tdep.c | 6 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 12 | ||||
-rw-r--r-- | gdb/i386nbsd-tdep.c | 7 | ||||
-rw-r--r-- | gdb/i386obsd-tdep.c | 7 | ||||
-rw-r--r-- | gdb/regset.c | 39 | ||||
-rw-r--r-- | gdb/regset.h | 25 | ||||
-rw-r--r-- | gdb/sparc64fbsd-tdep.c | 8 | ||||
-rw-r--r-- | gdb/sparc64nbsd-tdep.c | 8 | ||||
-rw-r--r-- | gdb/sparc64obsd-tdep.c | 6 | ||||
-rw-r--r-- | gdb/sparcnbsd-tdep.c | 8 |
13 files changed, 104 insertions, 59 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6de6b22..f73a2d9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,15 +1,29 @@ +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 diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 8c0813f..effe5c1 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -910,7 +910,7 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \ 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 @@ -2197,6 +2197,7 @@ regcache.o: regcache.c $(defs_h) $(inferior_h) $(target_h) $(gdbarch_h) \ $(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) \ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 0a85a23..a326811 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -1074,11 +1074,7 @@ amd64_regset_from_core_section (struct gdbarch *gdbarch, 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; } diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c index f9e0f69..5ded31d 100644 --- a/gdb/amd64obsd-tdep.c +++ b/gdb/amd64obsd-tdep.c @@ -63,11 +63,7 @@ amd64obsd_regset_from_core_section (struct gdbarch *gdbarch, && 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; } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 5f39529..9981059 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1662,11 +1662,7 @@ i386_regset_from_core_section (struct gdbarch *gdbarch, 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; } @@ -1675,11 +1671,7 @@ i386_regset_from_core_section (struct gdbarch *gdbarch, && 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; } diff --git a/gdb/i386nbsd-tdep.c b/gdb/i386nbsd-tdep.c index 9fd9883..53dbe8a 100644 --- a/gdb/i386nbsd-tdep.c +++ b/gdb/i386nbsd-tdep.c @@ -86,11 +86,8 @@ i386nbsd_aout_regset_from_core_section (struct gdbarch *gdbarch, && 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; } diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c index 0fe066f..a21faab 100644 --- a/gdb/i386obsd-tdep.c +++ b/gdb/i386obsd-tdep.c @@ -141,11 +141,8 @@ i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch, && 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; } diff --git a/gdb/regset.c b/gdb/regset.c new file mode 100644 index 0000000..98fb665 --- /dev/null +++ b/gdb/regset.c @@ -0,0 +1,39 @@ +/* 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; +} diff --git a/gdb/regset.h b/gdb/regset.h index 6172f0f..1d4355c 100644 --- a/gdb/regset.h +++ b/gdb/regset.h @@ -26,6 +26,11 @@ struct gdbarch; 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 { @@ -33,9 +38,23 @@ 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 */ diff --git a/gdb/sparc64fbsd-tdep.c b/gdb/sparc64fbsd-tdep.c index 6532a5f..7864ffa 100644 --- a/gdb/sparc64fbsd-tdep.c +++ b/gdb/sparc64fbsd-tdep.c @@ -199,13 +199,11 @@ sparc64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { 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); diff --git a/gdb/sparc64nbsd-tdep.c b/gdb/sparc64nbsd-tdep.c index 1c30a7a..25a0074 100644 --- a/gdb/sparc64nbsd-tdep.c +++ b/gdb/sparc64nbsd-tdep.c @@ -226,13 +226,11 @@ sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { 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); diff --git a/gdb/sparc64obsd-tdep.c b/gdb/sparc64obsd-tdep.c index fa0ab4d..b6bd88c 100644 --- a/gdb/sparc64obsd-tdep.c +++ b/gdb/sparc64obsd-tdep.c @@ -184,9 +184,9 @@ sparc64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { 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); diff --git a/gdb/sparcnbsd-tdep.c b/gdb/sparcnbsd-tdep.c index 43a8e9d..ab6003c 100644 --- a/gdb/sparcnbsd-tdep.c +++ b/gdb/sparcnbsd-tdep.c @@ -274,13 +274,11 @@ sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) 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); |