public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Pass alignment when using GCC_C_FE_VERSION_2 Date: Thu, 14 Mar 2024 15:56:01 +0000 (GMT) [thread overview] Message-ID: <20240314155601.04B00385781F@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=91e15dbaf9d05747fab0d33e5af7ae69c983398a commit 91e15dbaf9d05747fab0d33e5af7ae69c983398a Author: Tom Tromey <tom@tromey.com> Date: Wed Feb 21 08:22:01 2024 -0700 Pass alignment when using GCC_C_FE_VERSION_2 When the GCC compiler plugin responds with GCC_C_FE_VERSION_2, gdb can use the new 'finish_record_with_alignment' method. This lets gdb pass alignment information to the compiler, which in turn fixes the test case included in this patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31397 Diff: --- gdb/compile/compile-c-types.c | 6 +++++- gdb/testsuite/gdb.compile/compile.c | 7 +++++++ gdb/testsuite/gdb.compile/compile.exp | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 1bfaefc4933..1243be369f8 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -118,7 +118,11 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) type->field (i).loc_bitpos ()); } - context->plugin ().finish_record_or_union (result, type->length ()); + if (context->plugin ().version () >= GCC_C_FE_VERSION_2) + context->plugin ().finish_record_with_alignment (result, type->length (), + type_align (type)); + else + context->plugin ().finish_record_or_union (result, type->length ()); return result; } diff --git a/gdb/testsuite/gdb.compile/compile.c b/gdb/testsuite/gdb.compile/compile.c index 8170a3af5ab..04beae823c8 100644 --- a/gdb/testsuite/gdb.compile/compile.c +++ b/gdb/testsuite/gdb.compile/compile.c @@ -100,6 +100,13 @@ int globalshadow = 10; static int staticshadow = 20; int externed = 7; +struct struct_with_array +{ + char val[7]; +}; + +static struct struct_with_array swa; + int main (void) { diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index fed7b04a4c3..f522a84d5dd 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -397,3 +397,6 @@ gdb_test "p globalvar" " = 1" "expect 1" gdb_test_no_output "compile code shlibvar += 5;" "modify shared library variable" gdb_test "p shlibvar" " = 15" "expect 15" + +# This used to fail due to alignment. PR compile/31397. +gdb_test_no_output "compile code swa.val\[0\] = 1"
reply other threads:[~2024-03-14 15:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240314155601.04B00385781F@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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).