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/dwarf2/loc.c | |
parent | 1b2c120daf9e2d935453f9051bbeafbac7f9f14d (diff) | |
download | gdb-8480a37e146c40e82a93c0ecf6144571516c95c5.zip gdb-8480a37e146c40e82a93c0ecf6144571516c95c5.tar.gz gdb-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/dwarf2/loc.c')
-rw-r--r-- | gdb/dwarf2/loc.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 0f0d14f..203ad53 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -48,7 +48,7 @@ #include "gdbsupport/byte-vector.h" static struct value *dwarf2_evaluate_loc_desc_full - (struct type *type, frame_info_ptr frame, const gdb_byte *data, + (struct type *type, const frame_info_ptr &frame, const gdb_byte *data, size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true); @@ -503,7 +503,7 @@ locexpr_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc, LOC_BLOCK functions using a DWARF expression as its DW_AT_frame_base. */ static CORE_ADDR -locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) +locexpr_get_frame_base (struct symbol *framefunc, const frame_info_ptr &frame) { struct gdbarch *gdbarch; struct type *type; @@ -561,7 +561,7 @@ loclist_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc, LOC_BLOCK functions using a DWARF location list as its DW_AT_frame_base. */ static CORE_ADDR -loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) +loclist_get_frame_base (struct symbol *framefunc, const frame_info_ptr &frame) { struct gdbarch *gdbarch; struct type *type; @@ -649,11 +649,10 @@ show_entry_values_debug (struct ui_file *file, int from_tty, /* See gdbtypes.h. */ void -call_site_target::iterate_over_addresses - (struct gdbarch *call_site_gdbarch, - const struct call_site *call_site, - frame_info_ptr caller_frame, - iterate_ftype callback) const +call_site_target::iterate_over_addresses (gdbarch *call_site_gdbarch, + const call_site *call_site, + const frame_info_ptr &caller_frame, + iterate_ftype callback) const { switch (m_loc_kind) { @@ -1138,9 +1137,9 @@ call_site_parameter_matches (struct call_site_parameter *parameter, /* See loc.h. */ struct call_site_parameter * -dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, - enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, +dwarf_expr_reg_to_entry_parameter (const frame_info_ptr &initial_frame, + call_site_parameter_kind kind, + call_site_parameter_u kind_u, dwarf2_per_cu_data **per_cu_return, dwarf2_per_objfile **per_objfile_return) { @@ -1152,6 +1151,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, /* Initialize it just to avoid a GCC false warning. */ struct call_site_parameter *parameter = NULL; CORE_ADDR target_addr; + frame_info_ptr frame = initial_frame; while (get_frame_type (frame) == INLINE_FRAME) { @@ -1263,7 +1263,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, static struct value * dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, CORE_ADDR deref_size, struct type *type, - frame_info_ptr caller_frame, + const frame_info_ptr &caller_frame, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { @@ -1339,7 +1339,7 @@ static const struct lval_funcs entry_data_value_funcs = /* See dwarf2/loc.h. */ struct value * -value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, +value_of_dwarf_reg_entry (struct type *type, const frame_info_ptr &frame, enum call_site_parameter_kind kind, union call_site_parameter_u kind_u) { @@ -1395,7 +1395,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, cannot resolve the parameter for any reason. */ static struct value * -value_of_dwarf_block_entry (struct type *type, frame_info_ptr frame, +value_of_dwarf_block_entry (struct type *type, const frame_info_ptr &frame, const gdb_byte *block, size_t block_len) { union call_site_parameter_u kind_u; @@ -1456,7 +1456,7 @@ struct value * indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, - frame_info_ptr frame, struct type *type, + const frame_info_ptr &frame, struct type *type, bool resolve_abstract_p) { /* Fetch the location expression of the DIE we're pointing to. */ @@ -1496,7 +1496,7 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, SUBOBJ_BYTE_OFFSET within the variable of type TYPE. */ static struct value * -dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, +dwarf2_evaluate_loc_desc_full (struct type *type, const frame_info_ptr &frame, const gdb_byte *data, size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, @@ -1561,7 +1561,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, passes 0 as the byte_offset. */ struct value * -dwarf2_evaluate_loc_desc (struct type *type, frame_info_ptr frame, +dwarf2_evaluate_loc_desc (struct type *type, const frame_info_ptr &frame, const gdb_byte *data, size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, bool as_lval) @@ -1584,7 +1584,7 @@ dwarf2_evaluate_loc_desc (struct type *type, frame_info_ptr frame, static int dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, - frame_info_ptr frame, + const frame_info_ptr &frame, const struct property_addr_info *addr_stack, CORE_ADDR *valp, gdb::array_view<CORE_ADDR> push_values, @@ -1644,9 +1644,9 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, /* See dwarf2/loc.h. */ bool -dwarf2_evaluate_property (const struct dynamic_prop *prop, - frame_info_ptr frame, - const struct property_addr_info *addr_stack, +dwarf2_evaluate_property (const dynamic_prop *prop, + const frame_info_ptr &initial_frame, + const property_addr_info *addr_stack, CORE_ADDR *value, gdb::array_view<CORE_ADDR> push_values) { @@ -1657,6 +1657,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, Without this here this could happen if the code below selects a frame. */ scoped_restore_current_language save_language; + frame_info_ptr frame = initial_frame; if (frame == NULL && has_stack_frames ()) frame = get_selected_frame (NULL); @@ -3051,7 +3052,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, /* Return the value of SYMBOL in FRAME using the DWARF-2 expression evaluator to calculate the location. */ static struct value * -locexpr_read_variable (struct symbol *symbol, frame_info_ptr frame) +locexpr_read_variable (struct symbol *symbol, const frame_info_ptr &frame) { struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol); @@ -3069,7 +3070,7 @@ locexpr_read_variable (struct symbol *symbol, frame_info_ptr frame) will be thrown. */ static struct value * -locexpr_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame) +locexpr_read_variable_at_entry (struct symbol *symbol, const frame_info_ptr &frame) { struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol); @@ -3884,7 +3885,7 @@ const struct symbol_computed_ops dwarf2_locexpr_funcs = { /* Return the value of SYMBOL in FRAME using the DWARF-2 expression evaluator to calculate the location. */ static struct value * -loclist_read_variable (struct symbol *symbol, frame_info_ptr frame) +loclist_read_variable (struct symbol *symbol, const frame_info_ptr &frame) { struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol); @@ -3909,7 +3910,7 @@ loclist_read_variable (struct symbol *symbol, frame_info_ptr frame) if it cannot resolve the parameter for any reason. */ static struct value * -loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame) +loclist_read_variable_at_entry (struct symbol *symbol, const frame_info_ptr &frame) { struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol); |