]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: replace FRAME_OBSTACK_{C,Z}ALLOC macros with templated functions master
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 10 Nov 2025 05:21:33 +0000 (00:21 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 25 Nov 2025 20:09:11 +0000 (15:09 -0500)
While reviewing a patch, I saw these macros and thought they could be
modernized a bit.

Change-Id: I540edbcfd2e1e3cfd6afa0e911f43c8b89862414

61 files changed:
gdb/aarch64-tdep.c
gdb/alpha-mdebug-tdep.c
gdb/alpha-tdep.c
gdb/amd64-tdep.c
gdb/amd64-windows-tdep.c
gdb/amdgpu-tdep.c
gdb/arc-tdep.c
gdb/arm-tdep.c
gdb/avr-tdep.c
gdb/bfin-tdep.c
gdb/cris-tdep.c
gdb/csky-tdep.c
gdb/dummy-frame.c
gdb/dwarf2/frame.c
gdb/frame-unwind.h
gdb/frame.c
gdb/frame.h
gdb/frv-tdep.c
gdb/ft32-tdep.c
gdb/h8300-tdep.c
gdb/hppa-linux-tdep.c
gdb/hppa-tdep.c
gdb/i386-tdep.c
gdb/ia64-libunwind-tdep.c
gdb/ia64-tdep.c
gdb/iq2000-tdep.c
gdb/lm32-tdep.c
gdb/loongarch-tdep.c
gdb/m32c-tdep.c
gdb/m32r-linux-tdep.c
gdb/m32r-tdep.c
gdb/m68hc11-tdep.c
gdb/m68k-tdep.c
gdb/mep-tdep.c
gdb/microblaze-tdep.c
gdb/mips-tdep.c
gdb/mn10300-tdep.c
gdb/moxie-tdep.c
gdb/msp430-tdep.c
gdb/nds32-tdep.c
gdb/record-btrace.c
gdb/riscv-tdep.c
gdb/rl78-tdep.c
gdb/rs6000-tdep.c
gdb/rx-tdep.c
gdb/s390-linux-tdep.c
gdb/s390-tdep.c
gdb/sentinel-frame.c
gdb/sh-tdep.c
gdb/sparc-tdep.c
gdb/tic6x-tdep.c
gdb/tilegx-tdep.c
gdb/trad-frame.c
gdb/trad-frame.h
gdb/tramp-frame.c
gdb/v850-tdep.c
gdb/vax-tdep.c
gdb/windows-tdep.c
gdb/xstormy16-tdep.c
gdb/xtensa-tdep.c
gdb/z80-tdep.c

index e44f84c42f4d154407de4df9edb1e88e68b2665a..db8dff5d03108cb8aaecfa100427a24fb0de7eff 100644 (file)
@@ -1102,12 +1102,10 @@ aarch64_make_prologue_cache_1 (const frame_info_ptr &this_frame,
 static struct aarch64_prologue_cache *
 aarch64_make_prologue_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct aarch64_prologue_cache *cache;
-
   if (*this_cache != NULL)
     return (struct aarch64_prologue_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct aarch64_prologue_cache);
+  auto *cache = frame_obstack_zalloc<aarch64_prologue_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   *this_cache = cache;
 
@@ -1236,12 +1234,10 @@ static const frame_unwind_legacy aarch64_prologue_unwind (
 static struct aarch64_prologue_cache *
 aarch64_make_stub_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct aarch64_prologue_cache *cache;
-
   if (*this_cache != NULL)
     return (struct aarch64_prologue_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct aarch64_prologue_cache);
+  auto *cache = frame_obstack_zalloc<aarch64_prologue_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   *this_cache = cache;
 
index b8fe8f653e582cbca1bbbe354fe0ffdc2652bffa..11a6cb1c8bb0990b9ef117297e607e29e21e7f7b 100644 (file)
@@ -187,7 +187,6 @@ static struct alpha_mdebug_unwind_cache *
 alpha_mdebug_frame_unwind_cache (const frame_info_ptr &this_frame,
                                 void **this_prologue_cache)
 {
-  struct alpha_mdebug_unwind_cache *info;
   struct mdebug_extra_func_info *proc_desc;
   ULONGEST vfp;
   CORE_ADDR pc, reg_position;
@@ -197,7 +196,7 @@ alpha_mdebug_frame_unwind_cache (const frame_info_ptr &this_frame,
   if (*this_prologue_cache)
     return (struct alpha_mdebug_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct alpha_mdebug_unwind_cache);
+  auto *info = frame_obstack_zalloc<alpha_mdebug_unwind_cache> ();
   *this_prologue_cache = info;
   pc = get_frame_address_in_block (this_frame);
 
index 0e29889160f78dcde140e82c5d4486395d7e5dcc..2fd0317d99a3c61ae536b1c48ccbe727fe7f62bc 100644 (file)
@@ -855,12 +855,10 @@ static struct alpha_sigtramp_unwind_cache *
 alpha_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
                                   void **this_prologue_cache)
 {
-  struct alpha_sigtramp_unwind_cache *info;
-
   if (*this_prologue_cache)
     return (struct alpha_sigtramp_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct alpha_sigtramp_unwind_cache);
+  auto *info = frame_obstack_zalloc<alpha_sigtramp_unwind_cache> ();
   *this_prologue_cache = info;
 
   gdbarch *arch = get_frame_arch (this_frame);
@@ -1207,7 +1205,6 @@ alpha_heuristic_frame_unwind_cache (const frame_info_ptr &this_frame,
                                    CORE_ADDR start_pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct alpha_heuristic_unwind_cache *info;
   ULONGEST val;
   CORE_ADDR limit_pc, cur_pc;
   int frame_reg, frame_size, return_reg, reg;
@@ -1215,7 +1212,7 @@ alpha_heuristic_frame_unwind_cache (const frame_info_ptr &this_frame,
   if (*this_prologue_cache)
     return (struct alpha_heuristic_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct alpha_heuristic_unwind_cache);
+  auto *info = frame_obstack_zalloc<alpha_heuristic_unwind_cache> ();
   *this_prologue_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 3cbc022427569a5a43f2054a5c4a47b4aebb5ecd..f7224ff76e779a14a1a43ccf93da21ca9b131f1e 100755 (executable)
@@ -2155,9 +2155,7 @@ amd64_init_frame_cache (struct amd64_frame_cache *cache)
 static struct amd64_frame_cache *
 amd64_alloc_frame_cache (void)
 {
-  struct amd64_frame_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct amd64_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct amd64_frame_cache> ();
   amd64_init_frame_cache (cache);
   return cache;
 }
index c7977d29c3f60f16059b80c0236e3cc05344ab1f..875c39d95501f4b3d15358436d0396fe943aaf1a 100644 (file)
@@ -1084,7 +1084,6 @@ amd64_windows_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct amd64_windows_frame_cache *cache;
   std::array<gdb_byte, 8> buf;
   CORE_ADDR pc;
   CORE_ADDR unwind_info = 0;
@@ -1092,7 +1091,7 @@ amd64_windows_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
   if (*this_cache)
     return (struct amd64_windows_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct amd64_windows_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct amd64_windows_frame_cache> ();
   *this_cache = cache;
 
   /* Get current PC and SP.  */
index e0f64ee4b21e7099605cba7ecd48570e8739ceef..ec2fac09448c6c0e263344eddcaff2adc97788a5 100644 (file)
@@ -863,8 +863,7 @@ amdgpu_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
   if (*this_cache != nullptr)
     return (struct amdgpu_frame_cache *) *this_cache;
 
-  struct amdgpu_frame_cache *cache
-    = FRAME_OBSTACK_ZALLOC (struct amdgpu_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct amdgpu_frame_cache> ();
   (*this_cache) = cache;
 
   cache->pc = get_frame_func (this_frame);
index d7c908b1c6cb079c8b93ea2326ebc51dba1bfb24..db1b98f281795a1fed92d139fd12712ac4801883 100644 (file)
@@ -1688,9 +1688,8 @@ arc_make_frame_cache (const frame_info_ptr &this_frame)
     }
 
   /* Allocate new frame cache instance and space for saved register info.
-     FRAME_OBSTACK_ZALLOC will initialize fields to zeroes.  */
-  struct arc_frame_cache *cache
-    = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
+     frame_obstack_zalloc will initialize fields to zeroes.  */
+  auto *cache = frame_obstack_zalloc<arc_frame_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   arc_analyze_prologue (gdbarch, entrypoint, prologue_end, cache);
@@ -1824,7 +1823,7 @@ arc_make_sigtramp_frame_cache (const frame_info_ptr &this_frame)
   arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (arch);
 
   /* Allocate new frame cache instance and space for saved register info.  */
-  struct arc_frame_cache *cache = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
+  auto *cache = frame_obstack_zalloc<arc_frame_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* Get the stack pointer and use it as the frame base.  */
index 5b7846f77acdf50fc673a03e4fb6fcf643ef9ca7..8845ef27acc8a674e2ad8e7639dfd4f5c09c8d42 100644 (file)
@@ -2309,10 +2309,9 @@ static struct arm_prologue_cache *
 arm_make_prologue_cache (const frame_info_ptr &this_frame)
 {
   int reg;
-  struct arm_prologue_cache *cache;
   CORE_ADDR unwound_fp, prev_sp;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
+  auto *cache = frame_obstack_zalloc<arm_prologue_cache> ();
   arm_cache_init (cache, this_frame);
 
   arm_scan_prologue (this_frame, cache);
@@ -2796,8 +2795,7 @@ arm_exidx_fill_cache (const frame_info_ptr &this_frame, gdb_byte *entry)
   CORE_ADDR vsp = 0;
   int vsp_valid = 0;
 
-  struct arm_prologue_cache *cache;
-  cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
+  auto *cache = frame_obstack_zalloc<arm_prologue_cache> ();
   arm_cache_init (cache, this_frame);
 
   for (;;)
@@ -3199,10 +3197,9 @@ struct frame_unwind_legacy arm_exidx_unwind (
 static struct arm_prologue_cache *
 arm_make_epilogue_frame_cache (const frame_info_ptr &this_frame)
 {
-  struct arm_prologue_cache *cache;
   int reg;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
+  auto *cache = frame_obstack_zalloc<arm_prologue_cache> ();
   arm_cache_init (cache, this_frame);
 
   /* Still rely on the offset calculated from prologue.  */
@@ -3367,9 +3364,7 @@ arm_skip_bx_reg (const frame_info_ptr &frame, CORE_ADDR pc)
 static struct arm_prologue_cache *
 arm_make_stub_cache (const frame_info_ptr &this_frame)
 {
-  struct arm_prologue_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
+  auto *cache = frame_obstack_zalloc<arm_prologue_cache> ();
   arm_cache_init (cache, this_frame);
 
   arm_gdbarch_tdep *tdep
@@ -3445,9 +3440,8 @@ arm_m_exception_cache (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
-  struct arm_prologue_cache *cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
+  auto *cache = frame_obstack_zalloc<arm_prologue_cache> ();
   arm_cache_init (cache, this_frame);
 
   /* ARMv7-M Architecture Reference "B1.5.6 Exception entry behavior"
index 35ac952e73e78debb6eeba927357010610abb39d..4f6d1fc9d00e733e39907415c0c4ff8746ec979f 100644 (file)
@@ -985,14 +985,13 @@ avr_frame_unwind_cache (const frame_info_ptr &this_frame,
   CORE_ADDR start_pc, current_pc;
   ULONGEST prev_sp;
   ULONGEST this_base;
-  struct avr_unwind_cache *info;
   struct gdbarch *gdbarch;
   int i;
 
   if (*this_prologue_cache)
     return (struct avr_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct avr_unwind_cache);
+  auto *info = frame_obstack_zalloc<avr_unwind_cache> ();
   *this_prologue_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 3a96e9f7908bc4cc0adff657e6f10e4cc680d9a9..e454a4db3c427bfe831e16e0f098c3e87a3cf00f 100644 (file)
@@ -265,10 +265,9 @@ struct bfin_frame_cache
 static struct bfin_frame_cache *
 bfin_alloc_frame_cache (void)
 {
-  struct bfin_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct bfin_frame_cache);
+  auto *cache = frame_obstack_zalloc<bfin_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index e6925a617ea4c65085aaddad928b00685464c01d..efa1b18e2cd99b4387606f2e951aa8016ce13917 100644 (file)
@@ -315,7 +315,6 @@ cris_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct cris_unwind_cache *info;
   CORE_ADDR addr;
   gdb_byte buf[4];
   int i;
@@ -323,7 +322,7 @@ cris_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
   if ((*this_cache))
     return (struct cris_unwind_cache *) (*this_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache);
+  auto *info = frame_obstack_zalloc<cris_unwind_cache> ();
   (*this_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
@@ -697,12 +696,11 @@ cris_frame_unwind_cache (const frame_info_ptr &this_frame,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
-  struct cris_unwind_cache *info;
 
   if ((*this_prologue_cache))
     return (struct cris_unwind_cache *) (*this_prologue_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache);
+  auto *info = frame_obstack_zalloc<cris_unwind_cache> ();
   (*this_prologue_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index e6c6e2c6e6d0bf45ebc9bc9bdea8056b1ef1b13e..2d365a4479c5aeb1c16f0f009f7fe3943f5794d1 100644 (file)
@@ -2066,7 +2066,6 @@ static struct csky_unwind_cache *
 csky_frame_unwind_cache (const frame_info_ptr &this_frame)
 {
   CORE_ADDR prologue_start, prologue_end, func_end, prev_pc, block_addr;
-  struct csky_unwind_cache *cache;
   const struct block *bl;
   unsigned long func_size = 0;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -2075,7 +2074,7 @@ csky_frame_unwind_cache (const frame_info_ptr &this_frame)
   /* Default lr type is r15.  */
   lr_type_t lr_type = LR_TYPE_R15;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct csky_unwind_cache);
+  auto *cache = frame_obstack_zalloc<csky_unwind_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* Assume there is no frame until proven otherwise.  */
@@ -2243,9 +2242,7 @@ csky_stub_unwind_sniffer (const struct frame_unwind *self,
 static struct csky_unwind_cache *
 csky_make_stub_cache (const frame_info_ptr &this_frame)
 {
-  struct csky_unwind_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct csky_unwind_cache);
+  auto *cache = frame_obstack_zalloc<struct csky_unwind_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   cache->prev_sp = get_frame_register_unsigned (this_frame, CSKY_SP_REGNUM);
 
index 37ee60cb0e0562ebe4a0c4f76de1f8e5756751bc..43345bc52d53e3ade6f01d0e85093215d37bc409 100644 (file)
@@ -315,9 +315,7 @@ dummy_frame_sniffer (const struct frame_unwind *self,
        {
          if (dummy_frame_id_eq (&dummyframe->id, &dummy_id))
            {
-             struct dummy_frame_cache *cache;
-
-             cache = FRAME_OBSTACK_ZALLOC (struct dummy_frame_cache);
+             auto *cache = frame_obstack_zalloc<dummy_frame_cache> ();
              cache->prev_regcache = get_infcall_suspend_state_regcache
                                                   (dummyframe->caller_state);
              cache->this_id = this_id;
index 1570fd8d714785d9ba7b4fd59186c98ecc8c963a..11a4e0007dc4716043670229548d0b3715e74f32 100644 (file)
@@ -888,7 +888,6 @@ dwarf2_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   const int num_regs = gdbarch_num_cooked_regs (gdbarch);
-  struct dwarf2_frame_cache *cache;
   struct dwarf2_fde *fde;
   CORE_ADDR entry_pc;
   const gdb_byte *instr;
@@ -897,8 +896,8 @@ dwarf2_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
     return (struct dwarf2_frame_cache *) *this_cache;
 
   /* Allocate a new cache.  */
-  cache = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_cache);
-  cache->reg = FRAME_OBSTACK_CALLOC (num_regs, struct dwarf2_frame_state_reg);
+  auto *cache = frame_obstack_zalloc<struct dwarf2_frame_cache> ();
+  cache->reg = frame_obstack_calloc<dwarf2_frame_state_reg> (num_regs);
   *this_cache = cache;
 
   /* Unwind the PC.
@@ -1268,7 +1267,6 @@ void *
 dwarf2_frame_allocate_fn_data (const frame_info_ptr &this_frame, void **this_cache,
                               fn_prev_register cookie, unsigned long size)
 {
-  struct dwarf2_frame_fn_data *fn_data = nullptr;
   struct dwarf2_frame_cache *cache
     = dwarf2_frame_cache (this_frame, this_cache);
 
@@ -1277,7 +1275,7 @@ dwarf2_frame_allocate_fn_data (const frame_info_ptr &this_frame, void **this_cac
   gdb_assert (data == nullptr);
 
   /* No object found, lets create a new instance.  */
-  fn_data = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_fn_data);
+  auto *fn_data = frame_obstack_zalloc<dwarf2_frame_fn_data> ();
   fn_data->cookie = cookie;
   fn_data->data = frame_obstack_zalloc (size);
   fn_data->next = cache->fn_data;
index a967b7c4d3784c241374a8e181252c46e6c175d1..7fa2035772a540df0f40d1f75672b236baf17839 100644 (file)
@@ -103,7 +103,7 @@ extern CORE_ADDR default_unwind_sp (struct gdbarch *gdbarch,
 
    THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
    with the other unwind methods.  Memory for that cache should be
-   allocated using FRAME_OBSTACK_ZALLOC().  */
+   allocated using frame_obstack_zalloc.  */
 
 typedef void (frame_this_id_ftype) (const frame_info_ptr &this_frame,
                                    void **this_prologue_cache,
@@ -138,7 +138,7 @@ typedef void (frame_this_id_ftype) (const frame_info_ptr &this_frame,
 
    THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
    with the other unwind methods.  Memory for that cache should be
-   allocated using FRAME_OBSTACK_ZALLOC().  */
+   allocated using frame_obstack_zalloc.  */
 
 typedef value *(frame_prev_register_ftype) (const frame_info_ptr &this_frame,
                                            void **this_prologue_cache,
index 6c646e5faff708cb4c6a190369009da4bdfec368..2442f5d5b08f0ddc2f0e8f31a4815a5db4fe862d 100644 (file)
@@ -1657,7 +1657,7 @@ create_sentinel_frame (program_space *pspace, address_space *aspace,
                       regcache *regcache, CORE_ADDR stack_addr,
                       CORE_ADDR code_addr)
 {
-  frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
+  frame_info *frame = frame_obstack_zalloc<frame_info> ();
 
   frame->level = -1;
   frame->pspace = pspace;
@@ -2055,7 +2055,7 @@ create_new_frame (frame_id id)
   if (frame != nullptr)
     return frame;
 
-  frame_info *fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
+  frame_info *fi = frame_obstack_zalloc<frame_info> ();
 
   fi->next = create_sentinel_frame (current_program_space,
                                    current_inferior ()->aspace.get (),
@@ -2571,7 +2571,7 @@ get_prev_frame_raw (const frame_info_ptr &this_frame)
      quickly reclaimed when the frame cache is flushed, and the `we've
      been here before' check above will stop repeated memory
      allocation calls.  */
-  prev_frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
+  prev_frame = frame_obstack_zalloc<frame_info> ();
   prev_frame->level = this_frame->level + 1;
 
   /* For now, assume we don't have frame chains crossing address
index 99a79835efafb93f371c1177f123ebac5c1885ca..086abc86b519d85fcb0c8174bbd071b37fea4808 100644 (file)
@@ -823,10 +823,24 @@ enum print_what
    allocate memory using this method.  */
 
 extern void *frame_obstack_zalloc (unsigned long size);
-#define FRAME_OBSTACK_ZALLOC(TYPE) \
-  ((TYPE *) frame_obstack_zalloc (sizeof (TYPE)))
-#define FRAME_OBSTACK_CALLOC(NUMBER,TYPE) \
-  ((TYPE *) frame_obstack_zalloc ((NUMBER) * sizeof (TYPE)))
+
+/* Allocate one instance of T using frame_obstack_zalloc.  */
+
+template <typename T>
+T *
+frame_obstack_zalloc ()
+{
+  return static_cast<T *> (frame_obstack_zalloc (sizeof (T)));
+}
+
+/* Allocate N instances of T using frame_obstack_zalloc.  */
+
+template <typename T>
+T *
+frame_obstack_calloc (int n)
+{
+  return static_cast<T *> (frame_obstack_zalloc (n * sizeof (T)));
+}
 
 class readonly_detached_regcache;
 /* Create a regcache, and copy the frame's registers into it.  */
index e8de8440fb439643da5415432578b8473f68da98..b47ae96e1b9d14a657f6f5d7e0b5be021df272fd 100644 (file)
@@ -1088,12 +1088,11 @@ frv_frame_unwind_cache (const frame_info_ptr &this_frame,
                         void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct frv_unwind_cache *info;
 
   if ((*this_prologue_cache))
     return (struct frv_unwind_cache *) (*this_prologue_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct frv_unwind_cache);
+  auto *info = frame_obstack_zalloc<frv_unwind_cache> ();
   (*this_prologue_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 441364a7e171b8a4cb496b7d084b719210c50269..b1ebd7209eeab7da8cdd3d288a62873ebb509621 100644 (file)
@@ -437,10 +437,9 @@ ft32_return_value (struct gdbarch *gdbarch, struct value *function,
 static struct ft32_frame_cache *
 ft32_alloc_frame_cache (void)
 {
-  struct ft32_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct ft32_frame_cache);
+  auto *cache = frame_obstack_zalloc<ft32_frame_cache> ();
 
   for (i = 0; i < FT32_NUM_REGS; ++i)
     cache->saved_regs[i] = REG_UNAVAIL;
index 89907b86d9e2cfb81032672e1e58107d0e27116a..0db5ee6599303bef0fe36595c1e0a63f0507f885 100644 (file)
@@ -407,14 +407,13 @@ static struct h8300_frame_cache *
 h8300_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct h8300_frame_cache *cache;
   int i;
   CORE_ADDR current_pc;
 
   if (*this_cache)
     return (struct h8300_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct h8300_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct h8300_frame_cache> ();
   h8300_init_frame_cache (gdbarch, cache);
   *this_cache = cache;
 
index da5559c07abc1853c65dfafaffaf20b98010a7cf..16a06cc8e43ded225a99335e30434b142fd71525 100644 (file)
@@ -198,14 +198,13 @@ hppa_linux_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
                                        void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct hppa_linux_sigtramp_unwind_cache *info;
   CORE_ADDR pc, scptr;
   int i;
 
   if (*this_cache)
     return (struct hppa_linux_sigtramp_unwind_cache *) *this_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct hppa_linux_sigtramp_unwind_cache);
+  auto *info = frame_obstack_zalloc<hppa_linux_sigtramp_unwind_cache> ();
   *this_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index c419c371a6a9092d3b53e187177a4681f16d28c3..42288bdcd8ccf4e035c89088ca0cbaff012b3851 100644 (file)
@@ -1864,7 +1864,6 @@ hppa_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
-  struct hppa_frame_cache *cache;
   long saved_gr_mask;
   long saved_fr_mask;
   long frame_size;
@@ -1884,7 +1883,7 @@ hppa_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
                    paddress (gdbarch, ((struct hppa_frame_cache *)*this_cache)->base));
       return (struct hppa_frame_cache *) (*this_cache);
     }
-  cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct hppa_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
@@ -2316,7 +2315,6 @@ hppa_fallback_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct hppa_frame_cache *cache;
   unsigned int frame_size = 0;
   int found_rp = 0;
   CORE_ADDR start_pc;
@@ -2326,7 +2324,7 @@ hppa_fallback_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
                "{ hppa_fallback_frame_cache (frame=%d) -> ",
                frame_relative_level (this_frame));
 
-  cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct hppa_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
@@ -2427,12 +2425,10 @@ static struct hppa_stub_unwind_cache *
 hppa_stub_frame_unwind_cache (const frame_info_ptr &this_frame,
                              void **this_cache)
 {
-  struct hppa_stub_unwind_cache *info;
-
   if (*this_cache)
     return (struct hppa_stub_unwind_cache *) *this_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct hppa_stub_unwind_cache);
+  auto *info = frame_obstack_zalloc<hppa_stub_unwind_cache> ();
   *this_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 72d880a7a8a0b9a159fa99c1beb49681d8e1e322..b201d2a4139616aa4e767fd69d29bd4d835a5818 100644 (file)
@@ -1030,10 +1030,9 @@ struct i386_frame_cache
 static struct i386_frame_cache *
 i386_alloc_frame_cache (void)
 {
-  struct i386_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct i386_frame_cache);
+  auto *cache = frame_obstack_zalloc<i386_frame_cache> ();
 
   /* Base address.  */
   cache->base_p = 0;
index c17e1aa66d6d78efcaefab941c6312063ec7d24a..acae3e4796dedf40ebc0780e8cfa0e03dccb2911 100644 (file)
@@ -158,7 +158,6 @@ libunwind_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
   unw_addr_space_t as;
   unw_word_t fp;
   unw_regnum_t uw_sp_regnum;
-  struct libunwind_frame_cache *cache;
   struct libunwind_descr *descr;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int ret;
@@ -167,7 +166,7 @@ libunwind_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
     return (struct libunwind_frame_cache *) *this_cache;
 
   /* Allocate a new cache.  */
-  cache = FRAME_OBSTACK_ZALLOC (struct libunwind_frame_cache);
+  auto *cache = frame_obstack_zalloc<libunwind_frame_cache> ();
 
   cache->func_addr = get_frame_func (this_frame);
   if (cache->func_addr == 0)
index 42435d1b48b884bfd449e126fe0b0599ca012204..ee3b5120ed5ecffc497a28d0d6acb65360e02fb7 100644 (file)
@@ -1336,10 +1336,9 @@ refine_prologue_limit (CORE_ADDR pc, CORE_ADDR lim_pc, int *trust_limit)
 static struct ia64_frame_cache *
 ia64_alloc_frame_cache (void)
 {
-  struct ia64_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct ia64_frame_cache);
+  auto *cache = frame_obstack_zalloc<ia64_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index 1912e9ba7b07d936dd5067a6f60ea219c9fac2ae..ea566884fe2c883600d76a18639a916633aa17f5 100644 (file)
@@ -361,14 +361,13 @@ static struct iq2000_frame_cache *
 iq2000_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct iq2000_frame_cache *cache;
   CORE_ADDR current_pc;
   int i;
 
   if (*this_cache)
     return (struct iq2000_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct iq2000_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct iq2000_frame_cache> ();
   iq2000_init_frame_cache (cache);
   *this_cache = cache;
 
index 80411626621e64712519a7a69eb60bdf0ced8146..5f5881ddd11faa3baef570851a37f097a4248800 100644 (file)
@@ -384,13 +384,12 @@ lm32_frame_cache (const frame_info_ptr &this_frame, void **this_prologue_cache)
   CORE_ADDR current_pc;
   ULONGEST prev_sp;
   ULONGEST this_base;
-  struct lm32_frame_cache *info;
   int i;
 
   if ((*this_prologue_cache))
     return (struct lm32_frame_cache *) (*this_prologue_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct lm32_frame_cache);
+  auto *info = frame_obstack_zalloc<struct lm32_frame_cache> ();
   (*this_prologue_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 21a3e53779344130f97808a340b969ef5fdbee60..107a243af70e5e8697731a7a3aca6157ff80292d 100644 (file)
@@ -667,12 +667,10 @@ loongarch_frame_cache_1 (const frame_info_ptr &this_frame,
 static struct loongarch_frame_cache *
 loongarch_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct loongarch_frame_cache *cache;
-
   if (*this_cache != NULL)
     return (struct loongarch_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct loongarch_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct loongarch_frame_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   *this_cache = cache;
 
index 0b26e407fc6bc19335a2e0226fe3febd06969f66..62969e90b5a037d78198301a98388970c4bbec5c 100644 (file)
@@ -1867,7 +1867,7 @@ m32c_analyze_frame_prologue (const frame_info_ptr &this_frame,
       if (! func_start)
        stop_addr = func_start;
 
-      *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct m32c_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<m32c_prologue> ();
       m32c_analyze_prologue (get_frame_arch (this_frame),
                             func_start, stop_addr,
                             (struct m32c_prologue *) *this_prologue_cache);
index 03000cc99da00a974eba84d8d11d2af9474fad88..71bd0d9c3d9d1fc0b32ba0f26f232d195208d333 100644 (file)
@@ -227,13 +227,12 @@ static struct m32r_frame_cache *
 m32r_linux_sigtramp_frame_cache (const frame_info_ptr &this_frame,
                                 void **this_cache)
 {
-  struct m32r_frame_cache *cache;
   CORE_ADDR sigcontext_addr, addr;
   int regnum;
 
   if ((*this_cache) != NULL)
     return (struct m32r_frame_cache *) (*this_cache);
-  cache = FRAME_OBSTACK_ZALLOC (struct m32r_frame_cache);
+  auto *cache = frame_obstack_zalloc<m32r_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index bc5f05ed505fa3d8cba12d584ce49b6565ad7d07..7ef6dad96ea05ad5c5c1e0382930cd76009ba551 100644 (file)
@@ -524,13 +524,11 @@ m32r_frame_unwind_cache (const frame_info_ptr &this_frame,
   ULONGEST this_base;
   unsigned long op;
   int i;
-  struct m32r_unwind_cache *info;
-
 
   if ((*this_prologue_cache))
     return (struct m32r_unwind_cache *) (*this_prologue_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct m32r_unwind_cache);
+  auto *info = frame_obstack_zalloc<m32r_unwind_cache> ();
   (*this_prologue_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 83a57edae00b606773b98a9142ba44f81d15f3cc..55b26f9bf99320a4ff7596c68e0cc4fcd55efb7e 100644 (file)
@@ -780,14 +780,13 @@ m68hc11_frame_unwind_cache (const frame_info_ptr &this_frame,
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   ULONGEST prev_sp;
   ULONGEST this_base;
-  struct m68hc11_unwind_cache *info;
   CORE_ADDR current_pc;
   int i;
 
   if ((*this_prologue_cache))
     return (struct m68hc11_unwind_cache *) (*this_prologue_cache);
 
-  info = FRAME_OBSTACK_ZALLOC (struct m68hc11_unwind_cache);
+  auto *info = frame_obstack_zalloc<m68hc11_unwind_cache> ();
   (*this_prologue_cache) = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 3fa158a0338a6bf79dbc2df2bcb905194b959d54..98d3146499365d9f530ca525809b08e48a60bea2 100644 (file)
@@ -634,10 +634,9 @@ struct m68k_frame_cache
 static struct m68k_frame_cache *
 m68k_alloc_frame_cache (void)
 {
-  struct m68k_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache);
+  auto *cache = frame_obstack_zalloc<m68k_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index 1821cba7e5fe489e04ac8191f982243cb7bfc48b..04b02d892689fb4e2b4dcaa8fa54f51990bb43e0 100644 (file)
@@ -1920,8 +1920,7 @@ mep_analyze_frame_prologue (const frame_info_ptr &this_frame,
     {
       CORE_ADDR func_start, stop_addr;
 
-      *this_prologue_cache
-       = FRAME_OBSTACK_ZALLOC (struct mep_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<mep_prologue> ();
 
       func_start = get_frame_func (this_frame);
       stop_addr = get_frame_pc (this_frame);
index 72233444f34d7c935fa73c42e4833aa630f2a90f..f4ab2ec595fba50bd2ef8c47fb7c4300b5eedb13 100644 (file)
@@ -135,9 +135,7 @@ typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
 static struct microblaze_frame_cache *
 microblaze_alloc_frame_cache (void)
 {
-  struct microblaze_frame_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct microblaze_frame_cache);
+  auto *cache = frame_obstack_zalloc<microblaze_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index 2bd2db0bc771f24a8cf407ff37e2b9e71c458b72..6657f14b37acfdcf242c9c6496794f82bfb5c2c4 100644 (file)
@@ -2866,11 +2866,10 @@ static struct mips_frame_cache *
 mips_insn16_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct mips_frame_cache *cache;
 
   if ((*this_cache) != NULL)
     return (struct mips_frame_cache *) (*this_cache);
-  cache = FRAME_OBSTACK_ZALLOC (struct mips_frame_cache);
+  auto *cache = frame_obstack_zalloc<mips_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
@@ -3300,12 +3299,11 @@ static struct mips_frame_cache *
 mips_micro_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct mips_frame_cache *cache;
 
   if ((*this_cache) != NULL)
     return (struct mips_frame_cache *) (*this_cache);
 
-  cache = FRAME_OBSTACK_ZALLOC (struct mips_frame_cache);
+  auto *cache = frame_obstack_zalloc<mips_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
@@ -3681,12 +3679,11 @@ static struct mips_frame_cache *
 mips_insn32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct mips_frame_cache *cache;
 
   if ((*this_cache) != NULL)
     return (struct mips_frame_cache *) (*this_cache);
 
-  cache = FRAME_OBSTACK_ZALLOC (struct mips_frame_cache);
+  auto *cache = frame_obstack_zalloc<mips_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 3749c65f6cf33048ee787be5d54628bc8c9849bf..e6e7f3df247384da804d8f82f31940e940583e9b 100644 (file)
@@ -1049,7 +1049,7 @@ mn10300_analyze_frame_prologue (const frame_info_ptr &this_frame,
     {
       CORE_ADDR func_start, stop_addr;
 
-      *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct mn10300_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<mn10300_prologue> ();
 
       func_start = get_frame_func (this_frame);
       stop_addr = get_frame_pc (this_frame);
index 831c95e0fa125480baa40efea651abac6a12c458..17007a04e38e5ad548b2230dea6d1275d0e33e62 100644 (file)
@@ -496,10 +496,9 @@ moxie_return_value (struct gdbarch *gdbarch, struct value *function,
 static struct moxie_frame_cache *
 moxie_alloc_frame_cache (void)
 {
-  struct moxie_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct moxie_frame_cache);
+  auto *cache = frame_obstack_zalloc<moxie_frame_cache> ();
 
   cache->base = 0;
   cache->saved_sp = 0;
index 7ac26b958c328fef4eb9e60ab9734fda9d5d0db4..310cbeeeaf04002647f3165d360a8133d28d3bba 100644 (file)
@@ -465,7 +465,7 @@ msp430_analyze_frame_prologue (const frame_info_ptr &this_frame,
     {
       CORE_ADDR func_start, stop_addr;
 
-      *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct msp430_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<msp430_prologue> ();
 
       func_start = get_frame_func (this_frame);
       stop_addr = get_frame_pc (this_frame);
index 9180cd0c6d180ab8093cf3138b8276ab64008261..f0a0b338931b062848fa3593d195605c40d7a41e 100644 (file)
@@ -551,10 +551,9 @@ struct nds32_frame_cache
 static struct nds32_frame_cache *
 nds32_alloc_frame_cache (void)
 {
-  struct nds32_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct nds32_frame_cache);
+  auto *cache = frame_obstack_zalloc<nds32_frame_cache> ();
 
   /* Initialize fp_offset to check if FP is set in prologue.  */
   cache->fp_offset = INVALID_OFFSET;
index a9f05a26d1728b4eeafbed0c1486720a45df5c63..98bbc115cfeb17d7be57abef123cf9bb7b38c31a 100644 (file)
@@ -1675,10 +1675,8 @@ static gdb::unordered_map<frame_info *, btrace_frame_cache *> bfcache;
 static struct btrace_frame_cache *
 bfcache_new (const frame_info_ptr &frame)
 {
-  struct btrace_frame_cache *cache
-    = FRAME_OBSTACK_ZALLOC (struct btrace_frame_cache);
+  auto *cache = frame_obstack_zalloc<btrace_frame_cache> ();
   bfcache.emplace (frame.get (), cache);
-
   return cache;
 }
 
index 76d10a3b2989280d9405290f59708b36349cdf80..0c86fcd7196a67e23d86b2b98e4bda5b116f65d1 100644 (file)
@@ -3828,14 +3828,13 @@ static struct riscv_unwind_cache *
 riscv_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   CORE_ADDR pc, start_addr;
-  struct riscv_unwind_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int numregs, regno;
 
   if ((*this_cache) != NULL)
     return (struct riscv_unwind_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct riscv_unwind_cache);
+  auto *cache = frame_obstack_zalloc<riscv_unwind_cache> ();
   cache->regs = trad_frame_alloc_saved_regs (this_frame);
   (*this_cache) = cache;
 
index 846064cc3d86254c7b3b229313b6be748ae71b0a..b310a620e1fdd0ab3d0eeae14faa82c7c7d9cde8 100644 (file)
@@ -1099,7 +1099,7 @@ rl78_analyze_frame_prologue (const frame_info_ptr &this_frame,
     {
       CORE_ADDR func_start, stop_addr;
 
-      *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct rl78_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<rl78_prologue> ();
 
       func_start = get_frame_func (this_frame);
       stop_addr = get_frame_pc (this_frame);
index fc64e3ee69e6db8787756708adb75bd778abf167..b73ab87b69910c7461c14d3507eb649a7b455fdf 100644 (file)
@@ -3618,7 +3618,6 @@ struct rs6000_frame_cache
 static struct rs6000_frame_cache *
 rs6000_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct rs6000_frame_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -3628,7 +3627,7 @@ rs6000_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 
   if ((*this_cache) != NULL)
     return (struct rs6000_frame_cache *) (*this_cache);
-  cache = FRAME_OBSTACK_ZALLOC (struct rs6000_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct rs6000_frame_cache> ();
   (*this_cache) = cache;
   cache->pc = 0;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
@@ -3854,7 +3853,6 @@ static const struct frame_unwind_legacy rs6000_frame_unwind (
 static struct rs6000_frame_cache *
 rs6000_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct rs6000_frame_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
   struct rs6000_framedata fdata;
@@ -3863,7 +3861,7 @@ rs6000_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache
   if (*this_cache)
     return (struct rs6000_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct rs6000_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct rs6000_frame_cache> ();
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index d11d1d26811c320e6d9ee3cf8a68a0acc0eeeff0..c7b1dfa6ae7ef8bdef1b05ed002eb68df0919fd1 100644 (file)
@@ -391,7 +391,7 @@ rx_analyze_frame_prologue (const frame_info_ptr &this_frame,
     {
       CORE_ADDR func_start, stop_addr;
 
-      *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct rx_prologue);
+      *this_prologue_cache = frame_obstack_zalloc<rx_prologue> ();
 
       func_start = get_frame_func (this_frame);
       stop_addr = get_frame_pc (this_frame);
index 66e571d47dd3be5148c8da7c432132e65009ccf5..593befb495a9325f3882f170c2d531725fcf1132 100644 (file)
@@ -396,7 +396,6 @@ s390_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
   s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct s390_sigtramp_unwind_cache *info;
   ULONGEST this_sp, prev_sp;
   CORE_ADDR next_ra, next_cfa, sigreg_ptr, sigreg_high_off;
   int i;
@@ -404,7 +403,7 @@ s390_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
   if (*this_prologue_cache)
     return (struct s390_sigtramp_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct s390_sigtramp_unwind_cache);
+  auto *info = frame_obstack_zalloc<s390_sigtramp_unwind_cache> ();
   *this_prologue_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 0cef5f4645d09129c617cf2347b6f75a8672f9a8..c78eccbe4ca249ada09210ec9943f7f49cf5f6b0 100644 (file)
@@ -2720,12 +2720,10 @@ static struct s390_unwind_cache *
 s390_frame_unwind_cache (const frame_info_ptr &this_frame,
                         void **this_prologue_cache)
 {
-  struct s390_unwind_cache *info;
-
   if (*this_prologue_cache)
     return (struct s390_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache);
+  auto *info = frame_obstack_zalloc<s390_unwind_cache> ();
   *this_prologue_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   info->func = -1;
@@ -2812,13 +2810,12 @@ s390_stub_frame_unwind_cache (const frame_info_ptr &this_frame,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
-  struct s390_stub_unwind_cache *info;
   ULONGEST reg;
 
   if (*this_prologue_cache)
     return (struct s390_stub_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache);
+  auto *info = frame_obstack_zalloc<s390_stub_unwind_cache> ();
   *this_prologue_cache = info;
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
index 950588e9a3a079decef24ccb4393b002987e13a2..983ff4666451a81a9f18838f3b4c6a27302b4ead 100644 (file)
@@ -31,8 +31,7 @@ struct frame_unwind_cache
 void *
 sentinel_frame_cache (struct regcache *regcache)
 {
-  struct frame_unwind_cache *cache =
-    FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
+  auto *cache = frame_obstack_zalloc<frame_unwind_cache> ();
 
   cache->regcache = regcache;
   return cache;
index e7ab41f051fb030530ae0ecfe9e7342f51a40b89..d70188d0dc79a20d9239ad3f0f49e8dbd8fc5808 100644 (file)
@@ -1821,10 +1821,9 @@ sh_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 static struct sh_frame_cache *
 sh_alloc_frame_cache (void)
 {
-  struct sh_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct sh_frame_cache);
+  auto *cache = frame_obstack_zalloc<sh_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index 926afa3b9303e51c0ff7150d0b181f08b9d4b687..2ee508b6b8b18af7320d1de150821661df1f95bc 100644 (file)
@@ -751,9 +751,7 @@ typedef BP_MANIPULATION (sparc_break_insn) sparc_breakpoint;
 static struct sparc_frame_cache *
 sparc_alloc_frame_cache (void)
 {
-  struct sparc_frame_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct sparc_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct sparc_frame_cache> ();
 
   /* Base address.  */
   cache->base = 0;
index 56d309871ea2764ea962e8a940100fd2aa31a019..499cc0685b0ec83cb6930b21df300aec7ed1b492 100644 (file)
@@ -381,12 +381,11 @@ tic6x_frame_unwind_cache (const frame_info_ptr &this_frame,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR current_pc;
-  struct tic6x_unwind_cache *cache;
 
   if (*this_prologue_cache)
     return (struct tic6x_unwind_cache *) *this_prologue_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
+  auto *cache = frame_obstack_zalloc<tic6x_unwind_cache> ();
   (*this_prologue_cache) = cache;
 
   cache->return_regnum = TIC6X_RA_REGNUM;
@@ -475,9 +474,7 @@ static const struct frame_base tic6x_frame_base =
 static struct tic6x_unwind_cache *
 tic6x_make_stub_cache (const frame_info_ptr &this_frame)
 {
-  struct tic6x_unwind_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
+  auto *cache = frame_obstack_zalloc<tic6x_unwind_cache> ();
 
   cache->return_regnum = TIC6X_RA_REGNUM;
 
index c525644017d2f68e602161efed6ef7fc3da59a09..4ec14b96033d450e06a12a72f7c808ae934fe4e3 100644 (file)
@@ -836,13 +836,12 @@ static struct tilegx_frame_cache *
 tilegx_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  struct tilegx_frame_cache *cache;
   CORE_ADDR current_pc;
 
   if (*this_cache)
     return (struct tilegx_frame_cache *) *this_cache;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct tilegx_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct tilegx_frame_cache> ();
   *this_cache = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   cache->base = 0;
index 470f31d4b97b822d62c9b35c97dcf275e9b59987..c38b578f0fa1f0c4381c08dd90a6b1da5457d859 100644 (file)
@@ -38,9 +38,7 @@ struct trad_frame_cache
 struct trad_frame_cache *
 trad_frame_cache_zalloc (const frame_info_ptr &this_frame)
 {
-  struct trad_frame_cache *this_trad_cache;
-
-  this_trad_cache = FRAME_OBSTACK_ZALLOC (struct trad_frame_cache);
+  auto *this_trad_cache = frame_obstack_zalloc<trad_frame_cache> ();
   this_trad_cache->prev_regs = trad_frame_alloc_saved_regs (this_frame);
   this_trad_cache->this_frame = this_frame;
   return this_trad_cache;
@@ -64,8 +62,7 @@ trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
   static_assert (std::is_trivially_constructible<trad_frame_saved_reg>::value);
 
   int numregs = gdbarch_num_cooked_regs (gdbarch);
-  trad_frame_saved_reg *this_saved_regs
-    = FRAME_OBSTACK_CALLOC (numregs, trad_frame_saved_reg);
+  auto *this_saved_regs = frame_obstack_calloc<trad_frame_saved_reg> (numregs);
 
   /* For backwards compatibility, initialize all the register values to
      REALREG, with register 0 stored in 0, register 1 stored in 1 and so
index 9039e8b2a800ab2a658410bf2c4df5d7931d3fcd..02f1c8c9bd441d7f778c6d6182b6b36d7bc1b9d3 100644 (file)
@@ -117,7 +117,7 @@ struct trad_frame_saved_reg
   void set_value_bytes (gdb::array_view<const gdb_byte> bytes)
   {
     /* Allocate the space and copy the data bytes.  */
-    gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte);
+    auto *data = frame_obstack_calloc<gdb_byte> (bytes.size ());
     memcpy (data, bytes.data (), bytes.size ());
 
     m_kind = trad_frame_saved_reg_kind::VALUE_BYTES;
index 5fea5bbbd696b1f8b33b4e2f48e2cafafb330338..562feab7cc3fe6d714274b17e9f42db29138b587 100644 (file)
@@ -157,7 +157,6 @@ frame_unwind_trampoline::sniff (const frame_info_ptr &this_frame,
   const struct tramp_frame *tramp = unwind_data ()->tramp_frame;
   CORE_ADDR pc = get_frame_pc (this_frame);
   CORE_ADDR func;
-  struct tramp_frame_cache *tramp_cache;
 
   /* tausq/2004-12-12: We used to assume if pc has a name or is in a valid
      section, then this is not a trampoline.  However, this assumption is
@@ -166,7 +165,7 @@ frame_unwind_trampoline::sniff (const frame_info_ptr &this_frame,
   func = tramp_frame_start (tramp, this_frame, pc);
   if (func == 0)
     return 0;
-  tramp_cache = FRAME_OBSTACK_ZALLOC (struct tramp_frame_cache);
+  auto *tramp_cache = frame_obstack_zalloc<struct tramp_frame_cache> ();
   tramp_cache->func = func;
   tramp_cache->tramp_frame = tramp;
   (*this_cache) = tramp_cache;
index c544fe18ff2fba091d52a96961cfda774e0412cc..cd0635b5b2c001af28de4b31a6678f06548a5bbc 100644 (file)
@@ -1214,9 +1214,7 @@ v850_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 static struct v850_frame_cache *
 v850_alloc_frame_cache (const frame_info_ptr &this_frame)
 {
-  struct v850_frame_cache *cache;
-
-  cache = FRAME_OBSTACK_ZALLOC (struct v850_frame_cache);
+  auto *cache = frame_obstack_zalloc<v850_frame_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* Base address.  */
index 0a83f4f914cd6bc4d50568e73e153e61482bdd51..a6af8831c3c549f02c022b376a9cc095f5158fb9 100644 (file)
@@ -305,7 +305,6 @@ struct vax_frame_cache
 static struct vax_frame_cache *
 vax_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
-  struct vax_frame_cache *cache;
   CORE_ADDR addr;
   ULONGEST mask;
   int regnum;
@@ -314,7 +313,7 @@ vax_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
     return (struct vax_frame_cache *) *this_cache;
 
   /* Allocate a new cache.  */
-  cache = FRAME_OBSTACK_ZALLOC (struct vax_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct vax_frame_cache> ();
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* The frame pointer is used as the base for the frame.  */
index f77b21cef93f671fb3769f6c6721028976bad0ab..68d40b8373af0dc5096a128e76d4b2e17447950e 100644 (file)
@@ -1387,7 +1387,7 @@ cygwin_sigwrapper_frame_unwind::sniff (const frame_info_ptr &this_frame,
 
   frame_debug_printf ("sigstackptroffset=%x", tlsoffset);
 
-  auto *cache = FRAME_OBSTACK_ZALLOC (struct cygwin_sigwrapper_frame_cache);
+  auto *cache = frame_obstack_zalloc<struct cygwin_sigwrapper_frame_cache> ();
   cache->tlsoffset = tlsoffset;
 
   *this_cache = cache;
index 819c54ba4ba8e9996c8862cc14a4193dadf82429..d75e10428e13af61e7d99e62f52dc14752213143 100644 (file)
@@ -636,10 +636,9 @@ xstormy16_address_to_pointer (struct gdbarch *gdbarch,
 static struct xstormy16_frame_cache *
 xstormy16_alloc_frame_cache (void)
 {
-  struct xstormy16_frame_cache *cache;
   int i;
 
-  cache = FRAME_OBSTACK_ZALLOC (struct xstormy16_frame_cache);
+  auto *cache = frame_obstack_zalloc<xstormy16_frame_cache> ();
 
   cache->base = 0;
   cache->saved_sp = 0;
index 88ad81511c6c5f9a60b235013098e3094ffe605e..48ca4bd9eece055b254ba8f5d15958b38fd4d186 100644 (file)
@@ -975,12 +975,11 @@ typedef struct xtensa_frame_cache
 static struct xtensa_frame_cache *
 xtensa_alloc_frame_cache (int windowed)
 {
-  xtensa_frame_cache_t *cache;
   int i;
 
   DEBUGTRACE ("xtensa_alloc_frame_cache ()\n");
 
-  cache = FRAME_OBSTACK_ZALLOC (xtensa_frame_cache_t);
+  auto *cache = frame_obstack_zalloc<xtensa_frame_cache_t> ();
 
   cache->base = 0;
   cache->pc = 0;
index 31d319392ddbac25d5bd28c2c872713f57981a9f..6a099cd6e74a96e208331586f7777317a839ef67 100644 (file)
@@ -562,7 +562,6 @@ z80_frame_unwind_cache (const frame_info_ptr &this_frame,
   ULONGEST this_base;
   int i;
   gdb_byte buf[sizeof(void*)];
-  struct z80_unwind_cache *info;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
   int addr_len = tdep->addr_length;
@@ -570,7 +569,7 @@ z80_frame_unwind_cache (const frame_info_ptr &this_frame,
   if (*this_prologue_cache)
     return (struct z80_unwind_cache *) *this_prologue_cache;
 
-  info = FRAME_OBSTACK_ZALLOC (struct z80_unwind_cache);
+  auto *info = frame_obstack_zalloc<z80_unwind_cache> ();
   memset (info, 0, sizeof (*info));
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
   *this_prologue_cache = info;