From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/Ada] Crash when trying to set value of packed array element
Date: Fri, 16 Mar 2012 11:06:00 -0000 [thread overview]
Message-ID: <20120316110510.GA25193@host2.jankratochvil.net> (raw)
In-Reply-To: <1330556589-3594-1-git-send-email-brobecker@adacore.com>
Hi Joel,
On Thu, 01 Mar 2012 00:03:09 +0100, Joel Brobecker wrote:
> Still, this was not sufficient, because it caused a regression when
> trying to perform an aggregate assignment of a packed array of packed
> record. The key element here is the nesting of packed entities.
> Looking at the way ada_value_primitive_packed_val creates the value
> of each sub-component, one can see that the value's offset is set
> to the offset compared to the start of the parent. This was meant to
> match what value_primitive_field does as well.
>
> So, with our array of records, if the record offset was 2, and if
> the field we're interested in that record is at offset 1, the record
> value's offset would be set to 2, and the field value's offset would
> be set to 1. But the address for both values would be left to the
> array's address. This is where things start breaking down, because
> the value_address function for our field value would return the
> address of the array + 1, instead of + 3.
>
> This is what causes the final issue, here, because ada-lang.c's
> value_assign_to_component needs to compute the offset of the
> subcomponent compared to the top-level aggregate's start address
> (the array in our case).
It depends on how is defined functionality of ada_value_primitive_packed_val.
Whether its parameter OFFSET is relative to the start of the array or whether
it is relative to the element. I believe you want the latter and your patch
also implements the latter, otherwise I cannot imagine how callers would
handle it correctly. In the latter case the parameter name OFFSET is
confusing and it should be renamed as it is _added_ to value_offset (OBJ).
In general I do not think we can ever fix it all on top of the current
infrastructure. These OFFSETs, EMBEDDED_OFFSETs etc. should be dropped, there
should be support for discontiguos set of memory snapshot associated with
struct value (so that it supports for example even virtual method tables or
slices of multidimensional Fortran arrays). I should find time for
archer-jankratochvil-vla.
> @@ -2310,18 +2309,22 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
>
> if (obj != NULL)
> {
> - CORE_ADDR new_addr;
> + long new_offset = offset;
Nitpick - LONGEST (Siddhesh Poyarekar is working on a more thorough fix).
> }
>
> +void
> +set_value_parent (struct value *value, struct value *parent)
Missing function comment.
Thanks,
Jan
next prev parent reply other threads:[~2012-03-16 11:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 23:15 Joel Brobecker
2012-03-14 20:54 ` Ping: " Joel Brobecker
2012-03-16 11:06 ` Jan Kratochvil [this message]
2012-03-16 18:00 ` Joel Brobecker
2012-03-16 18:50 ` Jan Kratochvil
2012-03-19 4:17 ` Siddhesh Poyarekar
2012-03-19 15:54 ` Joel Brobecker
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=20120316110510.GA25193@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@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