[PATCH v4 5/8] Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START

Kevin Buettner
2018-08-22T17:16:31Z

This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in
places where BLOCK_START is used to obtain the address at which
execution should enter the block. Since blocks can now contain
non-contiguous ranges, the BLOCK_START - which is still be the
very lowest address in the block - might not be the same as
BLOCK_ENTRY_PC.

There is a change to infrun.c which is less obvious and less mechanical.
I'm posting it as a separate patch.

gdb/ChangeLog:

* ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of
BLOCK_START.
* blockframe.c (get_pc_function_start): Likewise.
* compile/compile-c-symbols.c (convert_one_symbol): Likewise.
(gcc_symbol_address): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (get_expr_block_and_pc): Likewise.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
(func_addr_to_tail_call_list): Likewise.
* findvar.c (default_read_var_value): Likewise.
* inline-frame.c (inline_frame_this_id): Likewise.
(skip-inline_frames): Likewise.
* infcmd.c (until_next_command): Likewise.
* linespec.c (convert_linespec_to_sals): Likewise.
* parse.c (parse_exp_in_context_1): Likewise.
* printcmd.c (build_address_symbolic): likewise.
(info_address_command): Likewise.
symtab.c (find_function_start_sal): Likewise.
(skip_prologue_sal): Likewise.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* stack.c (find_frame_funname): Likewise.
* symtab.c (fixup_symbol_section): Likewise.
(find_function_start_sal): Likewise.
(skip_prologue_sal): Likewsie.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* tracepoint.c (info_scope_command): Likewise.
* value.c (value_fn_field): Likewise.
---
gdb/ax-gdb.c | 2 +-
gdb/blockframe.c | 4 ++--
gdb/compile/compile-c-symbols.c | 4 ++--
gdb/compile/compile-object-run.c | 2 +-
gdb/compile/compile.c | 4 ++--
gdb/dwarf2loc.c | 4 ++--
gdb/findvar.c | 4 ++--
gdb/infcmd.c | 2 +-
gdb/inline-frame.c | 6 +++---
gdb/linespec.c | 2 +-
gdb/parse.c | 4 ++--
gdb/printcmd.c | 4 ++--
gdb/stack.c | 2 +-
gdb/symtab.c | 12 ++++++------
gdb/tracepoint.c | 4 ++--
gdb/value.c | 2 +-
16 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 2468061..9abd939 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -679,7 +679,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
break;

case LOC_BLOCK:
- ax_const_l (ax, BLOCK_START (SYMBOL_BLOCK_VALUE (var)));
+ ax_const_l (ax, BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)));
value->kind = axs_rvalue;
break;

diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 6dc736e..6ea0965 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -96,7 +96,7 @@ get_pc_function_start (CORE_ADDR pc)
if (symbol)
{
bl = SYMBOL_BLOCK_VALUE (symbol);
- return BLOCK_START (bl);
+ return BLOCK_ENTRY_PC (bl);
}
}

@@ -382,7 +382,7 @@ find_function_type (CORE_ADDR pc)
{
struct symbol *sym = find_pc_function (pc);

- if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc)
+ if (sym != NULL && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == pc)
return SYMBOL_TYPE (sym);

return NULL;
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index ecb0c16..e7423d1 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -93,7 +93,7 @@ convert_one_symbol (compile_c_instance *context,

case LOC_BLOCK:
kind = GCC_C_SYMBOL_FUNCTION;
- addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
+ addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym.symbol));
if (is_global && TYPE_GNU_IFUNC (SYMBOL_TYPE (sym.symbol)))
addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
break;
@@ -405,7 +405,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
fprintf_unfiltered (gdb_stdlog,
"gcc_symbol_address \"%s\": full symbol\n",
identifier);
- result = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ result = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
if (TYPE_GNU_IFUNC (SYMBOL_TYPE (sym)))
result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
found = 1;
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index e8a95e3..0846c73 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -152,7 +152,7 @@ compile_object_run (struct compile_module *module)

