public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "shahab.vahedi at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/28104] New: Incorrect extraction of boolean fields in target description "struct" data type
Date: Mon, 19 Jul 2021 14:41:00 +0000	[thread overview]
Message-ID: <bug-28104-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=28104

            Bug ID: 28104
           Summary: Incorrect extraction of boolean fields in target
                    description "struct" data type
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: shahab.vahedi at gmail dot com
  Target Milestone: ---

Affected versions are HEAD, 11, 10, ...

This is a more elaborated bug report of 21184. That report actually mentions
two bugs. This report is only about one of those.

============================================================

Assume there is an XML target description as follows:
---------------- [ target description xml ] ----------------
<?xml version="1.0"?>

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.arc.fpu">
  <struct id="struct_type" size="4">
    <field name="version" start="0"  end="7"  type="int" />
    <field name="g"       start="8"  end="8"  type="bool"/>
    <field name="u"       start="9"  end="9"  type="bool"/>
    <field name="b"       start="10" end="10" type="bool"/>
    <field name=""        start="11" end="31"            />
  </struct>
  <reg name="s_reg" bitsize="32" type="struct_type"/>
</feature>
------------------------------------------------------------

This corresponds to an "s_reg" register like below:
---------------- [ s_reg register format ] -----------------
      ,-----------------.---.---.---.---------.
      | dont_care_field | b | u | g | version |
      `-----------------^---^---^---^---------'
bit:   31     ...     11  10  9   8  7  ...  0
------------------------------------------------------------

When the reported value of "s_reg" is 0x1337:
------- [ s_reg instance with 0x1337 as its value ] --------
  0  x   1    3    3    7
       0001 0011 0011 0111
             bug  version
------------------------------------------------------------ 

GDB prints incorrect information regarding the boolean fields
that are set:
--------------------------- [gdb] --------------------------
(gdb) info reg $s_reg
s_reg          {
  version = 0x37,
  g = 0xff,
  u = 0xff,
  b = 0x0
} {
  version = 55,
  g = -1,
  u = -1,
  b = false
}
------------------------------------------------------------ 

As you can see, the "version" field is interpreted correctly,
but the "g" and "u" fields are represented by "0xff" or "-1"
instead of "1" or "true". The "b" field is fine though.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2021-07-19 14:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 14:41 shahab.vahedi at gmail dot com [this message]
2021-07-19 14:41 ` [Bug gdb/28104] " shahab.vahedi at gmail dot com
2021-07-26 13:55 ` shahab.vahedi at gmail dot com
2021-07-26 13:56 ` shahab.vahedi at gmail dot com
2021-08-02 11:03 ` andrew.burgess at embecosm dot com
2021-08-02 11:07 ` cvs-commit at gcc dot gnu.org
2021-08-02 11:20 ` shahab.vahedi at gmail dot com

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=bug-28104-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).