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/frame.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/frame.c')
-rw-r--r-- | gdb/frame.c | 171 |
1 files changed, 87 insertions, 84 deletions
diff --git a/gdb/frame.c b/gdb/frame.c index 72a34fc..9c3f0df 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -71,7 +71,7 @@ get_frame_cache_generation () /* The values behind the global "set backtrace ..." settings. */ set_backtrace_options user_set_backtrace_options; -static frame_info_ptr get_prev_frame_raw (frame_info_ptr this_frame); +static frame_info_ptr get_prev_frame_raw (const frame_info_ptr &this_frame); static const char *frame_stop_reason_symbol_string (enum unwind_stop_reason reason); static frame_info_ptr create_new_frame (frame_id id); @@ -197,7 +197,7 @@ struct frame_info /* See frame.h. */ void -set_frame_previous_pc_masked (frame_info_ptr frame) +set_frame_previous_pc_masked (const frame_info_ptr &frame) { frame->prev_pc.masked = true; } @@ -205,7 +205,7 @@ set_frame_previous_pc_masked (frame_info_ptr frame) /* See frame.h. */ bool -get_frame_pc_masked (frame_info_ptr frame) +get_frame_pc_masked (const frame_info_ptr &frame) { gdb_assert (frame->next != nullptr); gdb_assert (frame->next->prev_pc.status == CC_VALUE); @@ -528,7 +528,7 @@ frame_info::to_string () const Return NULL if FRAME is the start of an artificial-only chain. */ static frame_info_ptr -skip_artificial_frames (frame_info_ptr frame) +skip_artificial_frames (const frame_info_ptr &initial_frame) { /* Note we use get_prev_frame_always, and not get_prev_frame. The latter will truncate the frame chain, leading to this function @@ -537,6 +537,7 @@ skip_artificial_frames (frame_info_ptr frame) Note that for record targets we may get a frame chain that consists of artificial frames only. */ + frame_info_ptr frame = initial_frame; while (get_frame_type (frame) == INLINE_FRAME || get_frame_type (frame) == TAILCALL_FRAME) { @@ -549,8 +550,9 @@ skip_artificial_frames (frame_info_ptr frame) } frame_info_ptr -skip_unwritable_frames (frame_info_ptr frame) +skip_unwritable_frames (const frame_info_ptr &initial_frame) { + frame_info_ptr frame = initial_frame; while (gdbarch_code_of_frame_writable (get_frame_arch (frame), frame) == 0) { frame = get_prev_frame (frame); @@ -564,8 +566,9 @@ skip_unwritable_frames (frame_info_ptr frame) /* See frame.h. */ frame_info_ptr -skip_tailcall_frames (frame_info_ptr frame) +skip_tailcall_frames (const frame_info_ptr &initial_frame) { + frame_info_ptr frame = initial_frame; while (get_frame_type (frame) == TAILCALL_FRAME) { /* Note that for record targets we may get a frame chain that consists of @@ -582,7 +585,7 @@ skip_tailcall_frames (frame_info_ptr frame) frame. */ static void -compute_frame_id (frame_info_ptr fi) +compute_frame_id (const frame_info_ptr &fi) { FRAME_SCOPED_DEBUG_ENTER_EXIT; @@ -628,7 +631,7 @@ compute_frame_id (frame_info_ptr fi) frame. */ struct frame_id -get_frame_id (frame_info_ptr fi) +get_frame_id (const frame_info_ptr &fi) { if (fi == NULL) return null_frame_id; @@ -659,26 +662,24 @@ get_frame_id (frame_info_ptr fi) } struct frame_id -get_stack_frame_id (frame_info_ptr next_frame) +get_stack_frame_id (const frame_info_ptr &next_frame) { return get_frame_id (skip_artificial_frames (next_frame)); } struct frame_id -frame_unwind_caller_id (frame_info_ptr next_frame) +frame_unwind_caller_id (const frame_info_ptr &initial_next_frame) { - frame_info_ptr this_frame; - /* Use get_prev_frame_always, and not get_prev_frame. The latter will truncate the frame chain, leading to this function unintentionally returning a null_frame_id (e.g., when a caller requests the frame ID of "main()"s caller. */ - next_frame = skip_artificial_frames (next_frame); + frame_info_ptr next_frame = skip_artificial_frames (initial_next_frame); if (next_frame == NULL) return null_frame_id; - this_frame = get_prev_frame_always (next_frame); + frame_info_ptr this_frame = get_prev_frame_always (next_frame); if (this_frame) return get_frame_id (skip_artificial_frames (this_frame)); else @@ -965,7 +966,7 @@ frame_find_by_id (struct frame_id id) } static CORE_ADDR -frame_unwind_pc (frame_info_ptr this_frame) +frame_unwind_pc (const frame_info_ptr &this_frame) { if (this_frame->prev_pc.status == CC_UNKNOWN) { @@ -1039,20 +1040,20 @@ frame_unwind_pc (frame_info_ptr this_frame) } CORE_ADDR -frame_unwind_caller_pc (frame_info_ptr this_frame) +frame_unwind_caller_pc (const frame_info_ptr &initial_this_frame) { - this_frame = skip_artificial_frames (this_frame); + frame_info_ptr this_frame = skip_artificial_frames (initial_this_frame); /* We must have a non-artificial frame. The caller is supposed to check the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID in this case. */ - gdb_assert (this_frame != NULL); + gdb_assert (this_frame != nullptr); return frame_unwind_pc (this_frame); } bool -get_frame_func_if_available (frame_info_ptr this_frame, CORE_ADDR *pc) +get_frame_func_if_available (const frame_info_ptr &this_frame, CORE_ADDR *pc) { frame_info *next_frame = this_frame->next; @@ -1095,7 +1096,7 @@ get_frame_func_if_available (frame_info_ptr this_frame, CORE_ADDR *pc) } CORE_ADDR -get_frame_func (frame_info_ptr this_frame) +get_frame_func (const frame_info_ptr &this_frame) { CORE_ADDR pc; @@ -1106,7 +1107,7 @@ get_frame_func (frame_info_ptr this_frame) } std::unique_ptr<readonly_detached_regcache> -frame_save_as_regcache (frame_info_ptr this_frame) +frame_save_as_regcache (const frame_info_ptr &this_frame) { auto cooked_read = [this_frame] (int regnum, gdb::array_view<gdb_byte> buf) { @@ -1123,7 +1124,7 @@ frame_save_as_regcache (frame_info_ptr this_frame) } void -frame_pop (frame_info_ptr this_frame) +frame_pop (const frame_info_ptr &this_frame) { frame_info_ptr prev_frame; @@ -1172,7 +1173,7 @@ frame_pop (frame_info_ptr this_frame) } void -frame_register_unwind (frame_info_ptr next_frame, int regnum, +frame_register_unwind (const frame_info_ptr &next_frame, int regnum, int *optimizedp, int *unavailablep, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, gdb_byte *bufferp) @@ -1215,7 +1216,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, } void -frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf) +frame_unwind_register (const frame_info_ptr &next_frame, int regnum, gdb_byte *buf) { int optimized; int unavailable; @@ -1235,14 +1236,14 @@ frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf) } void -get_frame_register (frame_info_ptr frame, +get_frame_register (const frame_info_ptr &frame, int regnum, gdb_byte *buf) { frame_unwind_register (frame_info_ptr (frame->next), regnum, buf); } struct value * -frame_unwind_register_value (frame_info_ptr next_frame, int regnum) +frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum) { FRAME_SCOPED_DEBUG_ENTER_EXIT; @@ -1334,13 +1335,13 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) } struct value * -get_frame_register_value (frame_info_ptr frame, int regnum) +get_frame_register_value (const frame_info_ptr &frame, int regnum) { return frame_unwind_register_value (frame_info_ptr (frame->next), regnum); } LONGEST -frame_unwind_register_signed (frame_info_ptr next_frame, int regnum) +frame_unwind_register_signed (const frame_info_ptr &next_frame, int regnum) { struct gdbarch *gdbarch = frame_unwind_arch (next_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1366,13 +1367,13 @@ frame_unwind_register_signed (frame_info_ptr next_frame, int regnum) } LONGEST -get_frame_register_signed (frame_info_ptr frame, int regnum) +get_frame_register_signed (const frame_info_ptr &frame, int regnum) { return frame_unwind_register_signed (frame_info_ptr (frame->next), regnum); } ULONGEST -frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum) +frame_unwind_register_unsigned (const frame_info_ptr &next_frame, int regnum) { struct gdbarch *gdbarch = frame_unwind_arch (next_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1400,13 +1401,13 @@ frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum) } ULONGEST -get_frame_register_unsigned (frame_info_ptr frame, int regnum) +get_frame_register_unsigned (const frame_info_ptr &frame, int regnum) { return frame_unwind_register_unsigned (frame_info_ptr (frame->next), regnum); } bool -read_frame_register_unsigned (frame_info_ptr frame, int regnum, +read_frame_register_unsigned (const frame_info_ptr &frame, int regnum, ULONGEST *val) { struct value *regval = get_frame_register_value (frame, regnum); @@ -1427,7 +1428,7 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum, } void -put_frame_register (frame_info_ptr next_frame, int regnum, +put_frame_register (const frame_info_ptr &next_frame, int regnum, gdb::array_view<const gdb_byte> buf) { gdbarch *gdbarch = frame_unwind_arch (next_frame); @@ -1475,7 +1476,7 @@ put_frame_register (frame_info_ptr next_frame, int regnum, Returns 0 if the register value could not be found. */ bool -deprecated_frame_register_read (frame_info_ptr frame, int regnum, +deprecated_frame_register_read (const frame_info_ptr &frame, int regnum, gdb_byte *myaddr) { int optimized; @@ -1492,7 +1493,7 @@ deprecated_frame_register_read (frame_info_ptr frame, int regnum, } bool -get_frame_register_bytes (frame_info_ptr next_frame, int regnum, +get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, CORE_ADDR offset, gdb::array_view<gdb_byte> buffer, int *optimizedp, int *unavailablep) { @@ -1569,7 +1570,7 @@ get_frame_register_bytes (frame_info_ptr next_frame, int regnum, } void -put_frame_register_bytes (frame_info_ptr next_frame, int regnum, +put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, CORE_ADDR offset, gdb::array_view<const gdb_byte> buffer) { @@ -1658,7 +1659,7 @@ frame_obstack_zalloc (unsigned long size) return data; } -static frame_info_ptr get_prev_frame_always_1 (frame_info_ptr this_frame); +static frame_info_ptr get_prev_frame_always_1 (const frame_info_ptr &this_frame); frame_info_ptr get_current_frame (void) @@ -1920,7 +1921,7 @@ invalidate_selected_frame () /* See frame.h. */ void -select_frame (frame_info_ptr fi) +select_frame (const frame_info_ptr &fi) { gdb_assert (fi != nullptr); @@ -2062,7 +2063,7 @@ create_new_frame (CORE_ADDR stack, CORE_ADDR pc) frame chain and onto the sentinel frame. */ frame_info_ptr -get_next_frame (frame_info_ptr this_frame) +get_next_frame (const frame_info_ptr &this_frame) { if (this_frame->level > 0) return frame_info_ptr (this_frame->next); @@ -2075,7 +2076,7 @@ get_next_frame (frame_info_ptr this_frame) unlike get_next_frame(), NULL will never be returned. */ frame_info_ptr -get_next_frame_sentinel_okay (frame_info_ptr this_frame) +get_next_frame_sentinel_okay (const frame_info_ptr &this_frame) { gdb_assert (this_frame != NULL); @@ -2141,12 +2142,13 @@ reinit_frame_cache (void) relative to this particular frame. */ static void -frame_register_unwind_location (frame_info_ptr this_frame, int regnum, - int *optimizedp, enum lval_type *lvalp, +frame_register_unwind_location (const frame_info_ptr &initial_this_frame, + int regnum, int *optimizedp, lval_type *lvalp, CORE_ADDR *addrp, int *realnump) { - gdb_assert (this_frame == NULL || this_frame->level >= 0); + gdb_assert (initial_this_frame == nullptr || initial_this_frame->level >= 0); + frame_info_ptr this_frame = initial_this_frame; while (this_frame != NULL) { int unavailable; @@ -2185,7 +2187,7 @@ frame_register_unwind_location (frame_info_ptr this_frame, int regnum, of the previous frame, should also be a duplicate. */ static frame_info_ptr -get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame) +get_prev_frame_maybe_check_cycle (const frame_info_ptr &this_frame) { frame_info_ptr prev_frame = get_prev_frame_raw (this_frame); @@ -2273,7 +2275,7 @@ get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame) there is no such frame. This may throw an exception. */ static frame_info_ptr -get_prev_frame_always_1 (frame_info_ptr this_frame) +get_prev_frame_always_1 (const frame_info_ptr &this_frame) { FRAME_SCOPED_DEBUG_ENTER_EXIT; @@ -2429,7 +2431,7 @@ get_prev_frame_always_1 (frame_info_ptr this_frame) frame. */ frame_info_ptr -get_prev_frame_always (frame_info_ptr this_frame) +get_prev_frame_always (const frame_info_ptr &this_frame) { frame_info_ptr prev_frame = NULL; @@ -2469,7 +2471,7 @@ get_prev_frame_always (frame_info_ptr this_frame) this_frame. */ static frame_info_ptr -get_prev_frame_raw (frame_info_ptr this_frame) +get_prev_frame_raw (const frame_info_ptr &this_frame) { frame_info *prev_frame; @@ -2522,7 +2524,7 @@ get_prev_frame_raw (frame_info_ptr this_frame) /* Debug routine to print a NULL frame being returned. */ static void -frame_debug_got_null_frame (frame_info_ptr this_frame, +frame_debug_got_null_frame (const frame_info_ptr &this_frame, const char *reason) { if (frame_debug) @@ -2537,7 +2539,7 @@ frame_debug_got_null_frame (frame_info_ptr this_frame, /* Is this (non-sentinel) frame in the "main"() function? */ static bool -inside_main_func (frame_info_ptr this_frame) +inside_main_func (const frame_info_ptr &this_frame) { if (current_program_space->symfile_object_file == nullptr) return false; @@ -2585,7 +2587,7 @@ inside_main_func (frame_info_ptr this_frame) /* Test whether THIS_FRAME is inside the process entry point function. */ static bool -inside_entry_func (frame_info_ptr this_frame) +inside_entry_func (const frame_info_ptr &this_frame) { CORE_ADDR entry_point; @@ -2605,7 +2607,7 @@ inside_entry_func (frame_info_ptr this_frame) checking whether the program-counter is zero. */ frame_info_ptr -get_prev_frame (frame_info_ptr this_frame) +get_prev_frame (const frame_info_ptr &this_frame) { FRAME_SCOPED_DEBUG_ENTER_EXIT; @@ -2703,14 +2705,14 @@ get_prev_frame (frame_info_ptr this_frame) } CORE_ADDR -get_frame_pc (frame_info_ptr frame) +get_frame_pc (const frame_info_ptr &frame) { gdb_assert (frame->next != NULL); return frame_unwind_pc (frame_info_ptr (frame->next)); } bool -get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc) +get_frame_pc_if_available (const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_assert (frame->next != NULL); @@ -2733,7 +2735,7 @@ get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc) /* Return an address that falls within THIS_FRAME's code block. */ CORE_ADDR -get_frame_address_in_block (frame_info_ptr this_frame) +get_frame_address_in_block (const frame_info_ptr &this_frame) { /* A draft address. */ CORE_ADDR pc = get_frame_pc (this_frame); @@ -2793,7 +2795,7 @@ get_frame_address_in_block (frame_info_ptr this_frame) } bool -get_frame_address_in_block_if_available (frame_info_ptr this_frame, +get_frame_address_in_block_if_available (const frame_info_ptr &this_frame, CORE_ADDR *pc) { @@ -2812,7 +2814,7 @@ get_frame_address_in_block_if_available (frame_info_ptr this_frame, } symtab_and_line -find_frame_sal (frame_info_ptr frame) +find_frame_sal (const frame_info_ptr &frame) { frame_info_ptr next_frame; int notcurrent; @@ -2870,7 +2872,7 @@ find_frame_sal (frame_info_ptr frame) /* Per "frame.h", return the ``address'' of the frame. Code should really be using get_frame_id(). */ CORE_ADDR -get_frame_base (frame_info_ptr fi) +get_frame_base (const frame_info_ptr &fi) { return get_frame_id (fi).stack_addr; } @@ -2878,7 +2880,7 @@ get_frame_base (frame_info_ptr fi) /* High-level offsets into the frame. Used by the debug info. */ CORE_ADDR -get_frame_base_address (frame_info_ptr fi) +get_frame_base_address (const frame_info_ptr &fi) { if (get_frame_type (fi) != NORMAL_FRAME) return 0; @@ -2892,7 +2894,7 @@ get_frame_base_address (frame_info_ptr fi) } CORE_ADDR -get_frame_locals_address (frame_info_ptr fi) +get_frame_locals_address (const frame_info_ptr &fi) { if (get_frame_type (fi) != NORMAL_FRAME) return 0; @@ -2907,7 +2909,7 @@ get_frame_locals_address (frame_info_ptr fi) } CORE_ADDR -get_frame_args_address (frame_info_ptr fi) +get_frame_args_address (const frame_info_ptr &fi) { if (get_frame_type (fi) != NORMAL_FRAME) return 0; @@ -2925,7 +2927,7 @@ get_frame_args_address (frame_info_ptr fi) otherwise. */ bool -frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder) +frame_unwinder_is (const frame_info_ptr &fi, const frame_unwind *unwinder) { if (fi->unwind == nullptr) frame_unwind_find_by_frame (fi, &fi->prologue_cache); @@ -2937,7 +2939,7 @@ frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder) or -1 for a NULL frame. */ int -frame_relative_level (frame_info_ptr fi) +frame_relative_level (const frame_info_ptr &fi) { if (fi == NULL) return -1; @@ -2946,7 +2948,7 @@ frame_relative_level (frame_info_ptr fi) } enum frame_type -get_frame_type (frame_info_ptr frame) +get_frame_type (const frame_info_ptr &frame) { if (frame->unwind == NULL) /* Initialize the frame's unwinder because that's what @@ -2956,13 +2958,13 @@ get_frame_type (frame_info_ptr frame) } struct program_space * -get_frame_program_space (frame_info_ptr frame) +get_frame_program_space (const frame_info_ptr &frame) { return frame->pspace; } struct program_space * -frame_unwind_program_space (frame_info_ptr this_frame) +frame_unwind_program_space (const frame_info_ptr &this_frame) { gdb_assert (this_frame); @@ -2973,7 +2975,7 @@ frame_unwind_program_space (frame_info_ptr this_frame) } const address_space * -get_frame_address_space (frame_info_ptr frame) +get_frame_address_space (const frame_info_ptr &frame) { return frame->aspace; } @@ -2981,14 +2983,14 @@ get_frame_address_space (frame_info_ptr frame) /* Memory access methods. */ void -get_frame_memory (frame_info_ptr this_frame, CORE_ADDR addr, +get_frame_memory (const frame_info_ptr &this_frame, CORE_ADDR addr, gdb::array_view<gdb_byte> buffer) { read_memory (addr, buffer.data (), buffer.size ()); } LONGEST -get_frame_memory_signed (frame_info_ptr this_frame, CORE_ADDR addr, +get_frame_memory_signed (const frame_info_ptr &this_frame, CORE_ADDR addr, int len) { struct gdbarch *gdbarch = get_frame_arch (this_frame); @@ -2998,7 +3000,7 @@ get_frame_memory_signed (frame_info_ptr this_frame, CORE_ADDR addr, } ULONGEST -get_frame_memory_unsigned (frame_info_ptr this_frame, CORE_ADDR addr, +get_frame_memory_unsigned (const frame_info_ptr &this_frame, CORE_ADDR addr, int len) { struct gdbarch *gdbarch = get_frame_arch (this_frame); @@ -3008,7 +3010,7 @@ get_frame_memory_unsigned (frame_info_ptr this_frame, CORE_ADDR addr, } bool -safe_frame_unwind_memory (frame_info_ptr this_frame, +safe_frame_unwind_memory (const frame_info_ptr &this_frame, CORE_ADDR addr, gdb::array_view<gdb_byte> buffer) { /* NOTE: target_read_memory returns zero on success! */ @@ -3018,13 +3020,13 @@ safe_frame_unwind_memory (frame_info_ptr this_frame, /* Architecture methods. */ struct gdbarch * -get_frame_arch (frame_info_ptr this_frame) +get_frame_arch (const frame_info_ptr &this_frame) { return frame_unwind_arch (frame_info_ptr (this_frame->next)); } struct gdbarch * -frame_unwind_arch (frame_info_ptr next_frame) +frame_unwind_arch (const frame_info_ptr &next_frame) { if (!next_frame->prev_arch.p) { @@ -3050,14 +3052,14 @@ frame_unwind_arch (frame_info_ptr next_frame) } struct gdbarch * -frame_unwind_caller_arch (frame_info_ptr next_frame) +frame_unwind_caller_arch (const frame_info_ptr &initial_next_frame) { - next_frame = skip_artificial_frames (next_frame); + frame_info_ptr next_frame = skip_artificial_frames (initial_next_frame); /* We must have a non-artificial frame. The caller is supposed to check the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID in this case. */ - gdb_assert (next_frame != NULL); + gdb_assert (next_frame != nullptr); return frame_unwind_arch (next_frame); } @@ -3065,7 +3067,7 @@ frame_unwind_caller_arch (frame_info_ptr next_frame) /* Gets the language of FRAME. */ enum language -get_frame_language (frame_info_ptr frame) +get_frame_language (const frame_info_ptr &frame) { CORE_ADDR pc = 0; bool pc_p = false; @@ -3106,7 +3108,7 @@ get_frame_language (frame_info_ptr frame) /* Stack pointer methods. */ CORE_ADDR -get_frame_sp (frame_info_ptr this_frame) +get_frame_sp (const frame_info_ptr &this_frame) { struct gdbarch *gdbarch = get_frame_arch (this_frame); @@ -3118,9 +3120,9 @@ get_frame_sp (frame_info_ptr this_frame) /* See frame.h. */ frame_info_ptr -frame_follow_static_link (frame_info_ptr frame) +frame_follow_static_link (const frame_info_ptr &initial_frame) { - const block *frame_block = get_frame_block (frame, nullptr); + const block *frame_block = get_frame_block (initial_frame, nullptr); if (frame_block == nullptr) return {}; @@ -3132,11 +3134,12 @@ frame_follow_static_link (frame_info_ptr frame) CORE_ADDR upper_frame_base; - if (!dwarf2_evaluate_property (static_link, frame, NULL, &upper_frame_base)) + if (!dwarf2_evaluate_property (static_link, initial_frame, NULL, &upper_frame_base)) return {}; /* Now climb up the stack frame until we reach the frame we are interested in. */ + frame_info_ptr frame = initial_frame; for (; frame != nullptr; frame = get_prev_frame (frame)) { struct symbol *framefunc = get_frame_function (frame); @@ -3163,7 +3166,7 @@ frame_follow_static_link (frame_info_ptr frame) /* Return the reason why we can't unwind past FRAME. */ enum unwind_stop_reason -get_frame_unwind_stop_reason (frame_info_ptr frame) +get_frame_unwind_stop_reason (const frame_info_ptr &frame) { /* Fill-in STOP_REASON. */ get_prev_frame_always (frame); @@ -3190,7 +3193,7 @@ unwind_stop_reason_to_string (enum unwind_stop_reason reason) } const char * -frame_stop_reason_string (frame_info_ptr fi) +frame_stop_reason_string (const frame_info_ptr &fi) { gdb_assert (fi->prev_p); gdb_assert (fi->prev == NULL); @@ -3225,7 +3228,7 @@ frame_stop_reason_symbol_string (enum unwind_stop_reason reason) FRAME. */ void -frame_cleanup_after_sniffer (frame_info_ptr frame) +frame_cleanup_after_sniffer (const frame_info_ptr &frame) { /* The sniffer should not allocate a prologue cache if it did not match this frame. */ @@ -3255,7 +3258,7 @@ frame_cleanup_after_sniffer (frame_info_ptr frame) frame_cleanup_after_sniffer. */ void -frame_prepare_for_sniffer (frame_info_ptr frame, +frame_prepare_for_sniffer (const frame_info_ptr &frame, const struct frame_unwind *unwind) { gdb_assert (frame->unwind == NULL); |