public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Project Archer <archer@sourceware.org>
Subject: Re: Calculating array length
Date: Mon, 22 Jun 2009 12:15:00 -0000	[thread overview]
Message-ID: <20090622121451.GA32382@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <1245672417.12380.2.camel@wsjoost>


On Sun, 21 Jun 2009 14:22:48 +0200, Joost van der Sluis wrote:
> It only works partly. The length of the strings are ok. But they are not
> displayed correctly. That's because at the object_address points at the
> address where another address is stored, which points at the actual
> string. With your patch this second address is printed as the output.
> 
> So not only the type has to be evaluated again for each element, also
> the data-location.

This was an intention in my testcase+patch but sure there will be various bugs
- I also did not include it to the repository due to them.

> >   struct string_t
> >     {
>     <8e>   DW_AT_data_location: 2 byte block: 97 6      (DW_OP_push_object_address; DW_OP_deref)
> >       const char *string;
                ^^^^^^
> >       unsigned long length;
> >     }



> But this means that the object address of a type should be set. Where do
> we do that? And is it true that a 'struct type *' is only used for one
> variable at a time? How do we enforce that?

`struct type *' can used many times for various objects.  But the code should
be changed to use `struct value *' - and that one should be created for each
variable (array element) separately.


> I was working on a patch that removes the dynamic stuff from the 'stuct
> type *' into the 'struct value *'.

Yes, I would like it such way.


> That works, but the main problem with that is that the *_val_print functions
> do not have a 'struct value *' as parameter, so they can not access it. Or
> they should construct a new 'struct value' from the type and the address. 

Yes, something like that.


> So maybe we should adapt value_fetch_lazy so that it does not only sets
> val_address, but also the  dynamic fields in the type.

I think that even before value_fetch_lazy the GDB code needs to know various
dynamic parameters like the element stride, probably the dimensions etc. even
before value_fetch_lazy would be made.

Imagine accessing element [1,1,1,1] of a terribly big array.  GDB should not
call value_fetch_lazy for the whole array, it should work with the
dimensions/addresses only and apply value_fetch_lazy only on the single final
element (knowing its final address).

I do not think there should be something like check_value (making the dynamic
values static) instead of current check_typedef.  There has to be some sanity
check one does not access the parameter (such as the stride) before it gets
calculated from its dynamic representation.  And such sanity check can just
on-demand evaluate it on the first access instead.  It is true `value' should
not change after its parameters have been accessed on some final object
address - for subelements of an array a new `value' should be always created
(instead of modifying/reusing the old `value').



Thanks,
Jan

      reply	other threads:[~2009-06-22 12:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-07 10:23 Joost van der Sluis
2009-06-07 14:48 ` Jan Kratochvil
2009-06-07 16:06   ` Joost van der Sluis
2009-06-07 17:49     ` Jan Kratochvil
2009-06-07 17:59       ` Jan Kratochvil
2009-06-12 21:24       ` Joost van der Sluis
2009-06-15 11:57         ` Jan Kratochvil
2009-06-15 12:16           ` Jan Kratochvil
2009-06-14 20:30       ` Joost van der Sluis
2009-06-20 22:34         ` Jan Kratochvil
2009-06-22 12:07           ` Joost van der Sluis
2009-06-22 12:15             ` Jan Kratochvil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090622121451.GA32382@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=archer@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).