From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simark@simark.ca>, Eli Zaretskii <eliz@gnu.org>,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCHv3 1/2] gdb/amd64: Ignore zero sized fields when calling functions
Date: Fri, 02 Mar 2018 20:10:00 -0000 [thread overview]
Message-ID: <a99f02ac2ff15d7c4ffffda9fc7125267a53f6fd.1520021226.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1520021226.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1520021226.git.andrew.burgess@embecosm.com>
In some cases passing an argument to a function on amd64, or attempting
to fetch the return value, can trigger an assertion failure within GDB.
An example of a type that would trigger such an error is:
struct foo_t
{
long double a;
struct {
struct {
/* Empty. */
} es1;
} s1;
};
GCC does permit empty structures, so we should probably support this.
The test that exposes this bug is in the next commit along with the
RiscV support.
gdb/ChangeLog:
* amd64-tdep.c (amd64_classify_aggregate): Ignore zero sized
fields within aggregates.
---
gdb/ChangeLog | 5 +++++
gdb/amd64-tdep.c | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 6b92c9244c6..07eef5ea9f0 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -601,8 +601,9 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
bitsize = TYPE_LENGTH (subtype) * 8;
endpos = (TYPE_FIELD_BITPOS (type, i) + bitsize - 1) / 64;
- /* Ignore static fields. */
- if (field_is_static (&TYPE_FIELD (type, i)))
+ /* Ignore static fields, or empty fields, for example nested
+ empty structures.*/
+ if (field_is_static (&TYPE_FIELD (type, i)) || bitsize == 0)
continue;
gdb_assert (pos == 0 || pos == 1);
--
2.14.3
next prev parent reply other threads:[~2018-03-02 20:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 19:15 [PATCH] gdb: Initial baremetal riscv support Andrew Burgess
2018-02-13 19:49 ` Eli Zaretskii
2018-02-19 20:01 ` Simon Marchi
2018-02-27 1:09 ` [PATCHv2] " Andrew Burgess
2018-02-27 3:33 ` Simon Marchi
2018-03-02 20:09 ` [PATCHv3 0/2] Initial RiscV Support Andrew Burgess
2018-03-02 20:10 ` [PATCHv3 2/2] gdb: Initial baremetal riscv support Andrew Burgess
2018-03-03 6:27 ` Simon Marchi
2018-03-05 10:46 ` [PATCHv4 " Andrew Burgess
2018-03-05 22:35 ` Simon Marchi
2018-03-06 11:06 ` Yao Qi
2018-03-06 11:35 ` Yao Qi
2018-03-03 7:40 ` [PATCHv3 " Eli Zaretskii
2018-03-02 20:10 ` Andrew Burgess [this message]
2018-03-03 6:29 ` [PATCHv3 1/2] gdb/amd64: Ignore zero sized fields when calling functions Simon Marchi
2018-02-27 3:37 ` [PATCHv2] gdb: Initial baremetal riscv support Simon Marchi
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=a99f02ac2ff15d7c4ffffda9fc7125267a53f6fd.1520021226.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.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).