]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove BLOCK_ENTRY_PC macro
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 7 Feb 2022 03:41:58 +0000 (22:41 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 28 Apr 2022 02:05:03 +0000 (22:05 -0400)
Replace with equivalent method.

Change-Id: I0e033095e7358799930775e61028b48246971a7d

17 files changed:
gdb/ax-gdb.c
gdb/block.h
gdb/blockframe.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-object-run.c
gdb/compile/compile.c
gdb/dwarf2/loc.c
gdb/findvar.c
gdb/infcmd.c
gdb/infrun.c
gdb/inline-frame.c
gdb/linespec.c
gdb/parse.c
gdb/printcmd.c
gdb/symtab.c
gdb/tracepoint.c
gdb/value.c

index e2e311f9d74a0f277cc91752f831c5aee8fb7c1c..f8ea8adc6266bd2cc1d3992bc3817536941f2b68 100644 (file)
@@ -571,7 +571,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
       break;
 
     case LOC_BLOCK:
-      ax_const_l (ax, BLOCK_ENTRY_PC (var->value_block ()));
+      ax_const_l (ax, var->value_block ()->entry_pc ());
       value->kind = axs_rvalue;
       break;
 
index 80b0616116dca142ead7939ce2eb88a20517ac53..d952430e6b15790fe533f3853c03527b59b99a9e 100644 (file)
@@ -171,6 +171,29 @@ struct block
   bool is_contiguous () const
   { return this->ranges ().size () <= 1; }
 
+  /* Return the "entry PC" of this block.
+
+     The entry PC is the lowest (start) address for the block when all addresses
+     within the block are contiguous.  If non-contiguous, then use the start
+     address for the first range in the block.
+
+     At the moment, this almost matches what DWARF specifies as the entry
+     pc.  (The missing bit is support for DW_AT_entry_pc which should be
+     preferred over range data and the low_pc.)
+
+     Once support for DW_AT_entry_pc is added, I expect that an entry_pc
+     field will be added to one of these data structures.  Once that's done,
+     the entry_pc field can be set from the dwarf reader (and other readers
+     too).  ENTRY_PC can then be redefined to be less DWARF-centric.  */
+
+  CORE_ADDR entry_pc () const
+  {
+    if (this->is_contiguous ())
+      return this->start ();
+    else
+      return this->ranges ()[0].start ();
+  }
+
   /* Addresses in the executable code that are in this block.  */
 
   CORE_ADDR m_start;
@@ -219,24 +242,6 @@ struct global_block
   struct compunit_symtab *compunit_symtab;
 };
 
-/* Define the "entry pc" for a block BL to be the lowest (start) address
-   for the block when all addresses within the block are contiguous.  If
-   non-contiguous, then use the start address for the first range in the
-   block.
-
-   At the moment, this almost matches what DWARF specifies as the entry
-   pc.  (The missing bit is support for DW_AT_entry_pc which should be
-   preferred over range data and the low_pc.)
-
-   Once support for DW_AT_entry_pc is added, I expect that an entry_pc
-   field will be added to one of these data structures.  Once that's done,
-   the entry_pc field can be set from the dwarf reader (and other readers
-   too).  BLOCK_ENTRY_PC can then be redefined to be less DWARF-centric.  */
-
-#define BLOCK_ENTRY_PC(bl)     (bl->is_contiguous () \
-                                ? bl->start () \
-                                : bl->ranges ()[0].start ())
-
 struct blockvector
 {
   /* Number of blocks in the list.  */
index 694cd047c754c1f354f8479a3bb3446cd141fad1..47772f3b1a681f2fe2107e68597b6f8a2b7243cf 100644 (file)
@@ -96,7 +96,7 @@ get_pc_function_start (CORE_ADDR pc)
       if (symbol)
        {
          bl = symbol->value_block ();
-         return BLOCK_ENTRY_PC (bl);
+         return bl->entry_pc ();
        }
     }
 
