From: Luis Machado <lgustavo@codesourcery.com>
To: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] MIPS bit field failures in gdb.base/store.exp
Date: Fri, 19 Sep 2014 16:45:00 -0000 [thread overview]
Message-ID: <541C5D9D.9030809@codesourcery.com> (raw)
In-Reply-To: <5413534F.7000705@codesourcery.com>
On 09/12/2014 05:10 PM, Luis Machado wrote:
> Hi,
>
> I've been chasing this one for a while, trying to come up with the best
> solution while not having to do many changes to GDB's type system.
>
> On MIPS64 little endian, attempting an assignment to a bit field that
> lives in a register yields the wrong result. It just corrupts the data
> in the register depending on the specific position of the bit field
> inside the structure.
>
> FAIL: gdb.base/store.exp: f_1.j
> FAIL: gdb.base/store.exp: f_1.k
> FAIL: gdb.base/store.exp: F_1.i
> FAIL: gdb.base/store.exp: F_1.j
> FAIL: gdb.base/store.exp: F_1.k
> FAIL: gdb.base/store.exp: f_2.j
> FAIL: gdb.base/store.exp: f_2.k
> FAIL: gdb.base/store.exp: F_2.i
> FAIL: gdb.base/store.exp: F_2.j
> FAIL: gdb.base/store.exp: F_2.k
> FAIL: gdb.base/store.exp: f_3.j
> FAIL: gdb.base/store.exp: f_3.k
> FAIL: gdb.base/store.exp: F_3.i
> FAIL: gdb.base/store.exp: F_3.j
> FAIL: gdb.base/store.exp: F_3.k
> FAIL: gdb.base/store.exp: f_4.j
> FAIL: gdb.base/store.exp: f_4.k
> FAIL: gdb.base/store.exp: F_4.i
> FAIL: gdb.base/store.exp: F_4.j
> FAIL: gdb.base/store.exp: F_4.k
>
> === gdb Summary ===
>
> # of expected passes 220
> # of unexpected failures 20
>
> Now, GDB knows how to do bit field assignment properly, but MIPS is one
> of those architectures that uses a hook for the register-to-value
> conversion. Although we can properly tell when the type being passed is
> a structure or union, we cannot tell when it is a bit field, because the
> bit field data lives in a value structure. Such data only lives in a
> "type" structure when the parent structure is being referenced, thus you
> can collect them from the flds_bnds members.
>
> A bit field type structure looks pretty much the same as any other
> primitive type like int or char, so we can't distinguish them. Forcing
> more fields into the type structure wouldn't help much, because the type
> structs are shared.
>
> It feels to me GDB's type system is a bit dated and needs to be more
> precise about what it is describing, but for now i just want to fix a
> pending bug.
>
> The most elegant solution i could find without having to touch a number
> of other type-related data structures is making the
> gdbarch_convert_register_p predicate accept a value structure instead of
> a type structure. That way we can properly tell when a bit field is
> being manipulated in registers.
>
> There is still a little problem though. We don't always have a
> meaningful value struct to pass to this predicate, like both ocurrences
> of it in findvar.c. In those cases i went for a dummy value.
>
> In the end, it is functional but a bit ugly. Unless folks have a better
> suggestion, is this ok?
>
> I did tests with x86, mips32 be/le and mips64 be/le. No regressions found.
>
> The lack of bit field data in the type struct also affects other
> functions that rely on type descriptions, though there may not be
> explicit failures due to those yet.
>
> Luis
Ping! Any thoughts on the proposed solution?
next prev parent reply other threads:[~2014-09-19 16:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 20:11 Luis Machado
2014-09-19 16:45 ` Luis Machado [this message]
2014-09-19 17:12 ` Pedro Alves
2014-09-19 17:39 ` Luis Machado
2014-09-25 19:32 ` Luis Machado
2014-09-26 15:45 ` Pedro Alves
2014-09-29 12:36 ` Luis Machado
2014-09-29 13:30 ` Pedro Alves
2014-09-29 17:35 ` Luis Machado
2014-09-30 11:00 ` Pedro Alves
2014-10-03 11:23 ` Luis Machado
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=541C5D9D.9030809@codesourcery.com \
--to=lgustavo@codesourcery.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