Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] handle VLA in a struct or union
Date: Thu, 08 May 2014 21:09:00 -0000	[thread overview]
Message-ID: <20140508210914.GE4063@adacore.com> (raw)
In-Reply-To: <1399574816-12845-3-git-send-email-tromey@redhat.com>

> However, before this goes in, I'd like to understand the oddity
> pointed out by a change in is_dynamic_type.  That is, this test:
> 
> 	      /* This can happen with Ada for reasons unknown.  */
> 	      && TYPE_FIELD_TYPE (type, i) != NULL
> 
> is needed to avoid a crash with the Ada "iwide.exp" test.  This type:
> 
>     (top-gdb) p real_type.main_type.name
>     $15 = 0x7ffff0354c6d "ada__tags__type_specific_data___XVE"
> 
> ... has a seemingly invalid field:
> 
>     (top-gdb) p real_type.main_type.nfields
>     $9 = 13
> [...]
>     (top-gdb) p real_type.main_type.flds_bnds.fields[12]
>     $12 = {
>       loc = {
> 	bitpos = 576,
> 	enumval = 576,
> 	physaddr = 576,
> 	physname = 0x240 <Address 0x240 out of bounds>,
> 	dwarf_block = 0x240
>       },
>       artificial = 0,
>       loc_kind = FIELD_LOC_KIND_BITPOS,
>       bitsize = 0,
>       type = 0x0,
>       name = 0x0
>     }
> 
> Joel, can you comment?  Thanks.

It's actually not the only testcase I see being impacted if I remove
the check. What happens is that we're in the middle of resolving
this very type (what we have been calling creating a fixed version
of the type). While doing so, we do...

    if (dval0 == NULL)
      {
        /* rtype's length is computed based on the run-time
           value of discriminants.  If the discriminants are not
           initialized, the type size may be completely bogus and
           GDB may fail to allocate a value for it.  So check the
           size first before creating the value.  */
        check_size (rtype);
        dval = value_from_contents_and_address (rtype, valaddr, address);
        rtype = value_type (dval);
      }

... where rtype is the resolved type being constructed, and therefore
a type that isn't completely consistent yet. the call to
value_from_contents_and_address eventually leads to the is_dynamic_type
call.

I think I need to review that code, as I do that a litte little
later in the function again. I'll send another update when I have
more info on this.

-- 
Joel


  parent reply	other threads:[~2014-05-08 21:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 18:47 [PATCH 0/2] " Tom Tromey
2014-05-08 18:47 ` [PATCH 1/2] minor cleanups in is_dynamic_type Tom Tromey
2014-05-08 18:47 ` [PATCH 2/2] handle VLA in a struct or union Tom Tromey
2014-05-08 19:01   ` pinskia
2014-05-08 19:07     ` Tom Tromey
2014-05-08 20:30     ` Philippe Waroquiers
2014-05-08 21:32       ` Tom Tromey
2014-05-08 21:09   ` Joel Brobecker [this message]
2014-05-08 21:33     ` Tom Tromey
2014-05-08 22:38       ` Joel Brobecker
2014-05-09 15:57         ` Joel Brobecker
2014-05-21 17:28           ` Tom Tromey
2014-05-21 18:24             ` Joel Brobecker
2014-05-21 22:02             ` Joel Brobecker
2014-05-21 22:28               ` Tom Tromey
2014-06-04 20:27               ` Tom Tromey
2014-05-09  8:05   ` Agovic, Sanimir
2014-05-09 21:08     ` Tom Tromey
2014-05-12 15:37       ` Agovic, Sanimir
2014-05-12 17:00         ` Tom Tromey
2014-05-13  7:53           ` Agovic, Sanimir

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=20140508210914.GE4063@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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