Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Yao Qi <qiyaoltc@gmail.com>, Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Phil Muldoon <pmuldoon@redhat.com>
Subject: Re: [PATCH] Fix type casts losing typedefs and reimplement "whatis" typedef stripping
Date: Sat, 18 Nov 2017 22:58:00 -0000	[thread overview]
Message-ID: <4b73fb98-b8c2-9d2f-1981-4660e3c202e6@simark.ca> (raw)
In-Reply-To: <CAH=s-PMc+bp7rXhwZ0kNdTc5WZ+xL0G1NSE6m3pMM_zFo60b6Q@mail.gmail.com>

On 2017-11-18 03:57 PM, Yao Qi wrote:
> On Mon, Aug 21, 2017 at 11:38 AM, Pedro Alves <palves@redhat.com> wrote:
> 
> Hi Pedro,
> The new tests in gdb.base/whatis-ptype-typedefs.exp fail on 32-bit target.
> 
> https://gdb-build.sergiodj.net/builders/Ubuntu-AArch32-m32/builds/1175/steps/test%20gdb/logs/stdio
> https://gdb-build.sergiodj.net/builders/Fedora-i686/builds/6867/steps/test%20gdb/logs/stdio
> https://gdb-build.sergiodj.net/builders/Fedora-x86_64-m32/builds/6849/steps/test%20gdb/logs/stdio
> 
> Can you take a look?
> 

I took a quick look.  The issue (at least one of them) boils down to the fact
that on 64 bits, you can't do this:

(gdb) p (float_typedef) v_uchar_array_t_struct_typedef
Invalid cast.

but on 32 bits you can:

(gdb) p (float_typedef) v_uchar_array_t_struct_typedef
$1 = 1.16251721e-41

The expression basically tries to cast an array (which decays to a pointer) to
a float.  The cast works on 32 bits (doesn't give Invalid cast) because a float
and a pointer are of the same size, and the execution enters this if branch:

https://github.com/bminor/binutils-gdb/blob/master/gdb/valops.c#L554

On 64 bits, they are not the same size, so it ends up in the invalid cast
branch.

I don't really know what to do from there.  Should we leave the behavior as-is
and update the test, or prevent this kind of cast (the compiler doesn't accept
that anyway, and I don't see any real use case to this).  This function (value_cast)
is a bit convoluted, I'm always afraid to touch it...

Simon


  reply	other threads:[~2017-11-18 22:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 15:48 Pedro Alves
2017-08-16 20:11 ` Pedro Alves
2017-08-21 10:39   ` Pedro Alves
2017-11-18 20:57     ` Yao Qi
2017-11-18 22:58       ` Simon Marchi [this message]
2017-11-20 16:42         ` Pedro Alves
2017-11-20 17:01           ` Simon Marchi
2017-11-20 22:35           ` Yao Qi
2017-11-20 23:11             ` [pushed] Fix gdb.base/whatis-ptype-typedefs.exp on 32-bit archs (Re: [PATCH] Fix type casts losing typedefs and reimplement "whatis" typedef stripping) Pedro Alves
2017-11-20 23:06           ` [PATCH] Fix type casts losing typedefs and reimplement "whatis" typedef stripping Andreas Schwab

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=4b73fb98-b8c2-9d2f-1981-4660e3c202e6@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=pmuldoon@redhat.com \
    --cc=qiyaoltc@gmail.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