From: Simon Marchi Date: Mon, 10 Nov 2025 05:21:33 +0000 (-0500) Subject: gdb: replace FRAME_OBSTACK_{C,Z}ALLOC macros with templated functions X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab591baddaf8470f7502135655e3b22163b58460;p=thirdparty%2Fbinutils-gdb.git gdb: replace FRAME_OBSTACK_{C,Z}ALLOC macros with templated functions While reviewing a patch, I saw these macros and thought they could be modernized a bit. Change-Id: I540edbcfd2e1e3cfd6afa0e911f43c8b89862414 --- diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index e44f84c42f4..db8dff5d031 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -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 (); 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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); *this_cache = cache; diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c index b8fe8f653e5..11a6cb1c8bb 100644 --- a/gdb/alpha-mdebug-tdep.c +++ b/gdb/alpha-mdebug-tdep.c @@ -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 (); *this_prologue_cache = info; pc = get_frame_address_in_block (this_frame); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 0e29889160f..2fd0317d99a 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -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 (); *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 (); *this_prologue_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 3cbc0224275..f7224ff76e7 100755 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -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 (); amd64_init_frame_cache (cache); return cache; } diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index c7977d29c3f..875c39d9550 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -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 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 (); *this_cache = cache; /* Get current PC and SP. */ diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index e0f64ee4b21..ec2fac09448 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -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 (); (*this_cache) = cache; cache->pc = get_frame_func (this_frame); diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index d7c908b1c6c..db1b98f2817 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -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 (); 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 (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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); /* Get the stack pointer and use it as the frame base. */ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 5b7846f77ac..8845ef27acc 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -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_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_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_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_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 (gdbarch); - struct arm_prologue_cache *cache; - cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); + auto *cache = frame_obstack_zalloc (); arm_cache_init (cache, this_frame); /* ARMv7-M Architecture Reference "B1.5.6 Exception entry behavior" diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 35ac952e73e..4f6d1fc9d00 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -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 (); *this_prologue_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 3a96e9f7908..e454a4db3c4 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index e6925a617ea..efa1b18e2cd 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -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 (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 (); (*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 (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 (); (*this_prologue_cache) = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index e6c6e2c6e6d..2d365a4479c 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -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 (); 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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); cache->prev_sp = get_frame_register_unsigned (this_frame, CSKY_SP_REGNUM); diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index 37ee60cb0e0..43345bc52d5 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -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 (); cache->prev_regcache = get_infcall_suspend_state_regcache (dummyframe->caller_state); cache->this_id = this_id; diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 1570fd8d714..11a4e0007dc 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -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 (); + cache->reg = frame_obstack_calloc (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 (); fn_data->cookie = cookie; fn_data->data = frame_obstack_zalloc (size); fn_data->next = cache->fn_data; diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h index a967b7c4d37..7fa2035772a 100644 --- a/gdb/frame-unwind.h +++ b/gdb/frame-unwind.h @@ -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, diff --git a/gdb/frame.c b/gdb/frame.c index 6c646e5faff..2442f5d5b08 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -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->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 (); 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 (); prev_frame->level = this_frame->level + 1; /* For now, assume we don't have frame chains crossing address diff --git a/gdb/frame.h b/gdb/frame.h index 99a79835efa..086abc86b51 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -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 +T * +frame_obstack_zalloc () +{ + return static_cast (frame_obstack_zalloc (sizeof (T))); +} + +/* Allocate N instances of T using frame_obstack_zalloc. */ + +template +T * +frame_obstack_calloc (int n) +{ + return static_cast (frame_obstack_zalloc (n * sizeof (T))); +} class readonly_detached_regcache; /* Create a regcache, and copy the frame's registers into it. */ diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index e8de8440fb4..b47ae96e1b9 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -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 (); (*this_prologue_cache) = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 441364a7e17..b1ebd7209ee 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -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 (); for (i = 0; i < FT32_NUM_REGS; ++i) cache->saved_regs[i] = REG_UNAVAIL; diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 89907b86d9e..0db5ee65993 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -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 (); h8300_init_frame_cache (gdbarch, cache); *this_cache = cache; diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c index da5559c07ab..16a06cc8e43 100644 --- a/gdb/hppa-linux-tdep.c +++ b/gdb/hppa-linux-tdep.c @@ -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 (); *this_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index c419c371a6a..42288bdcd8c 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -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 (); (*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 (); (*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 (); *this_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 72d880a7a8a..b201d2a4139 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -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 (); /* Base address. */ cache->base_p = 0; diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c index c17e1aa66d6..acae3e4796d 100644 --- a/gdb/ia64-libunwind-tdep.c +++ b/gdb/ia64-libunwind-tdep.c @@ -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 (); cache->func_addr = get_frame_func (this_frame); if (cache->func_addr == 0) diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 42435d1b48b..ee3b5120ed5 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index 1912e9ba7b0..ea566884fe2 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -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 (); iq2000_init_frame_cache (cache); *this_cache = cache; diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 80411626621..5f5881ddd11 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -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 (); (*this_prologue_cache) = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index 21a3e537793..107a243af70 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); *this_cache = cache; diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 0b26e407fc6..62969e90b5a 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -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_analyze_prologue (get_frame_arch (this_frame), func_start, stop_addr, (struct m32c_prologue *) *this_prologue_cache); diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c index 03000cc99da..71bd0d9c3d9 100644 --- a/gdb/m32r-linux-tdep.c +++ b/gdb/m32r-linux-tdep.c @@ -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 (); (*this_cache) = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index bc5f05ed505..7ef6dad96ea 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -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 (); (*this_prologue_cache) = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 83a57edae00..55b26f9bf99 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -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 (); (*this_prologue_cache) = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 3fa158a0338..98d31464993 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index 1821cba7e5f..04b02d89268 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -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 (); func_start = get_frame_func (this_frame); stop_addr = get_frame_pc (this_frame); diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 72233444f34..f4ab2ec595f 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 2bd2db0bc77..6657f14b37a 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -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 (); (*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 (); (*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 (); (*this_cache) = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 3749c65f6cf..e6e7f3df247 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -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 (); func_start = get_frame_func (this_frame); stop_addr = get_frame_pc (this_frame); diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index 831c95e0fa1..17007a04e38 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -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 (); cache->base = 0; cache->saved_sp = 0; diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 7ac26b958c3..310cbeeeaf0 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -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 (); func_start = get_frame_func (this_frame); stop_addr = get_frame_pc (this_frame); diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 9180cd0c6d1..f0a0b338931 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -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 (); /* Initialize fp_offset to check if FP is set in prologue. */ cache->fp_offset = INVALID_OFFSET; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index a9f05a26d17..98bbc115cfe 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1675,10 +1675,8 @@ static gdb::unordered_map 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 (); bfcache.emplace (frame.get (), cache); - return cache; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 76d10a3b298..0c86fcd7196 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -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 (); cache->regs = trad_frame_alloc_saved_regs (this_frame); (*this_cache) = cache; diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 846064cc3d8..b310a620e1f 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -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 (); func_start = get_frame_func (this_frame); stop_addr = get_frame_pc (this_frame); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index fc64e3ee69e..b73ab87b699 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -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 (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 (); (*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 (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 (); (*this_cache) = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index d11d1d26811..c7b1dfa6ae7 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -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 (); func_start = get_frame_func (this_frame); stop_addr = get_frame_pc (this_frame); diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 66e571d47dd..593befb495a 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -396,7 +396,6 @@ s390_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame, s390_gdbarch_tdep *tdep = 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 (); *this_prologue_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 0cef5f4645d..c78eccbe4ca 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -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 (); *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 (); *this_prologue_cache = info; info->saved_regs = trad_frame_alloc_saved_regs (this_frame); diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c index 950588e9a3a..983ff466645 100644 --- a/gdb/sentinel-frame.c +++ b/gdb/sentinel-frame.c @@ -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 (); cache->regcache = regcache; return cache; diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index e7ab41f051f..d70188d0dc7 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 926afa3b930..2ee508b6b8b 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -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 (); /* Base address. */ cache->base = 0; diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 56d309871ea..499cc0685b0 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -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 (); (*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 (); cache->return_regnum = TIC6X_RA_REGNUM; diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index c525644017d..4ec14b96033 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -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 (); *this_cache = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); cache->base = 0; diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index 470f31d4b97..c38b578f0fa 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -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 (); 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::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 (numregs); /* For backwards compatibility, initialize all the register values to REALREG, with register 0 stored in 0, register 1 stored in 1 and so diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h index 9039e8b2a80..02f1c8c9bd4 100644 --- a/gdb/trad-frame.h +++ b/gdb/trad-frame.h @@ -117,7 +117,7 @@ struct trad_frame_saved_reg void set_value_bytes (gdb::array_view bytes) { /* Allocate the space and copy the data bytes. */ - gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte); + auto *data = frame_obstack_calloc (bytes.size ()); memcpy (data, bytes.data (), bytes.size ()); m_kind = trad_frame_saved_reg_kind::VALUE_BYTES; diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c index 5fea5bbbd69..562feab7cc3 100644 --- a/gdb/tramp-frame.c +++ b/gdb/tramp-frame.c @@ -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 (); tramp_cache->func = func; tramp_cache->tramp_frame = tramp; (*this_cache) = tramp_cache; diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index c544fe18ff2..cd0635b5b2c 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); /* Base address. */ diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index 0a83f4f914c..a6af8831c3c 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -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 (); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); /* The frame pointer is used as the base for the frame. */ diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index f77b21cef93..68d40b8373a 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -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 (); cache->tlsoffset = tlsoffset; *this_cache = cache; diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 819c54ba4ba..d75e10428e1 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -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 (); cache->base = 0; cache->saved_sp = 0; diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 88ad81511c6..48ca4bd9eec 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -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 (); cache->base = 0; cache->pc = 0; diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 31d319392dd..6a099cd6e74 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -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 (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 (); memset (info, 0, sizeof (*info)); info->saved_regs = trad_frame_alloc_saved_regs (this_frame); *this_prologue_cache = info;