gdb_assert (TYPE_CODE (func_type) == TYPE_CODE_FUNC);
func_val = value_from_pointer (lookup_pointer_type (func_type),
- BLOCK_START (SYMBOL_BLOCK_VALUE (func_sym)));
+ BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func_sym)));

vargs = XALLOCAVEC (struct value *, TYPE_NFIELDS (func_type));
if (TYPE_NFIELDS (func_type) >= 1)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 31ae597..20d81cb 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -439,10 +439,10 @@ get_expr_block_and_pc (CORE_ADDR *pc)
block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
STATIC_BLOCK);
if (block != NULL)
- *pc = BLOCK_START (block);
+ *pc = BLOCK_ENTRY_PC (block);
}
else
- *pc = BLOCK_START (block);
+ *pc = BLOCK_ENTRY_PC (block);

return block;
}
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index df2f231..200fa03 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -367,7 +367,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
if (pc_block)
pc_func = block_linkage_function (pc_block);

- if (pc_func && pc == BLOCK_START (SYMBOL_BLOCK_VALUE (pc_func)))
+ if (pc_func && pc == BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (pc_func)))
{
*locexpr_length = length;
return loc_ptr;
@@ -871,7 +871,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr)
struct symbol *sym = find_pc_function (addr);
struct type *type;

- if (sym == NULL || BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) != addr)
+ if (sym == NULL || BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) != addr)
throw_error (NO_ENTRY_VALUE_ERROR,
_("DW_TAG_call_site resolving failed to find function "
"name for address %s"),
diff --git a/gdb/findvar.c b/gdb/findvar.c
index ebaff92..9256833 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -702,10 +702,10 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
case LOC_BLOCK:
if (overlay_debugging)
addr = symbol_overlayed_address
- (BLOCK_START (SYMBOL_BLOCK_VALUE (var)),
+ (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)),
SYMBOL_OBJ_SECTION (symbol_objfile (var), var));
else
- addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
+ addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var));
break;

case LOC_REGISTER:
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 74d5956..860909f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1552,7 +1552,7 @@ until_next_command (int from_tty)
{
sal = find_pc_line (pc, 0);

- tp->control.step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
+ tp->control.step_range_start = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func));
tp->control.step_range_end = sal.end;
}
tp->control.may_range_step = 1;
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index c6caf9d..b408b71 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -165,7 +165,7 @@ inline_frame_this_id (struct frame_info *this_frame,
in the frame ID (and eventually, to set breakpoints). */
func = get_frame_function (this_frame);
gdb_assert (func != NULL);
- (*this_id).code_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
+ (*this_id).code_addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func));
(*this_id).artificial_depth++;
}

