From: Andrew Burgess Date: Fri, 2 Mar 2018 15:48:23 +0000 (+0000) Subject: gdb/amd64: Ignore zero sized fields when calling functions X-Git-Tag: binutils-2_31~1127 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5dc4391345f6e86906a57af1434025cfb47b4100;p=platform%2Fupstream%2Fbinutils.git gdb/amd64: Ignore zero sized fields when calling functions 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4a44af4..28e5e89 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-03-06 Andrew Burgess + + * amd64-tdep.c (amd64_classify_aggregate): Ignore zero sized + fields within aggregates. + 2018-03-04 Simon Marchi * record-btrace.c (btrace_print_lines): Change type of flags to diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 6b92c92..07eef5e 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);