diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2024-02-19 13:07:47 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2024-02-20 10:42:25 -0500 |
commit | 8480a37e146c40e82a93c0ecf6144571516c95c5 (patch) | |
tree | bfa5d1e14e5212821ee29ae5099be72399137036 /gdb/aarch64-tdep.c | |
parent | 1b2c120daf9e2d935453f9051bbeafbac7f9f14d (diff) | |
download | binutils-8480a37e146c40e82a93c0ecf6144571516c95c5.zip binutils-8480a37e146c40e82a93c0ecf6144571516c95c5.tar.gz binutils-8480a37e146c40e82a93c0ecf6144571516c95c5.tar.bz2 |
gdb: pass frames as `const frame_info_ptr &`
We currently pass frames to function by value, as `frame_info_ptr`.
This is somewhat expensive:
- the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass
by value
- the constructors and destructor link/unlink the object in the global
`frame_info_ptr::frame_list` list. This is an `intrusive_list`, so
it's not so bad: it's just assigning a few points, there's no memory
allocation as if it was `std::list`, but still it's useless to do
that over and over.
As suggested by Tom Tromey, change many function signatures to accept
`const frame_info_ptr &` instead of `frame_info_ptr`.
Some functions reassign their `frame_info_ptr` parameter, like:
void
the_func (frame_info_ptr frame)
{
for (; frame != nullptr; frame = get_prev_frame (frame))
{
...
}
}
I wondered what to do about them, do I leave them as-is or change them
(and need to introduce a separate local variable that can be
re-assigned). I opted for the later for consistency. It might not be
clear why some functions take `const frame_info_ptr &` while others take
`frame_info_ptr`. Also, if a function took a `frame_info_ptr` because
it did re-assign its parameter, I doubt that we would think to change it
to `const frame_info_ptr &` should the implementation change such that
it doesn't need to take `frame_info_ptr` anymore. It seems better to
have a simple rule and apply it everywhere.
Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/aarch64-tdep.c')
-rw-r--r-- | gdb/aarch64-tdep.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index b97e215..d1d5486 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -268,7 +268,7 @@ class instruction_reader : public abstract_instruction_reader static CORE_ADDR aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep, - frame_info_ptr this_frame, CORE_ADDR addr) + const frame_info_ptr &this_frame, CORE_ADDR addr) { if (tdep->has_pauth () && frame_unwind_register_unsigned (this_frame, @@ -298,7 +298,7 @@ aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep, /* Implement the "get_pc_address_flags" gdbarch method. */ static std::string -aarch64_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc) +aarch64_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc) { if (pc != 0 && get_frame_pc_masked (frame)) return "PAC"; @@ -995,7 +995,7 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) cache CACHE. */ static void -aarch64_scan_prologue (frame_info_ptr this_frame, +aarch64_scan_prologue (const frame_info_ptr &this_frame, struct aarch64_prologue_cache *cache) { CORE_ADDR block_addr = get_frame_address_in_block (this_frame); @@ -1049,7 +1049,7 @@ aarch64_scan_prologue (frame_info_ptr this_frame, not available. */ static void -aarch64_make_prologue_cache_1 (frame_info_ptr this_frame, +aarch64_make_prologue_cache_1 (const frame_info_ptr &this_frame, struct aarch64_prologue_cache *cache) { CORE_ADDR unwound_fp; @@ -1087,7 +1087,7 @@ aarch64_make_prologue_cache_1 (frame_info_ptr this_frame, *THIS_CACHE. */ static struct aarch64_prologue_cache * -aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache) +aarch64_make_prologue_cache (const frame_info_ptr &this_frame, void **this_cache) { struct aarch64_prologue_cache *cache; @@ -1114,7 +1114,7 @@ aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache) /* Implement the "stop_reason" frame_unwind method. */ static enum unwind_stop_reason -aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame, +aarch64_prologue_frame_unwind_stop_reason (const frame_info_ptr &this_frame, void **this_cache) { struct aarch64_prologue_cache *cache @@ -1140,7 +1140,7 @@ aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame, PC and the caller's SP when we were called. */ static void -aarch64_prologue_this_id (frame_info_ptr this_frame, +aarch64_prologue_this_id (const frame_info_ptr &this_frame, void **this_cache, struct frame_id *this_id) { struct aarch64_prologue_cache *cache @@ -1155,7 +1155,7 @@ aarch64_prologue_this_id (frame_info_ptr this_frame, /* Implement the "prev_register" frame_unwind method. */ static struct value * -aarch64_prologue_prev_register (frame_info_ptr this_frame, +aarch64_prologue_prev_register (const frame_info_ptr &this_frame, void **this_cache, int prev_regnum) { struct aarch64_prologue_cache *cache @@ -1221,7 +1221,7 @@ static frame_unwind aarch64_prologue_unwind = *THIS_CACHE. */ static struct aarch64_prologue_cache * -aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache) +aarch64_make_stub_cache (const frame_info_ptr &this_frame, void **this_cache) { struct aarch64_prologue_cache *cache; @@ -1251,7 +1251,7 @@ aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache) /* Implement the "stop_reason" frame_unwind method. */ static enum unwind_stop_reason -aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame, +aarch64_stub_frame_unwind_stop_reason (const frame_info_ptr &this_frame, void **this_cache) { struct aarch64_prologue_cache *cache @@ -1266,7 +1266,7 @@ aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame, /* Our frame ID for a stub frame is the current SP and LR. */ static void -aarch64_stub_this_id (frame_info_ptr this_frame, +aarch64_stub_this_id (const frame_info_ptr &this_frame, void **this_cache, struct frame_id *this_id) { struct aarch64_prologue_cache *cache @@ -1282,7 +1282,7 @@ aarch64_stub_this_id (frame_info_ptr this_frame, static int aarch64_stub_unwind_sniffer (const struct frame_unwind *self, - frame_info_ptr this_frame, + const frame_info_ptr &this_frame, void **this_prologue_cache) { CORE_ADDR addr_in_block; @@ -1313,7 +1313,7 @@ static frame_unwind aarch64_stub_unwind = /* Return the frame base address of *THIS_FRAME. */ static CORE_ADDR -aarch64_normal_frame_base (frame_info_ptr this_frame, void **this_cache) +aarch64_normal_frame_base (const frame_info_ptr &this_frame, void **this_cache) { struct aarch64_prologue_cache *cache = aarch64_make_prologue_cache (this_frame, this_cache); @@ -1334,7 +1334,7 @@ static frame_base aarch64_normal_base = *THIS_FRAME. */ static struct value * -aarch64_dwarf2_prev_register (frame_info_ptr this_frame, +aarch64_dwarf2_prev_register (const frame_info_ptr &this_frame, void **this_cache, int regnum) { gdbarch *arch = get_frame_arch (this_frame); @@ -1361,7 +1361,7 @@ static const unsigned char op_lit1 = DW_OP_lit1; static void aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, - frame_info_ptr this_frame) + const frame_info_ptr &this_frame) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch); @@ -2780,7 +2780,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, /* Implement the "get_longjmp_target" gdbarch method. */ static int -aarch64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc) +aarch64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { CORE_ADDR jb_addr; gdb_byte buf[X_REGISTER_SIZE]; @@ -3105,7 +3105,7 @@ aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, /* Helper for aarch64_pseudo_read_value. */ static value * -aarch64_pseudo_read_value_1 (frame_info_ptr next_frame, +aarch64_pseudo_read_value_1 (const frame_info_ptr &next_frame, const int pseudo_reg_num, int raw_regnum_offset) { unsigned v_regnum = AARCH64_V0_REGNUM + raw_regnum_offset; @@ -3197,7 +3197,7 @@ aarch64_za_offsets_from_regnum (struct gdbarch *gdbarch, int regnum) /* Given REGNUM, a SME pseudo-register number, return its value in RESULT. */ static value * -aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame, +aarch64_sme_pseudo_register_read (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch); @@ -3231,7 +3231,7 @@ aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame, /* Implement the "pseudo_register_read_value" gdbarch method. */ static value * -aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame, +aarch64_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch); @@ -3296,7 +3296,7 @@ aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame, /* Helper for aarch64_pseudo_write. */ static void -aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame, +aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame, int regnum_offset, gdb::array_view<const gdb_byte> buf) { @@ -3322,7 +3322,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame, pseudo-register. */ static void -aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame, +aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int regnum, gdb::array_view<const gdb_byte> data) { @@ -3364,7 +3364,7 @@ aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame, /* Implement the "pseudo_register_write" gdbarch method. */ static void -aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame, +aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num, gdb::array_view<const gdb_byte> buf) { @@ -3437,7 +3437,7 @@ aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame, /* Callback function for user_reg_add. */ static struct value * -value_of_aarch64_user_reg (frame_info_ptr frame, const void *baton) +value_of_aarch64_user_reg (const frame_info_ptr &frame, const void *baton) { const int *reg_p = (const int *) baton; |