This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: allocate regsets on gdbarch obstack


Mark Kettenis <kettenis@chello.nl> writes:
> Anyway, consider a patch with s/regset_obstack_alloc/regset_obstack/g
> and gets rid of the funny parenthesis pre-approved.

You mean, s/regset_obstack_alloc/regset_alloc/g, right?  I've
committed the patch below.

> P.S. Sorry to be so pedantic about function name, but I feel the lack
> of consistency in naming function is causing too much confusion.

No, not at all.  I've been trying to guess the appropriate precedent,
too, just getting it wrong.

2004-05-20  Jim Blandy  <jimb@redhat.com>

	Allocate regset structures in the gdbarch's obstack, not using
	xmalloc.
	* regset.c (regset_alloc): Renamed from regset_xmalloc.
	Add 'arch' argument.  Allocate the regset on arch's obstack, not
	using xmalloc.
	* regset.h (regset_alloc): Update declaration.
	* am64-tdep.c (amd64_regset_from_core_section): Update call; pass
	gdbarch argument.
	* 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.

Index: gdb/regset.c
===================================================================
RCS file: /cvs/src/src/gdb/regset.c,v
retrieving revision 1.2
diff -c -p -r1.2 regset.c
*** gdb/regset.c	20 May 2004 17:47:55 -0000	1.2
--- gdb/regset.c	21 May 2004 21:49:11 -0000
***************
*** 25,35 ****
  
  
  struct regset *
! regset_xmalloc (const 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;
--- 25,37 ----
  
  
  struct regset *
! regset_alloc (struct gdbarch *arch,
!               const void *descr,
!               supply_regset_ftype *supply_regset,
!               collect_regset_ftype *collect_regset)
  {
!   struct regset *r
!     = (struct regset *) gdbarch_obstack_zalloc (arch, sizeof (*r));
  
    r->descr = descr;
    r->supply_regset = supply_regset;
Index: gdb/regset.h
===================================================================
RCS file: /cvs/src/src/gdb/regset.h,v
retrieving revision 1.3
diff -c -p -r1.3 regset.h
*** gdb/regset.h	20 May 2004 17:47:55 -0000	1.3
--- gdb/regset.h	21 May 2004 21:49:11 -0000
*************** struct regset
*** 51,60 ****
     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 (const void *descr,
!                                       supply_regset_ftype *supply_regset,
!                                       collect_regset_ftype *collect_regset);
  
  
  #endif /* regset.h */
--- 51,61 ----
     function is COLLECT_REGSET.  If the regset has no collect function,
     pass NULL for COLLECT_REGSET.
  
!    The object returned is allocated on ARCH's obstack.  */
! extern struct regset *regset_alloc (struct gdbarch *arch,
!                                     const void *descr,
!                                     supply_regset_ftype *supply_regset,
!                                     collect_regset_ftype *collect_regset);
  
  
  #endif /* regset.h */
Index: gdb/amd64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-tdep.c,v
retrieving revision 1.11
diff -c -p -r1.11 amd64-tdep.c
*** gdb/amd64-tdep.c	20 May 2004 00:53:06 -0000	1.11
--- gdb/amd64-tdep.c	21 May 2004 21:49:09 -0000
*************** amd64_regset_from_core_section (struct g
*** 1074,1080 ****
    if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
      {
        if (tdep->fpregset == NULL)
!         tdep->fpregset = regset_xmalloc (tdep, amd64_supply_fpregset, NULL);
  
        return tdep->fpregset;
      }
--- 1074,1081 ----
    if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
      {
        if (tdep->fpregset == NULL)
!         tdep->fpregset = regset_alloc (gdbarch, tdep,
!                                        amd64_supply_fpregset, NULL);
  
        return tdep->fpregset;
      }
Index: gdb/amd64obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64obsd-tdep.c,v
retrieving revision 1.11
diff -c -p -r1.11 amd64obsd-tdep.c
*** gdb/amd64obsd-tdep.c	20 May 2004 00:53:06 -0000	1.11
--- gdb/amd64obsd-tdep.c	21 May 2004 21:49:09 -0000
*************** amd64obsd_regset_from_core_section (stru
*** 63,69 ****
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_xmalloc (tdep, amd64obsd_supply_regset, NULL);
        return tdep->gregset;
      }
  
--- 63,70 ----
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_alloc (gdbarch, tdep,
!                                       amd64obsd_supply_regset, NULL);
        return tdep->gregset;
      }
  
Index: gdb/i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.192
diff -c -p -r1.192 i386-tdep.c
*** gdb/i386-tdep.c	20 May 2004 00:53:06 -0000	1.192
--- gdb/i386-tdep.c	21 May 2004 21:49:10 -0000
*************** i386_regset_from_core_section (struct gd
*** 1662,1668 ****
    if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_xmalloc (tdep, i386_supply_gregset, NULL);
        return tdep->gregset;
      }
  
--- 1662,1669 ----
    if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_alloc (gdbarch, tdep,
!                                       i386_supply_gregset, NULL);
        return tdep->gregset;
      }
  
*************** i386_regset_from_core_section (struct gd
*** 1671,1677 ****
  	  && sect_size == I387_SIZEOF_FXSAVE))
      {
        if (tdep->fpregset == NULL)
!         tdep->fpregset = regset_xmalloc (tdep, i386_supply_fpregset, NULL);
        return tdep->fpregset;
      }
  
