From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Handle bitfields inside inner structs for internalvars
Date: Fri, 08 Feb 2013 20:47:00 -0000 [thread overview]
Message-ID: <20130208204702.GA22467@host2.jankratochvil.net> (raw)
In-Reply-To: <m338x9npn5.fsf@redhat.com>
On Wed, 06 Feb 2013 21:39:10 +0100, Sergio Durigan Junior wrote:
> gdb/
> 2013-02-06 Sergio Durigan Junior <sergiodj@redhat.com>
>
> * valops.c (value_assign): Handling bitfield offset in
> `lval_internalvar_component' case.
>
> gdb/testsuite/
> 2013-02-06 Sergio Durigan Junior <sergiodj@redhat.com>
>
> * gdb.base/bitfields.c (struct internalvartest): New declaration.
> * gdb.base/bitfields.exp (bitfield_internalvar): New function.
OK for check-in with the bits below.
> --- a/gdb/testsuite/gdb.base/bitfields.exp
> +++ b/gdb/testsuite/gdb.base/bitfields.exp
> @@ -245,6 +245,31 @@ proc bitfield_at_offset {} {
> gdb_test "print container.two.u3" ".* = 3"
> }
>
> +proc bitfield_internalvar {} {
> + global gdb_prompt
> +
> + # First, we create an internal var holding an instance of
> + # the struct (zeroed out).
> + gdb_test "set \$myvar = \(struct internalvartest\) \{0\}" "" \
Backslashes are excessive here, parentheses are not special characters for the
TCL interpretation and this string is not regexp:
gdb_test "set \$myvar = (struct internalvartest) \{0\}" "" \
> + "set internal var"
> +
> + # Now, we set the proper bits.
[...]
> --- a/gdb/valops.c
> +++ b/gdb/valops.c
> @@ -1233,11 +1233,18 @@ value_assign (struct value *toval, struct value *fromval)
> VALUE_INTERNALVAR (toval));
>
> case lval_internalvar_component:
> - set_internalvar_component (VALUE_INTERNALVAR (toval),
> - value_offset (toval),
> - value_bitpos (toval),
> - value_bitsize (toval),
> - fromval);
> + {
> + int offset = value_offset (toval);
> +
> + if (value_bitsize (toval))
> + offset += value_offset (value_parent (toval));
value_address rather tests for value_parent existence; although value_bitsize
is right as value_parent is currently not used elsewhere.
if (value_parent (toval))
{
/* VALUE_INTERNALVAR below corresponds to the parent value while
offset is relative to the parent value. */
gdb_assert (value_parent (value_parent (toval)) == NULL);
offset += value_offset (value_parent (toval));
}
And it was not so clear to me on the first look so I have added this comment
if you are OK with it.
> +
> + set_internalvar_component (VALUE_INTERNALVAR (toval),
> + offset,
> + value_bitpos (toval),
> + value_bitsize (toval),
> + fromval);
> + }
> break;
>
Thanks,
Jan
next prev parent reply other threads:[~2013-02-08 20:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 20:39 Sergio Durigan Junior
2013-02-08 20:47 ` Jan Kratochvil [this message]
2013-02-09 4:52 ` Sergio Durigan Junior
2013-02-09 7:39 ` Jan Kratochvil
2013-02-11 18:06 ` Sergio Durigan Junior
2013-02-11 18:11 ` Jan Kratochvil
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=20130208204702.GA22467@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=sergiodj@redhat.com \
/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