@@ -254,7 +254,7 @@ find_pc_partial_function_sym (CORE_ADDR pc,
       f = find_pc_sect_function (mapped_pc, section);
       if (f != NULL
          && (msymbol.minsym == NULL
-             || (BLOCK_ENTRY_PC (f->value_block ())
+             || (f->value_block ()->entry_pc ()
                  >= msymbol.value_address ())))
        {
          const struct block *b = f->value_block ();
@@ -392,7 +392,7 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
 
   if (status && block != nullptr && !block->is_contiguous ())
     {
-      CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
+      CORE_ADDR entry_pc = block->entry_pc ();
 
       for (const blockrange &range : block->ranges ())
        {
@@ -424,7 +424,7 @@ find_function_type (CORE_ADDR pc)
 {
   struct symbol *sym = find_pc_function (pc);
 
-  if (sym != NULL && BLOCK_ENTRY_PC (sym->value_block ()) == pc)
+  if (sym != NULL && sym->value_block ()->entry_pc () == pc)
     return sym->type ();
 
   return NULL;
index 4c30ae98c1c22991e718610744d3cf901d5f0b23..e1f94ec2907cffe9a9cc60afcb7126ae58c7ab74 100644 (file)
@@ -93,7 +93,7 @@ convert_one_symbol (compile_c_instance *context,
 
        case LOC_BLOCK:
          kind = GCC_C_SYMBOL_FUNCTION;
-         addr = BLOCK_ENTRY_PC (sym.symbol->value_block ());
+         addr = sym.symbol->value_block ()->entry_pc ();
          if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
            addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
          break;
@@ -404,7 +404,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
            gdb_printf (gdb_stdlog,
                        "gcc_symbol_address \"%s\": full symbol\n",
                        identifier);
-         result = BLOCK_ENTRY_PC (sym->value_block ());
+         result = sym->value_block ()->entry_pc ();
          if (sym->type ()->is_gnu_ifunc ())
            result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
          found = 1;
index d5742a5880de324e8ca5d6d85d0e321fd3b92d51..331ae35c5e92c1ddda6298996aac9341be1e0cd7 100644 (file)
@@ -145,7 +145,7 @@ compile_object_run (compile_module_up &&module)
 
       gdb_assert (func_type->code () == TYPE_CODE_FUNC);
       func_val = value_from_pointer (lookup_pointer_type (func_type),
-                                  BLOCK_ENTRY_PC (func_sym->value_block ()));
+                                  func_sym->value_block ()->entry_pc ());
 
       vargs = XALLOCAVEC (struct value *, func_type->num_fields ());
       if (func_type->num_fields () >= 1)
index 5cbb341b383bdc23054a069c640b3fde137c8f64..1c3a618690beeb1ab55f65ae3f2a08e30b2b594c 100644 (file)
@@ -487,10 +487,10 @@ get_expr_block_and_pc (CORE_ADDR *pc)
        block = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (),
                                   STATIC_BLOCK);
       if (block != NULL)
-       *pc = BLOCK_ENTRY_PC (block);
+       *pc = block->entry_pc ();
     }
   else
-    *pc = BLOCK_ENTRY_PC (block);
+    *pc = block->entry_pc ();
 
   return block;
 }
index ea45475810ec64f7f368ac1ad061522345aef3e1..f490b68adc3d066603990187d452ede1d370f7e5 100644 (file)
@@ -453,7 +453,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_ENTRY_PC (pc_func->value_block ()))
+         if (pc_func && pc == pc_func->value_block ()->entry_pc ())
            {
              *locexpr_length = length;
              return loc_ptr;
@@ -753,7 +753,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_ENTRY_PC (sym->value_block ()) != addr)
+  if (sym == NULL || sym->value_block ()->entry_pc () != addr)
     throw_error (NO_ENTRY_VALUE_ERROR,
                 _("DW_TAG_call_site resolving failed to find function "
                   "name for address %s"),
index bdc3d35c3458c541773229804af1a684fec673e8..1f0317567cd4219006a8516b7e25a7358bb4d98b 100644 (file)
@@ -704,10 +704,10 @@ language_defn::read_var_value (struct symbol *var,
     case LOC_BLOCK:
       if (overlay_debugging)
        addr = symbol_overlayed_address
-         (BLOCK_ENTRY_PC (var->value_block ()),
+         (var->value_block ()->entry_pc (),
           var->obj_section (var->objfile ()));
       else
-       addr = BLOCK_ENTRY_PC (var->value_block ());
+       addr = var->value_block ()->entry_pc ();
       break;
 
     case LOC_REGISTER:
index 5368fcd71570d77656191b7b930648e04ed4508d..53c9e3d0afeab6622a53c2b6c016ed1a562703b4 100644 (file)
@@ -1345,7 +1345,7 @@ until_next_command (int from_tty)
     {
       sal = find_pc_line (pc, 0);
 
-      tp->control.step_range_start = BLOCK_ENTRY_PC (func->value_block ());
+      tp->control.step_range_start = func->value_block ()->entry_pc ();
       tp->control.step_range_end = sal.end;
 
       /* By setting the step_range_end based on the current pc, we are
index e0a5bde037b85192ef4d941101e822e8f26c0495..acefd4f0becffdc869594d55ba13677d07b2d5aa 100644 (file)
@@ -4687,8 +4687,8 @@ fill_in_stop_func (struct gdbarch *gdbarch,
         stop_func_start is NOT advanced when in a range of a
         non-contiguous block that does not contain the entry pc.  */
       if (block != nullptr
-         && ecs->stop_func_start <= BLOCK_ENTRY_PC (block)
-         && BLOCK_ENTRY_PC (block) < ecs->stop_func_end)
+         && ecs->stop_func_start <= block->entry_pc ()
+         && block->entry_pc () < ecs->stop_func_end)
        {
          ecs->stop_func_start
            += gdbarch_deprecated_function_start_offset (gdbarch);
index bd173a1d21b75adcdc3abfc59fb61998ebf249f1..c502674b1d42980ebf6be55d1525003d9e8813bc 100644 (file)
@@ -181,7 +181,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_ENTRY_PC (func->value_block ());
+  (*this_id).code_addr = func->value_block ()->entry_pc ();
   (*this_id).artificial_depth++;
 }
 
@@ -362,7 +362,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
            {
              /* See comments in inline_frame_this_id about this use
                 of BLOCK_ENTRY_PC.  */
-             if (BLOCK_ENTRY_PC (cur_block) == this_pc
+             if (cur_block->entry_pc () == this_pc
                  || block_starting_point_at (this_pc, cur_block))
                {
                  /* Do not skip the inlined frame if execution
index fd3fba871c5cc46522652e8e8ae2ec8dea5c0439..c424b33b522802e73221947aa0a049e82b95ec0a 100644 (file)
@@ -2224,7 +2224,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
                   && sym.symbol->aclass () == LOC_BLOCK)
                {
                  const CORE_ADDR addr
-                   = BLOCK_ENTRY_PC (sym.symbol->value_block ());
+                   = sym.symbol->value_block ()->entry_pc ();
 
                  for (const auto &elem : ls->minimal_symbols)
                    {
index 73669923890eb5deec3d43f81be2f94e9c1efc11..52925db218953a5af3831ae1649b5865ae2a5b84 100644 (file)
@@ -454,7 +454,7 @@ parse_exp_in_context (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_ENTRY_PC (expression_context_block);
+    expression_context_pc = expression_context_block->entry_pc ();
   else
     expression_context_pc = pc;
 
@@ -468,7 +468,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
          = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (),
                               STATIC_BLOCK);
       if (expression_context_block)
-       expression_context_pc = BLOCK_ENTRY_PC (expression_context_block);
+       expression_context_pc = expression_context_block->entry_pc ();
     }
 
   if (language_mode == language_mode_auto && block != NULL)
index 102058a857931be9d9b4b5984499755d0e3e1079..806c5d1b004f9f9dec4f97007cae26bb1821c415 100644 (file)
@@ -645,7 +645,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_ENTRY_PC (symbol->value_block ());
+      name_location = symbol->value_block ()->entry_pc ();
       if (do_demangle || asm_demangle)
        name_temp = symbol->print_name ();
       else
@@ -1778,7 +1778,7 @@ info_address_command (const char *exp, int from_tty)
 
     case LOC_BLOCK:
       gdb_printf (_("a function at address "));
-      load_addr = BLOCK_ENTRY_PC (sym->value_block ());
+      load_addr = sym->value_block ()->entry_pc ();
       fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
                    gdb_stdout);
       if (section_is_overlay (section))
index 63fa9ba3196e6c90809b056d3e5190ca3027f0c0..0367705576c8178d11b9510077683609f934ccc7 100644 (file)
@@ -1821,7 +1821,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
       addr = sym->value_address ();
       break;
     case LOC_BLOCK:
-      addr = BLOCK_ENTRY_PC (sym->value_block ());
+      addr = sym->value_block ()->entry_pc ();
       break;
 
     default:
@@ -3779,7 +3779,7 @@ find_function_start_sal (symbol *sym, bool funfirstline)
 {
   fixup_symbol_section (sym, NULL);
   symtab_and_line sal
-    = find_function_start_sal_1 (BLOCK_ENTRY_PC (sym->value_block ()),
+    = find_function_start_sal_1 (sym->value_block ()->entry_pc (),
                                 sym->obj_section (sym->objfile ()),
                                 funfirstline);
   sal.symbol = sym;
@@ -3908,7 +3908,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
       fixup_symbol_section (sym, NULL);
 
       objfile = sym->objfile ();
-      pc = BLOCK_ENTRY_PC (sym->value_block ());
+      pc = sym->value_block ()->entry_pc ();
       section = sym->obj_section (objfile);
       name = sym->linkage_name ();
     }
@@ -3984,7 +3984,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_ENTRY_PC (sym->value_block ()) <= start_sal.end
+         && (sym ? (sym->value_block ()->entry_pc () <= start_sal.end
                     && start_sal.end < sym->value_block()->end ())
              : (lookup_minimal_symbol_by_pc_section (start_sal.end, section).minsym
                 == lookup_minimal_symbol_by_pc_section (pc, section).minsym)))
@@ -4182,7 +4182,7 @@ find_function_alias_target (bound_minimal_symbol msymbol)
   symbol *sym = find_pc_function (func_addr);
   if (sym != NULL
       && sym->aclass () == LOC_BLOCK
-      && BLOCK_ENTRY_PC (sym->value_block ()) == func_addr)
+      && sym->value_block ()->entry_pc () == func_addr)
     return sym;
 
   return NULL;
@@ -5791,7 +5791,7 @@ find_gnu_ifunc (const symbol *sym)
                                symbol_name_match_type::SEARCH_NAME);
   struct objfile *objfile = sym->objfile ();
 
-  CORE_ADDR address = BLOCK_ENTRY_PC (sym->value_block ());
+  CORE_ADDR address = sym->value_block ()->entry_pc ();
   minimal_symbol *ifunc = NULL;
 
   iterate_over_minimal_symbols (objfile, lookup_name,
index 64419436fd740c10fbe48a137ff2a25a7b3fc1ed..44d16b55bca64736e9cf98d2eefe8d75e789f245 100644 (file)
@@ -2512,7 +2512,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_ENTRY_PC (block),
+                                                         block->entry_pc (),
                                                          gdb_stdout);
          else
            {
@@ -2587,7 +2587,7 @@ info_scope_command (const char *args_in, int from_tty)
                  gdb_printf ("a function at address ");
                  gdb_printf ("%s",
                              paddress (gdbarch,
-                                       BLOCK_ENTRY_PC (sym->value_block ())));
+                                       sym->value_block ()->entry_pc ()));
                  break;
                case LOC_UNRESOLVED:
                  msym = lookup_minimal_symbol (sym->linkage_name (),
index 08cccf711b224b3804b11c97b4bc7a98363c9eef..022fca91a42a8b4d5bccc745b62e642aea8a02ed 100644 (file)
@@ -3184,7 +3184,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
   VALUE_LVAL (v) = lval_memory;
   if (sym)
     {
-      set_value_address (v, BLOCK_ENTRY_PC (sym->value_block ()));
+      set_value_address (v, sym->value_block ()->entry_pc ());
     }
   else
     {