Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START
authorKevin Buettner <kevinb@redhat.com>
Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)
committerKevin Buettner <kevinb@redhat.com>
Thu, 23 Aug 2018 23:19:18 +0000 (16:19 -0700)
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.

17 files changed:
gdb/ChangeLog
gdb/ax-gdb.c
gdb/blockframe.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-object-run.c
gdb/compile/compile.c
gdb/dwarf2loc.c
gdb/findvar.c
gdb/infcmd.c
gdb/inline-frame.c
gdb/linespec.c
gdb/parse.c
gdb/printcmd.c
gdb/stack.c
gdb/symtab.c
gdb/tracepoint.c
gdb/value.c

index 751b3ed46e332a50d069db407c1345f19a1fd612..319c19685b0639228c32cfa497ff452000e1feba 100644 (file)
        (disassemble_current_function): Likewise.
        (disassemble_command): Likewise.
 
+       * 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.
+
 2018-08-23  Xavier Roirand  <roirand@adacore.com>
 
        * machoread.c (macho_symfile_read_all_oso): Remove uneeded
index 2468061aadbd9f28c2d7eda715e568707f51fc23..9abd939e235feedf45dd35954fca0b0d852e8dd3 100644 (file)
@@ -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;
 
index 6dc736ea5ed2cde4bfaac2a98f339c47f6ab0d62..6ea09658b5333c6ef870119f3bad82ce058962c4 100644 (file)
@@ -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;
index ecb0c165840ce761acffd53400a7aef6b95bdf50..e7423d1c887411795ea31e483c2de6c6d3358aa3 100644 (file)
@@ -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;
index e8a95e3cfe8783029e8e7d2c42d6c98cf1ff9652..0846c735fe2bcaa0f8e57dfa2ef593433b847490 100644 (file)
@@ -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)
index 31ae5970b925f3f7a27467355863dfd1423e7ec9..20d81cb501dcd2abce88c358ae139abfa8102dab 100644 (file)
@@ -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;
 }
index df2f2310679d607dae0e191afc3f78d0e47637e3..200fa03f46ab88ebc869c84f30099126a5676908 100644 (file)
@@ -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"),
index ebaff923a13632f8304925072ce5ab7d2b1e9f41..9256833ab601976b2f36f03aa241150f599ec10b 100644 (file)
@@ -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:
index 74d5956765f1cf5acedc0e7d1407f7398ffdabbe..860909f5e20ea0c898e0039a836f98c43a2c9b9b 100644 (file)
@@ -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;
index c6caf9d0c6ef937f676e641a4e7df322a903ab8e..b408b71f8ce7c3beb90d1fdfc2b6a7d2afbb27e0 100644 (file)
@@ -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
index 892d141e0ae50dd399399c06f2572e03733ef121..73fbe4af3be713281534f939e322af1d7e15547a 100644 (file)
@@ -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;
index 0cbdb48d23a1e9edaa21574e8815df2f68fbb7ad..1b58073a5293402a16c041f0161900c114067409 100644 (file)
@@ -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)
index 2ecbd546532280e68723a7c2aa142b9b8367fd44..1a3d9723d4b1bd4a952ee298623cb63d99ae0cb4 100644 (file)
@@ -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))
        {
index 366687e7df236f8a778b9a58de3ec58eafb5e856..40ff99b8fa6b12d40985ac0cf8f918dc681d5af4 100644 (file)
@@ -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.  */
index 73c79833ce5193e48431bc2c42d2d56fa70d63bd..0a1caa51fba7d33fbb6c3eaf844c9b70302820b0 100644 (file)
@@ -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,
index cd538f4498ff38db33282e28bf117758e7e7413c..a96f56a06b5de387d43426ab3ff4e58b832b9032 100644 (file)
@@ -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),
index b0f22f1117ea0e61cacf6e03c4ab02534713e2af..38fc18e0f69b01fa83d10755753ab63752a49f31 100644 (file)
@@ -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
     {