--- 1672,1679 ----
  	  && sect_size == I387_SIZEOF_FXSAVE))
      {
        if (tdep->fpregset == NULL)
!         tdep->fpregset = regset_alloc (gdbarch, tdep,
!                                        i386_supply_fpregset, NULL);
        return tdep->fpregset;
      }
  
Index: gdb/i386nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-tdep.c,v
retrieving revision 1.25
diff -c -p -r1.25 i386nbsd-tdep.c
*** gdb/i386nbsd-tdep.c	20 May 2004 00:53:06 -0000	1.25
--- gdb/i386nbsd-tdep.c	21 May 2004 21:49:10 -0000
*************** i386nbsd_aout_regset_from_core_section (
*** 86,93 ****
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset
!           = regset_xmalloc (tdep, i386nbsd_aout_supply_regset, NULL);
        return tdep->gregset;
      }
  
--- 86,93 ----
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_alloc (gdbarch, tdep,
!                                       i386nbsd_aout_supply_regset, NULL);
        return tdep->gregset;
      }
  
Index: gdb/i386obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386obsd-tdep.c,v
retrieving revision 1.16
diff -c -p -r1.16 i386obsd-tdep.c
*** gdb/i386obsd-tdep.c	20 May 2004 00:53:06 -0000	1.16
--- gdb/i386obsd-tdep.c	21 May 2004 21:49:10 -0000
*************** i386obsd_aout_regset_from_core_section (
*** 141,148 ****
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset
!           = regset_xmalloc (tdep, i386obsd_aout_supply_regset, NULL);
        return tdep->gregset;
      }
  
--- 141,148 ----
        && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
      {
        if (tdep->gregset == NULL)
!         tdep->gregset = regset_alloc (gdbarch, tdep,
!                                       i386obsd_aout_supply_regset, NULL);
        return tdep->gregset;
      }
  