@@ -341,8 +341,8 @@ skip_inline_frames (thread_info *thread, bpstat stop_chain)
if (block_inlined_p (cur_block))
{
/* See comments in inline_frame_this_id about this use
- of BLOCK_START. */
- if (BLOCK_START (cur_block) == this_pc
+ of BLOCK_ENTRY_PC. */
+ if (BLOCK_ENTRY_PC (cur_block) == this_pc
|| block_starting_point_at (this_pc, cur_block))
{
/* Do not skip the inlined frame if execution
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 892d141..73fbe4a 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2283,7 +2283,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
&& SYMBOL_CLASS (sym) == LOC_BLOCK)
{
const CORE_ADDR addr
- = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));

bound_minimal_symbol_d *elem;
for (int m = 0;
diff --git a/gdb/parse.c b/gdb/parse.c
index 0cbdb48..1b58073 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -1146,7 +1146,7 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
if (!expression_context_block)
expression_context_block = get_selected_block (&expression_context_pc);
else if (pc == 0)
- expression_context_pc = BLOCK_START (expression_context_block);
+ expression_context_pc = BLOCK_ENTRY_PC (expression_context_block);
else
expression_context_pc = pc;

@@ -1160,7 +1160,7 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
= BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
STATIC_BLOCK);
if (expression_context_block)
- expression_context_pc = BLOCK_START (expression_context_block);
+ expression_context_pc = BLOCK_ENTRY_PC (expression_context_block);
}

if (language_mode == language_mode_auto && block != NULL)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2ecbd54..1a3d972 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -609,7 +609,7 @@ build_address_symbolic (struct gdbarch *gdbarch,
pointer is <function+3>. This matches the ISA behavior. */
addr = gdbarch_addr_bits_remove (gdbarch, addr);

- name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
+ name_location = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (symbol));
if (do_demangle || asm_demangle)
name_temp = SYMBOL_PRINT_NAME (symbol);
else
@@ -1519,7 +1519,7 @@ info_address_command (const char *exp, int from_tty)

case LOC_BLOCK:
printf_filtered (_("a function at address "));
- load_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ load_addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
if (section_is_overlay (section))
{
diff --git a/gdb/stack.c b/gdb/stack.c
index 366687e..40ff99b 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1079,7 +1079,7 @@ find_frame_funname (struct frame_info *frame, enum language *funlang,

if (msymbol.minsym != NULL
&& (BMSYMBOL_VALUE_ADDRESS (msymbol)
- > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
+ > BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func))))
{
/* We also don't know anything about the function besides
its address and name. */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 73c7983..0a1caa5 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1746,7 +1746,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
addr = SYMBOL_VALUE_ADDRESS (sym);
break;
case LOC_BLOCK:
- addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
break;

default:
@@ -3637,7 +3637,7 @@ find_function_start_sal (symbol *sym, bool funfirstline)
{
fixup_symbol_section (sym, NULL);
symtab_and_line sal
- = find_function_start_sal_1 (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
+ = find_function_start_sal_1 (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)),
SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym),
funfirstline);
sal.symbol = sym;
@@ -3717,7 +3717,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
fixup_symbol_section (sym, NULL);

objfile = symbol_objfile (sym);
- pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ pc = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
section = SYMBOL_OBJ_SECTION (objfile, sym);
name = SYMBOL_LINKAGE_NAME (sym);
}
@@ -3778,7 +3778,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
/* Check if gdbarch_skip_prologue left us in mid-line, and the next
line is still part of the same function. */
if (skip && start_sal.pc != pc
- && (sym ? (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) <= start_sal.end
+ && (sym ? (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) <= start_sal.end
&& start_sal.end < BLOCK_END (SYMBOL_BLOCK_VALUE (sym)))
: (lookup_minimal_symbol_by_pc_section (start_sal.end, section).minsym
== lookup_minimal_symbol_by_pc_section (pc, section).minsym)))
@@ -3982,7 +3982,7 @@ find_function_alias_target (bound_minimal_symbol msymbol)
symbol *sym = find_pc_function (func_addr);
if (sym != NULL
&& SYMBOL_CLASS (sym) == LOC_BLOCK
- && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == func_addr)
+ && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == func_addr)
return sym;

return NULL;
@@ -4987,7 +4987,7 @@ find_gnu_ifunc (const symbol *sym)
symbol_name_match_type::SEARCH_NAME);
struct objfile *objfile = symbol_objfile (sym);

- CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ CORE_ADDR address = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
minimal_symbol *ifunc = NULL;

iterate_over_minimal_symbols (objfile, lookup_name,
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index cd538f4..a96f56a 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2536,7 +2536,7 @@ info_scope_command (const char *args_in, int from_tty)

if (SYMBOL_COMPUTED_OPS (sym) != NULL)
SYMBOL_COMPUTED_OPS (sym)->describe_location (sym,
- BLOCK_START (block),
+ BLOCK_ENTRY_PC (block),
gdb_stdout);
else
{
@@ -2613,7 +2613,7 @@ info_scope_command (const char *args_in, int from_tty)
case LOC_BLOCK:
printf_filtered ("a function at address ");
printf_filtered ("%s",
- paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (sym))));
+ paddress (gdbarch, BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym))));
break;
case LOC_UNRESOLVED:
msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym),
diff --git a/gdb/value.c b/gdb/value.c
index b0f22f1..38fc18e 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3050,7 +3050,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
VALUE_LVAL (v) = lval_memory;
if (sym)
{
- set_value_address (v, BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
+ set_value_address (v, BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)));
}
else
{