mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
Fix passing of struct with bitfields on x86-64
Commit 4aa866af ("Fix AMD64 return value ABI in expression evaluation") introduced a regression when calling a function with a structure that contains bitfields. Because the caller of amd64_has_unaligned_fields handles bitfields already, it seemed to me that the simplest fix was to ignore bitfields here. gdb/ChangeLog 2019-04-24 Tom Tromey <tromey@adacore.com> * amd64-tdep.c (amd64_has_unaligned_fields): Ignore bitfields. gdb/testsuite/ChangeLog 2019-04-24 Tom Tromey <tromey@adacore.com> * gdb.arch/amd64-eval.exp: Test bitfield return. * gdb.arch/amd64-eval.cc (struct Bitfields): New. (class Foo) <return_bitfields>: New method. (main): Call it.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2019-04-24 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* amd64-tdep.c (amd64_has_unaligned_fields): Ignore bitfields.
|
||||||
|
|
||||||
2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* s12z-tdep.c (s12z_unwind_pc): Delete.
|
* s12z-tdep.c (s12z_unwind_pc): Delete.
|
||||||
|
@ -555,11 +555,13 @@ amd64_has_unaligned_fields (struct type *type)
|
|||||||
int bitpos = TYPE_FIELD_BITPOS (type, i);
|
int bitpos = TYPE_FIELD_BITPOS (type, i);
|
||||||
int align = type_align(subtype);
|
int align = type_align(subtype);
|
||||||
|
|
||||||
/* Ignore static fields, or empty fields, for example nested
|
/* Ignore static fields, empty fields (for example nested
|
||||||
empty structures. */
|
empty structures), and bitfields (these are handled by
|
||||||
|
the caller). */
|
||||||
if (field_is_static (&TYPE_FIELD (type, i))
|
if (field_is_static (&TYPE_FIELD (type, i))
|
||||||
|| (TYPE_FIELD_BITSIZE (type, i) == 0
|
|| (TYPE_FIELD_BITSIZE (type, i) == 0
|
||||||
&& TYPE_LENGTH (subtype) == 0))
|
&& TYPE_LENGTH (subtype) == 0)
|
||||||
|
|| TYPE_FIELD_PACKED (type, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (bitpos % 8 != 0)
|
if (bitpos % 8 != 0)
|
||||||
@ -569,7 +571,7 @@ amd64_has_unaligned_fields (struct type *type)
|
|||||||
if (bytepos % align != 0)
|
if (bytepos % align != 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (amd64_has_unaligned_fields(subtype))
|
if (amd64_has_unaligned_fields (subtype))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2019-04-24 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* gdb.arch/amd64-eval.exp: Test bitfield return.
|
||||||
|
* gdb.arch/amd64-eval.cc (struct Bitfields): New.
|
||||||
|
(class Foo) <return_bitfields>: New method.
|
||||||
|
(main): Call it.
|
||||||
|
|
||||||
2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* gdb.cp/many-args.cc: New file.
|
* gdb.cp/many-args.cc: New file.
|
||||||
|
@ -63,6 +63,16 @@ struct UnalignedFieldsInBase : public UnalignedFields
|
|||||||
int32_t x2;
|
int32_t x2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Bitfields
|
||||||
|
{
|
||||||
|
Bitfields(unsigned int x, unsigned int y)
|
||||||
|
: fld(x), fld2(y)
|
||||||
|
{}
|
||||||
|
|
||||||
|
unsigned fld : 7;
|
||||||
|
unsigned fld2 : 7;
|
||||||
|
};
|
||||||
|
|
||||||
class Foo
|
class Foo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -101,6 +111,13 @@ public:
|
|||||||
return UnalignedFieldsInBase (x, y, x2);
|
return UnalignedFieldsInBase (x, y, x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bitfields
|
||||||
|
return_bitfields (unsigned int x, unsigned int y)
|
||||||
|
{
|
||||||
|
assert (this->tag == EXPECTED_TAG);
|
||||||
|
return Bitfields(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Use a tag to detect if the "this" value is correct. */
|
/* Use a tag to detect if the "this" value is correct. */
|
||||||
static const int EXPECTED_TAG = 0xF00F00F0;
|
static const int EXPECTED_TAG = 0xF00F00F0;
|
||||||
@ -116,5 +133,6 @@ main (int argc, char *argv[])
|
|||||||
foo.return_non_trivial_destructor(3);
|
foo.return_non_trivial_destructor(3);
|
||||||
foo.return_unaligned(4, 5);
|
foo.return_unaligned(4, 5);
|
||||||
foo.return_unaligned_in_base(6, 7, 8);
|
foo.return_unaligned_in_base(6, 7, 8);
|
||||||
|
foo.return_bitfields(23, 74);
|
||||||
return 0; // break-here
|
return 0; // break-here
|
||||||
}
|
}
|
||||||
|
@ -41,3 +41,5 @@ gdb_test "call foo.return_unaligned(78, 9.25)" \
|
|||||||
" = {x = 78, y = 9.25}"
|
" = {x = 78, y = 9.25}"
|
||||||
gdb_test "call foo.return_unaligned_in_base(23, 4.5, 67)" \
|
gdb_test "call foo.return_unaligned_in_base(23, 4.5, 67)" \
|
||||||
" = {<UnalignedFields> = {x = 23, y = 4.5}, x2 = 67}"
|
" = {<UnalignedFields> = {x = 23, y = 4.5}, x2 = 67}"
|
||||||
|
gdb_test "call foo.return_bitfields(23, 74)" \
|
||||||
|
" = {fld = 23, fld2 = 74}"
|
||||||
|
Reference in New Issue
Block a user