]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Turn value_bits_synthetic_pointer into a method
authorTom Tromey <tom@tromey.com>
Tue, 31 Jan 2023 21:17:50 +0000 (14:17 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 13 Feb 2023 22:22:16 +0000 (15:22 -0700)
This changes value_bits_synthetic_pointer to be a method of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/cp-valprint.c
gdb/dwarf2/expr.c
gdb/opencl-lang.c
gdb/p-valprint.c
gdb/valops.c
gdb/valprint.c
gdb/value.c
gdb/value.h

index dd3968257980eed68bad0f53d8a1aabcf83ad4e4..5f18d372aa30849cf08ef254abe3ab01483cad5d 100644 (file)
@@ -270,9 +270,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
                  fputs_styled ("<optimized out or zero length>",
                                metadata_style.style (), stream);
                }
-             else if (value_bits_synthetic_pointer
-                        (val, type->field (i).loc_bitpos (),
-                         TYPE_FIELD_BITSIZE (type, i)))
+             else if (val->bits_synthetic_pointer
+                      (type->field (i).loc_bitpos (),
+                       TYPE_FIELD_BITSIZE (type, i)))
                {
                  fputs_styled (_("<synthetic pointer>"),
                                metadata_style.style (), stream);
index e08dca01a67aaf65791a7f1308762f31f7b1cc43..ef93b89aaa920828bc5036acb7274e164e1c2509 100644 (file)
@@ -576,8 +576,8 @@ coerce_pieced_ref (const value *value)
 {
   struct type *type = check_typedef (value->type ());
 
-  if (value_bits_synthetic_pointer (value, value->embedded_offset (),
-                                   TARGET_CHAR_BIT * type->length ()))
+  if (value->bits_synthetic_pointer (value->embedded_offset (),
+                                    TARGET_CHAR_BIT * type->length ()))
     {
       const piece_closure *closure
        = (piece_closure *) value->computed_closure ();
index 8bc727cdfdf59f621841b71c80f937e4c4d5fa6a..e4a88a23d49edd41ff8a18f8c30003f03e8e7b9e 100644 (file)
@@ -215,9 +215,8 @@ lval_func_check_synthetic_pointer (const struct value *v,
       int comp_offset = (i == start) ? startrest : 0;
       int comp_length = (i == end) ? endrest : elsize;
 
-      if (!value_bits_synthetic_pointer (c->val,
-                                        c->indices[i] * elsize + comp_offset,
-                                        comp_length))
+      if (!c->val->bits_synthetic_pointer (c->indices[i] * elsize + comp_offset,
+                                          comp_length))
        return 0;
     }
 
index c6b9b5571dd48199d41e993baae087cadce77ed0..4b84ec1c43f4a670ae084222eb42ffc26403e1a0 100644 (file)
@@ -609,9 +609,9 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
                  fputs_styled ("<optimized out or zero length>",
                                metadata_style.style (), stream);
                }
-             else if (value_bits_synthetic_pointer
-                        (val, type->field (i).loc_bitpos (),
-                         TYPE_FIELD_BITSIZE (type, i)))
+             else if (val->bits_synthetic_pointer
+                      (type->field (i).loc_bitpos (),
+                       TYPE_FIELD_BITSIZE (type, i)))
                {
                  fputs_styled (_("<synthetic pointer>"),
                                metadata_style.style (), stream);
index 6896478c0f8c32e3210dc4dd07aa60dc9a8d7179..fc9c6dcfe64437170eb1c583f381cb9b9bdd5896 100644 (file)
@@ -1556,8 +1556,8 @@ value_addr (struct value *arg1)
 
   if (TYPE_IS_REFERENCE (type))
     {
-      if (value_bits_synthetic_pointer (arg1, arg1->embedded_offset (),
-         TARGET_CHAR_BIT * type->length ()))
+      if (arg1->bits_synthetic_pointer (arg1->embedded_offset (),
+                                       TARGET_CHAR_BIT * type->length ()))
        arg1 = coerce_ref (arg1);
       else
        {
index 2fa18b8f8e832c7052636843a5eef0605cd5d8ac..08e8826e5b923cb40aeee7c8b7927e1093f421c2 100644 (file)
@@ -381,8 +381,8 @@ valprint_check_validity (struct ui_file *stream,
          return 0;
        }
 
-      if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset,
-                                       TARGET_CHAR_BIT * type->length ()))
+      if (val->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset,
+                                      TARGET_CHAR_BIT * type->length ()))
        {
          const int is_ref = type->code () == TYPE_CODE_REF;
          int ref_is_addressable = 0;
@@ -568,9 +568,8 @@ generic_val_print_ref (struct type *type,
   struct type *elttype = check_typedef (type->target_type ());
   struct value *deref_val = NULL;
   const int value_is_synthetic
-    = value_bits_synthetic_pointer (original_value,
-                                   TARGET_CHAR_BIT * embedded_offset,
-                                   TARGET_CHAR_BIT * type->length ());
+    = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset,
+                                             TARGET_CHAR_BIT * type->length ());
   const int must_coerce_ref = ((options->addressprint && value_is_synthetic)
                               || options->deref_ref);
   const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF;
index 6198fb84d223451e8a9f8a5774bb74856ac6ef4c..75f8dc49b0a18b45e942bf59f2741e540d4ffb74 100644 (file)
@@ -1365,15 +1365,13 @@ mark_value_bits_optimized_out (struct value *value,
 }
 
 int
-value_bits_synthetic_pointer (const struct value *value,
-                             LONGEST offset, LONGEST length)
+value::bits_synthetic_pointer (LONGEST offset, LONGEST length) const
 {
-  if (value->m_lval != lval_computed
-      || !value->m_location.computed.funcs->check_synthetic_pointer)
+  if (m_lval != lval_computed
+      || !m_location.computed.funcs->check_synthetic_pointer)
     return 0;
-  return value->m_location.computed.funcs->check_synthetic_pointer (value,
-                                                                 offset,
-                                                                 length);
+  return m_location.computed.funcs->check_synthetic_pointer (this, offset,
+                                                            length);
 }
 
 const struct lval_funcs *
index b025d678c6da8696c8d616b155a45cf3a8ecd4e7..5738584291905f030f00531a233c33c81a705e3a 100644 (file)
@@ -455,6 +455,11 @@ public:
      values.  */
   bool contents_eq (const struct value *val2) const;
 
+  /* Given a value, determine whether the bits starting at OFFSET and
+     extending for LENGTH bits are a synthetic pointer.  */
+
+  int bits_synthetic_pointer (LONGEST offset, LONGEST length) const;
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -862,12 +867,6 @@ extern struct value *coerce_ref (struct value *value);
 
 extern struct value *coerce_array (struct value *value);
 
-/* Given a value, determine whether the bits starting at OFFSET and
-   extending for LENGTH bits are a synthetic pointer.  */
-
-extern int value_bits_synthetic_pointer (const struct value *value,
-                                        LONGEST offset, LONGEST length);
-
 /* Given a value, determine whether the contents bytes starting at
    OFFSET and extending for LENGTH bytes are available.  This returns
    nonzero if all bytes in the given range are available, zero if any