]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/value.h
Turn allocate_computed_value into static "constructor"
[thirdparty/binutils-gdb.git] / gdb / value.h
index 30c2cb48b708f05610cfaa6c04ef3395737775be..dbbb61932b8fbd4acd866826b79eec99984f827c 100644 (file)
@@ -144,6 +144,9 @@ typedef gdb::ref_ptr<struct value, value_ref_policy> value_ref_ptr;
 
 struct value
 {
+private:
+
+  /* Values can only be created via "static constructors".  */
   explicit value (struct type *type_)
     : m_modifiable (1),
       m_lazy (1),
@@ -156,6 +159,22 @@ struct value
   {
   }
 
+public:
+
+  /* Allocate a lazy value for type TYPE.  Its actual content is
+     "lazily" allocated too: the content field of the return value is
+     NULL; it will be allocated when it is fetched from the target.  */
+  static struct value *allocate_lazy (struct type *type);
+
+  /* Allocate a value and its contents for type TYPE.  */
+  static struct value *allocate (struct type *type);
+
+  /* Create a computed lvalue, with type TYPE, function pointers
+     FUNCS, and closure CLOSURE.  */
+  static struct value *allocate_computed (struct type *type,
+                                         const struct lval_funcs *funcs,
+                                         void *closure);
+
   ~value ();
 
   DISABLE_COPY_AND_ASSIGN (value);
@@ -316,6 +335,35 @@ struct value
   enum lval_type lval () const
   { return m_lval; }
 
+  /* Set or return field indicating whether a variable is initialized or
+     not, based on debugging information supplied by the compiler.
+     1 = initialized; 0 = uninitialized.  */
+  int initialized () const
+  { return m_initialized; }
+
+  void set_initialized (int value)
+  { m_initialized = value; }
+
+  /* If lval == lval_memory, return the address in the inferior.  If
+     lval == lval_register, return the byte offset into the registers
+     structure.  Otherwise, return 0.  The returned address
+     includes the offset, if any.  */
+  CORE_ADDR address () const;
+
+  /* Like address, except the result does not include value's
+     offset.  */
+  CORE_ADDR raw_address () const;
+
+  /* Set the address of a value.  */
+  void set_address (CORE_ADDR);
+
+  struct internalvar **deprecated_internalvar_hack ()
+  { return &m_location.internalvar; }
+
+  struct frame_id *deprecated_next_frame_id_hack ();
+
+  int *deprecated_regnum_hack ();
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -492,6 +540,12 @@ struct value
      limited_length will be set to indicate the length in octets that were
      loaded from the inferior.  */
   ULONGEST m_limited_length = 0;
+
+private:
+
+  /* Allocate a value and its contents for type TYPE.  If CHECK_SIZE
+     is true, then apply the usual max-value-size checks.  */
+  static struct value *allocate (struct type *type, bool check_size);
 };
 
 /* Returns value_type or value_enclosing_type depending on
@@ -571,13 +625,6 @@ struct lval_funcs
   void (*free_closure) (struct value *v);
 };
 
-/* Create a computed lvalue, with type TYPE, function pointers FUNCS,
-   and closure CLOSURE.  */
-
-extern struct value *allocate_computed_value (struct type *type,
-                                             const struct lval_funcs *funcs,
-                                             void *closure);
-
 extern struct value *allocate_optimized_out_value (struct type *type);
 
 /* Throw an error complaining that the value has been optimized
@@ -657,12 +704,6 @@ extern void mark_value_bytes_optimized_out (struct value *value,
 extern void mark_value_bits_optimized_out (struct value *value,
                                           LONGEST offset, LONGEST length);
 
-/* Set or return field indicating whether a variable is initialized or
-   not, based on debugging information supplied by the compiler.
-   1 = initialized; 0 = uninitialized.  */
-extern int value_initialized (const struct value *);
-extern void set_value_initialized (struct value *, int);
-
 /* Set COMPONENT's location as appropriate for a component of WHOLE
    --- regardless of what kind of lvalue WHOLE is.  */
 extern void set_value_component_location (struct value *component,
@@ -675,33 +716,17 @@ extern void set_value_component_location (struct value *component,
    possible kinds of lval.  */
 #define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ()))
 
-/* If lval == lval_memory, return the address in the inferior.  If
-   lval == lval_register, return the byte offset into the registers
-   structure.  Otherwise, return 0.  The returned address
-   includes the offset, if any.  */
-extern CORE_ADDR value_address (const struct value *);
-
-/* Like value_address, except the result does not include value's
-   offset.  */
-extern CORE_ADDR value_raw_address (const struct value *);
-
-/* Set the address of a value.  */
-extern void set_value_address (struct value *, CORE_ADDR);
-
 /* Pointer to internal variable.  */
-extern struct internalvar **deprecated_value_internalvar_hack (struct value *);
-#define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val))
+#define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ()))
 
 /* Frame ID of "next" frame to which a register value is relative.  A
    register value is indicated by VALUE_LVAL being set to lval_register.
    So, if the register value is found relative to frame F, then the
    frame id of F->next will be stored in VALUE_NEXT_FRAME_ID.  */
-extern struct frame_id *deprecated_value_next_frame_id_hack (struct value *);
-#define VALUE_NEXT_FRAME_ID(val) (*deprecated_value_next_frame_id_hack (val))
+#define VALUE_NEXT_FRAME_ID(val) (*((val)->deprecated_next_frame_id_hack ()))
 
 /* Register number if the value is from a register.  */
-extern int *deprecated_value_regnum_hack (struct value *);
-#define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val))
+#define VALUE_REGNUM(val) (*((val)->deprecated_regnum_hack ()))
 
 /* Return value after lval_funcs->coerce_ref (after check_typedef).  Return
    NULL if lval_funcs->coerce_ref is not applicable for whatever reason.  */
@@ -994,8 +1019,6 @@ extern struct value *read_var_value (struct symbol *var,
                                     const struct block *var_block,
                                     frame_info_ptr frame);
 
-extern struct value *allocate_value (struct type *type);
-extern struct value *allocate_value_lazy (struct type *type);
 extern void value_contents_copy (struct value *dst, LONGEST dst_offset,
                                 struct value *src, LONGEST src_offset,
                                 LONGEST length);