From: Tom Tromey <tromey@redhat.com>
To: "Andrew Burgess" <aburgess@broadcom.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Vector to scalar casting and widening
Date: Mon, 19 Nov 2012 21:17:00 -0000 [thread overview]
Message-ID: <87k3thpa2g.fsf@fleche.redhat.com> (raw)
In-Reply-To: <50A254C0.1030901@broadcom.com> (Andrew Burgess's message of "Tue, 13 Nov 2012 14:10:08 +0000")
>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:
Andrew> I'd like to change the way gdb handles scalar to vector
Andrew> widening. I believe that the changes I propose will bring gdb
Andrew> expression evaluation into line with how gcc handles these
Andrew> things; this seems a good thing to me, but I'd be interested to
Andrew> hear why anyone things we should stick with the current scheme.
I agree that we should generally follow the compiler.
In this case what I would suggest is looking up the original vector
patches to gdb to see whether there is some rationale given for the
chosen behavior.
I'm in favor of this change unless that research turns up something; in
which case we should probably discuss it more.
Andrew> +static struct value *
Andrew> +vector_widen (struct value *scalar_value, struct type *vector_type)
Andrew> +{
Andrew> + /* Widen the scalar to a vector. */
Andrew> + struct type *eltype, *scalar_type;
Andrew> + struct value *val, *elval;
Andrew> + LONGEST low_bound, high_bound;
Andrew> + int i;
Andrew> +
Andrew> + gdb_assert (TYPE_CODE (check_typedef (vector_type)) == TYPE_CODE_ARRAY);
Andrew> + gdb_assert (TYPE_VECTOR (vector_type));
Andrew> +
Andrew> + if (!get_array_bounds (vector_type, &low_bound, &high_bound))
Andrew> + error (_("Could not determine the vector bounds"));
Andrew> +
Andrew> + eltype = check_typedef (TYPE_TARGET_TYPE (vector_type));
Andrew> + elval = value_cast (eltype, scalar_value);
I think check_typedef is being applied inconsistently here.
I'd suggest starting the function with a call to the macro:
CHECK_TYPEDEF (vector_type);
then you can drop check_typedef from the first assert.
Andrew> + else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
Andrew> + && code2 == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)
Andrew> + && TYPE_LENGTH (type) != TYPE_LENGTH (type2))
Andrew> + error (_("can't convert between vector values of different size"));
I didn't see a test case for this error.
Could you add one?
Andrew> +++ b/gdb/testsuite/gdb.base/gnu_vector.c
Andrew> @@ -31,6 +31,7 @@ int ia = 2;
Andrew> int ib = 1;
Andrew> float fa = 2;
Andrew> float fb = 1;
Andrew> +long long lla = 0x0000000100000001ll;
Here I don't think we can assume that lla has a particular size, can we?
But since this is a gcc-specific test, I think you can work around it by
using the 'mode' attribute to pick a particular size.
Andrew> +++ b/gdb/testsuite/gdb.python/py-type.c
Andrew> @@ -15,6 +15,8 @@
Andrew> You should have received a copy of the GNU General Public License
Andrew> along with this program. If not, see <http://www.gnu.org/licenses/>. */
Andrew> +#include <stdint.h>
I'm mildly concerned that this will mean that we can't run this test on
some platform. But only mildly, I'm inclined to let it go.
Tom
next prev parent reply other threads:[~2012-11-19 21:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-13 14:10 Andrew Burgess
2012-11-19 21:17 ` Tom Tromey [this message]
2012-11-23 16:26 ` Andrew Burgess
2012-11-26 14:18 ` Ulrich Weigand
2012-11-28 22:08 ` Andrew Burgess
2012-11-29 17:50 ` Ulrich Weigand
2012-11-29 18:13 ` Andrew Burgess
2013-01-04 14:45 ` Andrew Burgess
2013-01-07 16:23 ` Ulrich Weigand
2013-01-08 15:08 ` Andrew Burgess
2013-01-08 19:05 ` Ulrich Weigand
2013-01-09 19:13 ` Tom Tromey
2013-01-25 17:18 ` Andrew Burgess
2013-01-09 19:08 ` Tom Tromey
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=87k3thpa2g.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=aburgess@broadcom.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