Index: gdb/sparc64fbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64fbsd-tdep.c,v
retrieving revision 1.7
diff -c -p -r1.7 sparc64fbsd-tdep.c
*** gdb/sparc64fbsd-tdep.c	20 May 2004 00:53:06 -0000	1.7
--- gdb/sparc64fbsd-tdep.c	21 May 2004 21:49:11 -0000
*************** sparc64fbsd_init_abi (struct gdbarch_inf
*** 199,209 ****
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset
!     = regset_xmalloc (&sparc64fbsd_gregset, sparc64fbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 256;
  
!   tdep->fpregset = regset_xmalloc (NULL, sparc64fbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 272;
  
    frame_unwind_append_sniffer (gdbarch, sparc64fbsd_sigtramp_frame_sniffer);
--- 199,210 ----
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset = regset_alloc (gdbarch, &sparc64fbsd_gregset,
!                                 sparc64fbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 256;
  
!   tdep->fpregset = regset_alloc (gdbarch, NULL,
!                                  sparc64fbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 272;
  
    frame_unwind_append_sniffer (gdbarch, sparc64fbsd_sigtramp_frame_sniffer);
Index: gdb/sparc64nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64nbsd-tdep.c,v
retrieving revision 1.8
diff -c -p -r1.8 sparc64nbsd-tdep.c
*** gdb/sparc64nbsd-tdep.c	20 May 2004 00:53:06 -0000	1.8
--- gdb/sparc64nbsd-tdep.c	21 May 2004 21:49:11 -0000
*************** sparc64nbsd_init_abi (struct gdbarch_inf
*** 226,236 ****
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset
!     = regset_xmalloc (&sparc64nbsd_gregset, sparc64nbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 160;
  
!   tdep->fpregset = regset_xmalloc (NULL, sparc64nbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 272;
  
    frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
--- 226,237 ----
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset = regset_alloc (gdbarch, &sparc64nbsd_gregset,
!                                 sparc64nbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 160;
  
!   tdep->fpregset = regset_alloc (gdbarch, NULL,
!                                  sparc64nbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 272;
  
    frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
Index: gdb/sparc64obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64obsd-tdep.c,v
retrieving revision 1.4
diff -c -p -r1.4 sparc64obsd-tdep.c
*** gdb/sparc64obsd-tdep.c	20 May 2004 00:53:06 -0000	1.4
--- gdb/sparc64obsd-tdep.c	21 May 2004 21:49:11 -0000
*************** sparc64obsd_init_abi (struct gdbarch_inf
*** 184,192 ****
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset = regset_xmalloc (&sparc64obsd_core_gregset, 
!                                   sparc64obsd_supply_gregset,
!                                   NULL);
    tdep->sizeof_gregset = 832;
  
    frame_unwind_append_sniffer (gdbarch, sparc64obsd_sigtramp_frame_sniffer);
--- 184,191 ----
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
!   tdep->gregset = regset_alloc (gdbarch, &sparc64obsd_core_gregset, 
!                                 sparc64obsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 832;
  
    frame_unwind_append_sniffer (gdbarch, sparc64obsd_sigtramp_frame_sniffer);
Index: gdb/sparcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcnbsd-tdep.c,v
retrieving revision 1.19
diff -c -p -r1.19 sparcnbsd-tdep.c
*** gdb/sparcnbsd-tdep.c	20 May 2004 00:53:06 -0000	1.19
--- gdb/sparcnbsd-tdep.c	21 May 2004 21:49:11 -0000
*************** sparc32nbsd_init_abi (struct gdbarch_inf
*** 274,284 ****
    set_gdbarch_long_double_bit (gdbarch, 64);
    set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
  
!   tdep->gregset
!     = regset_xmalloc (&sparc32nbsd_gregset, sparc32nbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 20 * 4;
  
!   tdep->fpregset = regset_xmalloc (NULL, sparc32nbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 33 * 4;
  
    frame_unwind_append_sniffer (gdbarch, sparc32nbsd_sigtramp_frame_sniffer);
--- 274,285 ----
    set_gdbarch_long_double_bit (gdbarch, 64);
    set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
  
!   tdep->gregset = regset_alloc (gdbarch, &sparc32nbsd_gregset,
!                                 sparc32nbsd_supply_gregset, NULL);
    tdep->sizeof_gregset = 20 * 4;
  
!   tdep->fpregset = regset_alloc (gdbarch, NULL,
!                                  sparc32nbsd_supply_fpregset, NULL);
    tdep->sizeof_fpregset = 33 * 4;
  
    frame_unwind_append_sniffer (gdbarch, sparc32nbsd_sigtramp_frame_sniffer);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]