This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] "lazily" allocate the raw content of lazy values

>>>>> "Jerome" == Jerome Guitton <> writes:

Jerome> Here, an elegant solution would be to manipulate lazy values instead
Jerome> of references

Very nice background explanation, thanks.

Jerome> +/* Actual contents of the value.  For use of this value; setting it
Jerome> +   uses the stuff defined in struct value.  Target byte-order.  We force it
Jerome> +   to be aligned properly for any possible value.  Note that a value therefore
Jerome> +   extends beyond what is declared here.  */
Jerome> +
Jerome> +union value_aligner
Jerome> +{
Jerome> +  gdb_byte contents[1];
Jerome> +  DOUBLEST force_doublest_align;
Jerome> +  LONGEST force_longest_align;
Jerome> +  CORE_ADDR force_core_addr_align;
Jerome> +  void *force_pointer_align;  
Jerome> +};

The purpose of this union is just to force alignment of the 'contents'
field, so that we can stuff any data type into it without worrying.
Once we're no longer using the struct hack to store the bits, there is
no need for this union.

Jerome> +  union value_aligner *content;

I think you might as well make this "gdb_byte *contents" now.

I think it would be nice to have a test case showing the Ada problem.
This would help prevent mistakes if we ever want to change the value
representation again.  Would this be hard to do?

After that I only have nits.

Jerome> +void
Jerome> +value_free (struct value *val)
Jerome> +{
Jerome> +  if (val && val->content)

No need to check val->content, xfree does that.

Jerome>  struct value *
Jerome>  value_change_enclosing_type (struct value *val, struct type *new_encl_type)

You were right, value_change_enclosing_type is much simpler now :-)

Jerome>        if (value_lazy (arg1))
Jerome> -	set_value_lazy (v, 1);
Jerome> +        {
Jerome> +          v = allocate_value_lazy (value_enclosing_type (arg1));
Jerome> +        }

In the GNU style, a single statement like this does not have braces
around it.  There are a few instances of this in the patch.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]