Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/DWARF] Set enum type "flag_enum" and "unsigned" flags at type creation.
Date: Wed, 19 Feb 2014 14:34:00 -0000	[thread overview]
Message-ID: <1392820455.21975.235.camel@bordewijk.wildebeest.org> (raw)
In-Reply-To: <1390796357-3739-1-git-send-email-brobecker@adacore.com>

On Mon, 2014-01-27 at 08:19 +0400, Joel Brobecker wrote:
> To understand why the range type's upper bound is read as a negative
> value, one needs to look at how it is determined, in read_subrange_type:
> 
>   orig_base_type = die_type (die, cu);
>   base_type = check_typedef (orig_base_type);
>   [... high is first correctly read as 128, but then ...]
>   if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
>     high |= negative_mask;
> 
> The negative_mask is applied, here, because BASE_TYPE->FLAG_UNSIGNED
> is not set. And the reason for that is because the base_type was only
> partially constructed during the call to die_type. While the enum
> is constructed on the fly by read_enumeration_type, its flag_unsigned
> flag is only set later on, while creating the symbols corresponding to
> the enum type's enumerators (see process_enumeration_scope), after
> we've already finished creating our range type - and therefore too
> late.

This looks suspicious. I think the explicit sign-extension is in general
wrong. It seems to assume that the DWARF producer encoded the
DW_AT_upper_bound wrongly (not as a signed value, but as an unsigned
value that needs to be sign-extended). Something like that might happen
in theory if the producer used DW_FORM_data[1248] because DWARF doesn't
define how to encode signed values in that case. But in practice this
seems to have been settled by interpreting these values as zero-extended
values (not sign-extended) and by the producer using either
DW_FORM_sdata or DW_FORM_udata to remove any ambiguity (like in your
testcase).

Does anything break if you just remove the sign-extension part?
If not, then you don't have to go through the whole
update_enumeration_type_from_children. Or do you need that for anything
else?

Cheers,

Mark



  parent reply	other threads:[~2014-02-19 14:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27  8:09 Joel Brobecker
2014-02-10 14:29 ` Joel Brobecker
2014-02-17 20:20 ` Joel Brobecker
2014-02-19 14:34 ` Mark Wielaard [this message]
2014-02-19 15:18   ` Mark Wielaard
2014-02-21  9:21     ` Joel Brobecker
2014-02-25 14:32       ` Mark Wielaard
2014-02-26 18:32     ` Joel Brobecker
2014-02-26 18:58       ` Joel Brobecker
2014-02-27 10:30       ` Mark Wielaard
2014-02-27 11:15         ` Mark Wielaard
2014-02-27 14:29         ` Joel Brobecker
2014-02-26 18:42 ` pushed: " 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=1392820455.21975.235.camel@bordewijk.wildebeest.org \
    --to=mjw@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