Add two convenience methods to block
[binutils-gdb.git] / gdb / findvar.c
index a82cf8c0afab1e888731454ff2070cfd2837c4f2..1079b85df825eaecbfa063257271247e99870f00 100644 (file)
@@ -25,7 +25,7 @@
 #include "gdbcore.h"
 #include "inferior.h"
 #include "target.h"
-#include "symfile.h"           /* for overlay functions */
+#include "symfile.h"
 #include "regcache.h"
 #include "user-regs.h"
 #include "block.h"
@@ -295,7 +295,7 @@ value_of_register_lazy (frame_info_ptr frame, int regnum)
   gdb_assert (frame_id_p (get_frame_id (next_frame)));
 
   reg_val = value::allocate_lazy (register_type (gdbarch, regnum));
-  VALUE_LVAL (reg_val) = lval_register;
+  reg_val->set_lval (lval_register);
   VALUE_REGNUM (reg_val) = regnum;
   VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame);
 
@@ -460,8 +460,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
      tests that embed global/static symbols with null location lists.
      We want to get <optimized out> instead of <frame required> when evaluating
      them so return a frame instead of raising an error.  */
-  else if (var_block == block_global_block (var_block)
-          || var_block == block_static_block (var_block))
+  else if (var_block->is_global_block () || var_block->is_static_block ())
     return frame;
 
   /* We have to handle the "my_func::my_local_var" notation.  This requires us
@@ -486,7 +485,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
 
       /* If we failed to find the proper frame, fallback to the heuristic
         method below.  */
-      else if (frame_block == block_global_block (frame_block))
+      else if (frame_block->is_global_block ())
        {
          frame = NULL;
          break;
@@ -498,7 +497,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
       else if (frame_block->function ())
        {
          const struct dynamic_prop *static_link
-           = block_static_link (frame_block);
+           = frame_block->static_link ();
          int could_climb_up = 0;
 
          if (static_link != NULL)
@@ -533,7 +532,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
       if (frame == NULL)
        {
          if (var_block->function ()
-             && !block_inlined_p (var_block)
+             && !var_block->inlined_p ()
              && var_block->function ()->print_name ())
            error (_("No frame is currently executing in block %s."),
                   var_block->function ()->print_name ());
@@ -589,7 +588,7 @@ language_defn::read_var_value (struct symbol *var,
       v = value::allocate (type);
       store_signed_integer (v->contents_raw ().data (), type->length (),
                            type_byte_order (type), var->value_longest ());
-      VALUE_LVAL (v) = not_lval;
+      v->set_lval (not_lval);
       return v;
 
     case LOC_LABEL:
@@ -616,7 +615,7 @@ language_defn::read_var_value (struct symbol *var,
        struct type *void_ptr_type
          = builtin_type (var->arch ())->builtin_data_ptr;
        v = value_cast_pointers (void_ptr_type, v, 0);
-       VALUE_LVAL (v) = not_lval;
+       v->set_lval (not_lval);
        return v;
       }
 
@@ -629,7 +628,7 @@ language_defn::read_var_value (struct symbol *var,
       v = value::allocate (type);
       memcpy (v->contents_raw ().data (), var->value_bytes (),
              type->length ());
-      VALUE_LVAL (v) = not_lval;
+      v->set_lval (not_lval);
       return v;
 
     case LOC_STATIC:
@@ -754,9 +753,9 @@ language_defn::read_var_value (struct symbol *var,
           a TLS variable. */
        if (obj_section == NULL
            || (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
-          addr = bmsym.minsym->value_raw_address ();
+         addr = CORE_ADDR (bmsym.minsym->unrelocated_address ());
        else
-          addr = bmsym.value_address ();
+         addr = bmsym.value_address ();
        if (overlay_debugging)
          addr = symbol_overlayed_address (addr, obj_section);
        /* Determine address of TLS variable. */
@@ -804,7 +803,7 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type,
   struct value *value = value::allocate (type);
   frame_info_ptr frame;
 
-  VALUE_LVAL (value) = lval_register;
+  value->set_lval (lval_register);
   frame = frame_find_by_id (frame_id);
 
   if (frame == NULL)
@@ -846,7 +845,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame)
   int regnum = VALUE_REGNUM (value);
   int len = type_length_units (check_typedef (value->type ()));
 
-  gdb_assert (VALUE_LVAL (value) == lval_register);
+  gdb_assert (value->lval () == lval_register);
 
   /* Skip registers wholly inside of REG_OFFSET.  */
   while (reg_offset >= register_size (gdbarch, regnum))
@@ -896,7 +895,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
         is that gdbarch_register_to_value populates the entire value
         including the location.  */
       v = value::allocate (type);
-      VALUE_LVAL (v) = lval_register;
+      v->set_lval (lval_register);
       VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
       VALUE_REGNUM (v) = regnum;
       ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,