From: Joel Brobecker <brobecker@adacore.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Shahab Vahedi <shahab.vahedi@gmail.com>,
gdb-patches@sourceware.org, Shahab Vahedi <shahab@synopsys.com>,
Simon Marchi <simon.marchi@efficios.com>,
Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH v2] gdb: Fix numerical field extraction for target description "flags"
Date: Sat, 24 Jul 2021 06:50:37 -0700 [thread overview]
Message-ID: <20210724135037.GA2278483@adacore.com> (raw)
In-Reply-To: <7c003060-8c48-9fa7-07eb-4733ef7f30e1@polymtl.ca>
> Shahab expressed (on IRC) the desire to merge this patch in the GDB 11
> branch. That sounds reasonable to me, does it to you?
It does to me too. Thanks Simon and Shahab.
> On 2021-07-23 9:26 a.m., Simon Marchi via Gdb-patches wrote:
> > On 2021-07-23 8:38 a.m., Shahab Vahedi via Gdb-patches wrote:
> >> From: Shahab Vahedi <shahab@synopsys.com>
> >>
> >> v2 (This section will be removed when checking the patch in):
> >> 1. There are no lines in the commit message starting with "---".
> >> 2. Joined 2 lines together that now fit under character limits.
> >> 3. Added the unit-test "test_print_flags" as proposed by Simon.
> >>
> >> The "val_print_type_code_flags ()" function is responsible for
> >> extraction of fields for "flags" data type. These data types are
> >> used when describing a custom register type in a target description
> >> XML. The logic used for the extraction though is not sound:
> >>
> >> unsigned field_len = TYPE_FIELD_BITSIZE (type, field);
> >> ULONGEST field_val
> >> = val >> (TYPE_FIELD_BITPOS (type, field) - field_len + 1);
> >>
> >> TYPE_FIELD_BITSIZE: The bit length of the field to be extracted.
> >> TYPE_FIELD_BITPOS: The starting position of the field; 0 is LSB.
> >> val: The register value.
> >>
> >> Imagine you have a field that starts at position 1 and its length
> >> is 4 bits. According to the third line of the code snippet the
> >> shifting right would become "val >> -2", or "val >> 0xfff...fe"
> >> to be precise. That will result in a "field_val" of 0.
> >>
> >> The correct extraction should be:
> >>
> >> ULONGEST field_val = val >> TYPE_FIELD_BITPOS (type, field);
> >>
> >> The rest of the algorithm that masks out the higher bits is OK.
> >>
> >> Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
> >
> > LGTM, thanks.
> >
> > Simon
> >
--
Joel
next prev parent reply other threads:[~2021-07-24 13:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-23 12:38 Shahab Vahedi
2021-07-23 13:26 ` Simon Marchi
2021-07-24 11:16 ` Simon Marchi
2021-07-24 13:50 ` Joel Brobecker [this message]
2021-07-26 13:33 ` Shahab Vahedi
2021-07-26 13:51 ` Simon Marchi
2021-07-26 13:17 ` [PUSHED master] " Shahab Vahedi
2021-07-26 13:17 ` [PUSHED gdb-11-branch] " Shahab Vahedi
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=20210724135037.GA2278483@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=shahab.vahedi@gmail.com \
--cc=shahab@synopsys.com \
--cc=simon.marchi@efficios.com \
--cc=simon.marchi@polymtl.ca \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).