]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/dwarf2/loc.c
Turn many optimized-out value functions into methods
[thirdparty/binutils-gdb.git] / gdb / dwarf2 / loc.c
index fe91d609f194ffe4ce5805e12b7c7e2f901349ce..616db13488b95be81b52765a59d78c588692dc40 100644 (file)
@@ -516,7 +516,7 @@ locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame)
      dwarf2_evaluate_loc_desc returns a value representing a variable at
      that address.  The frame base address is thus this variable's
      address.  */
-  return value_address (result);
+  return result->address ();
 }
 
 /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
@@ -573,7 +573,7 @@ loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame)
      dwarf2_evaluate_loc_desc returns a value representing a variable at
      that address.  The frame base address is thus this variable's
      address.  */
-  return value_address (result);
+  return result->address ();
 }
 
 /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
@@ -685,7 +685,7 @@ call_site_target::iterate_over_addresses
                                        dwarf_block->per_objfile);
        /* DW_AT_call_target is a DWARF expression, not a DWARF location.  */
        if (VALUE_LVAL (val) == lval_memory)
-         callback (value_address (val));
+         callback (val->address ());
        else
          callback (value_as_address (val));
       }
@@ -718,9 +718,7 @@ call_site_target::iterate_over_addresses
     case call_site_target::PHYSADDR:
       {
        dwarf2_per_objfile *per_objfile = call_site->per_objfile;
-       compunit_symtab *cust = per_objfile->get_symtab (call_site->per_cu);
-       int sect_idx = cust->block_line_section ();
-       CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
+       CORE_ADDR delta = per_objfile->objfile->text_section_offset ();
 
        callback (m_loc.physaddr + delta);
       }
@@ -729,9 +727,7 @@ call_site_target::iterate_over_addresses
     case call_site_target::ADDRESSES:
       {
        dwarf2_per_objfile *per_objfile = call_site->per_objfile;
-       compunit_symtab *cust = per_objfile->get_symtab (call_site->per_cu);
-       int sect_idx = cust->block_line_section ();
-       CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
+       CORE_ADDR delta = per_objfile->objfile->text_section_offset ();
 
        for (unsigned i = 0; i < m_loc.addresses.length; ++i)
          callback (m_loc.addresses.values[i] + delta);
@@ -1277,14 +1273,14 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
 static struct value *
 entry_data_value_coerce_ref (const struct value *value)
 {
-  struct type *checked_type = check_typedef (value_type (value));
+  struct type *checked_type = check_typedef (value->type ());
   struct value *target_val;
 
   if (!TYPE_IS_REFERENCE (checked_type))
     return NULL;
 
-  target_val = (struct value *) value_computed_closure (value);
-  value_incref (target_val);
+  target_val = (struct value *) value->computed_closure ();
+  target_val->incref ();
   return target_val;
 }
 
@@ -1293,9 +1289,9 @@ entry_data_value_coerce_ref (const struct value *value)
 static void *
 entry_data_value_copy_closure (const struct value *v)
 {
-  struct value *target_val = (struct value *) value_computed_closure (v);
+  struct value *target_val = (struct value *) v->computed_closure ();
 
-  value_incref (target_val);
+  target_val->incref ();
   return target_val;
 }
 
@@ -1304,9 +1300,9 @@ entry_data_value_copy_closure (const struct value *v)
 static void
 entry_data_value_free_closure (struct value *v)
 {
-  struct value *target_val = (struct value *) value_computed_closure (v);
+  struct value *target_val = (struct value *) v->computed_closure ();
 
-  value_decref (target_val);
+  target_val->decref ();
 }
 
 /* Vector for methods for an entry value reference where the referenced value
@@ -1363,14 +1359,14 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame,
                                               caller_per_cu,
                                               caller_per_objfile);
 
-  val = allocate_computed_value (type, &entry_data_value_funcs,
+  val = value::allocate_computed (type, &entry_data_value_funcs,
                                 release_value (target_val).release ());
 
   /* Copy the referencing pointer to the new computed value.  */
-  memcpy (value_contents_raw (val).data (),
-         value_contents_raw (outer_val).data (),
+  memcpy (val->contents_raw ().data (),
+         outer_val->contents_raw ().data (),
          checked_type->length ());
-  set_value_lazy (val, 0);
+  val->set_lazy (0);
 
   return val;
 }
@@ -1433,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
        invalid_synthetic_pointer ();
     }
   else
-    result = allocate_optimized_out_value (type->target_type ());
+    result = value::allocate_optimized_out (type->target_type ());
 
   return result;
 }
@@ -1501,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
     invalid_synthetic_pointer ();
 
   if (size == 0)
-    return allocate_optimized_out_value (subobj_type);
+    return value::allocate_optimized_out (subobj_type);
 
   dwarf_expr_context ctx (per_objfile, per_cu->addr_size ());
 
@@ -1518,9 +1514,9 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
       if (ex.error == NOT_AVAILABLE_ERROR)
        {
          free_values.free_to_mark ();
-         retval = allocate_value (subobj_type);
-         mark_value_bytes_unavailable (retval, 0,
-                                       subobj_type->length ());
+         retval = value::allocate (subobj_type);
+         retval->mark_bytes_unavailable (0,
+                                         subobj_type->length ());
          return retval;
        }
       else if (ex.error == NO_ENTRY_VALUE_ERROR)
@@ -1528,7 +1524,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
          if (entry_values_debug)
            exception_print (gdb_stdout, ex);
          free_values.free_to_mark ();
-         return allocate_optimized_out_value (subobj_type);
+         return value::allocate_optimized_out (subobj_type);
        }
       else
        throw;
@@ -1542,7 +1538,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
   value_ref_ptr value_holder = value_ref_ptr::new_reference (retval);
   free_values.free_to_mark ();
 
-  return value_copy (retval);
+  return retval->copy ();
 }
 
 /* The exported interface to dwarf2_evaluate_loc_desc_full; it always
@@ -1613,11 +1609,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
        throw;
     }
 
-  if (value_optimized_out (result))
+  if (result->optimized_out ())
     return 0;
 
   if (VALUE_LVAL (result) == lval_memory)
-    *valp = value_address (result);
+    *valp = result->address ();
   else
     {
       if (VALUE_LVAL (result) == not_lval)
@@ -1713,7 +1709,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
            val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data,
                                            size, baton->loclist.per_cu,
                                            baton->loclist.per_objfile);
-           if (!value_optimized_out (val))
+           if (!val->optimized_out ())
              {
                *value = value_as_address (val);
                return true;
@@ -3910,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
   CORE_ADDR pc;
 
   if (frame == NULL || !get_frame_func_if_available (frame, &pc))
-    return allocate_optimized_out_value (symbol->type ());
+    return value::allocate_optimized_out (symbol->type ());
 
   data = dwarf2_find_location_expression (dlbaton, &size, pc);
   if (data == NULL)
-    return allocate_optimized_out_value (symbol->type ());
+    return value::allocate_optimized_out (symbol->type ());
 
   return value_of_dwarf_block_entry (symbol->type (), frame, data, size);
 }