From: Simon Marchi <simon.marchi@polymtl.ca>
To: Shahab Vahedi <shahab.vahedi@gmail.com>, gdb@sourceware.org
Subject: Re: Custom types in target description XMLs
Date: Thu, 15 Jul 2021 10:37:39 -0400 [thread overview]
Message-ID: <429b4e0f-032b-b946-2f59-ff2f729b1005@polymtl.ca> (raw)
In-Reply-To: <YO3kxtKlu4SLbHM2@gmail.com>
On 2021-07-13 3:08 p.m., Shahab Vahedi via Gdb wrote:
> Hello,
>
> I have difficulties defining a custom register type in a target
> description XML format. For the sake of argument, consider the
> 32-bit register below with it's own contrived fields:
>
> bit: 31 ... 11 10 9 8 7 ... 0
> ,-----------------.---.---.---.---------.
> | dont_care_field | g | u | b | version |
> `-----------------^---^---^---^---------'
>
> I've come up with two definitions. One uses the "flag" and the
> other uses the "struct" type. However, both have their issues
> in representing the correct values. The definitions are as
> follows:
>
> -----------------------------8<-----------------------------
> <?xml version="1.0"?>
>
> <!DOCTYPE feature SYSTEM "gdb-target.dtd">
> <feature name="org.gnu.gdb.arc.fpu">
> <flags id="flag_type" size="4">
> <field name="version" start="0" end="7" type="int" />
> <field name="b" start="8" end="8" type="bool"/>
> <field name="u" start="9" end="9" type="bool"/>
> <field name="g" start="10" end="10" type="bool"/>
> <field name="" start="11" end="31" />
> </flags>
> <struct id="struct_type" size="4">
> <field name="version" start="0" end="7" type="int" />
> <field name="b" start="8" end="8" type="bool"/>
> <field name="u" start="9" end="9" type="bool"/>
> <field name="g" start="10" end="10" type="bool"/>
> <field name="" start="11" end="31" />
> </struct>
> <reg name="f_reg" bitsize="32" type="flag_type"/>
> <reg name="s_reg" bitsize="32" type="struct_type"/>
> </feature>
> ----------------------------->8-----------------------------
>
> The value reported by GDBstub (QEMU) is 0x1337 for both registers:
>
> 0 x 1 3 3 7
> 0001 0011 0011 0111
>
> version: 0x37 (55)
> b: true
> u: true
> g: false
>
> However, this is how GDB prints them:
>
> ---------------------- [ gdb ] ----------------------
> (gdb) info reg $f_reg
> f_reg 0x1337 [ version=0 b u ]
> -----------------------------------------------------
>
> Here, while "$f_reg" holds the correct value (0x1337), the
> "version" field is 0 instead of 55. "b", "u", and "g" fields
> are inferred correctly though.
>
> ---------------------- [ gdb ] ----------------------
> (gdb) info reg $s_reg
> s_reg {
> version = 0x37,
> b = 0xff,
> u = 0xff,
> g = 0x0
> } {
> version = 55,
> b = -1,
> u = -1,
> g = false
> }
> -----------------------------------------------------
>
> The register with struct type on the other hand, interprets
> "version" correctly while misjudging the "boolean" fields that
> are set.
>
> Am I doing something wrong or this could be a bug in parsing?
> If latter is the case, I will dive into the code to find the
> root cause. I just need someone to confirm it first.
Hi Shahab,
Given the lack of response, I would say that nobody knows that off-hand,
and you would need to dive into the code to check what is happening, if
it's a GDB bug or something else.
Simon
next prev parent reply other threads:[~2021-07-15 14:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 19:08 Shahab Vahedi
2021-07-15 14:37 ` Simon Marchi [this message]
2021-07-15 17:21 ` Shahab Vahedi
2021-08-02 11:51 ` 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=429b4e0f-032b-b946-2f59-ff2f729b1005@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb@sourceware.org \
--cc=shahab.vahedi@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).