public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with gcc-12
Date: Tue, 24 May 2022 16:36:39 +0100	[thread overview]
Message-ID: <5ca5c802-141a-c3b3-da9f-8e102bc151e5@arm.com> (raw)
In-Reply-To: <20220524140704.GA23593@delia.home>

Hi,

On 5/24/22 15:07, Tom de Vries via Gdb-patches wrote:
> Hi,
> 
> When running test-case gdb.opt/clobbered-registers-O2.exp with gcc-12, I run
> into:
> ...
> (gdb) PASS: gdb.opt/clobbered-registers-O2.exp: backtracing
> print operand0^M
> $1 = (unsigned int *) 0x7fffffffd070^M
> (gdb) print *operand0^M
> $2 = 4195541^M
> (gdb) FAIL: gdb.opt/clobbered-registers-O2.exp: print operand0
> ...
> 
> The problem is that starting gcc-12, the assignments to x and y in main are
> optimized away:
> ...
> int main(void)
> {
>    unsigned x, y;
> 
>    x = 13;
>    y = 14;
>    return (int)gen_movsd (&x, &y);
> ...
> 
> Fix this by making x and y volatile.
> 
> Note that the test-case intends to check the handling of debug info for
> optimized code in function gen_movsd, so inhibiting optimization in main
> doesn't interfere with that.
> 
> Tested on x86_64-linux.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29161
> 
> Any comments?

Sorry, this was so long ago. I don't remember if we had a dwarf info assembler back in those days,
but it might be easier to simulate an optimized-away value by hand as opposed to doing some
contortionism with compilers and flags. But ...

> 
> Thanks,
> - Tom
> 
> [gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with gcc-12
> 
> ---
>   gdb/testsuite/gdb.opt/clobbered-registers-O2.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.opt/clobbered-registers-O2.c b/gdb/testsuite/gdb.opt/clobbered-registers-O2.c
> index 7776024eb90..83cf2267d1e 100644
> --- a/gdb/testsuite/gdb.opt/clobbered-registers-O2.c
> +++ b/gdb/testsuite/gdb.opt/clobbered-registers-O2.c
> @@ -33,7 +33,7 @@ gen_movsd (unsigned * operand0, unsigned * operand1)
>   
>   int main(void)
>   {
> -  unsigned x, y;
> +  volatile unsigned x, y;
>   
>     x = 13;
>     y = 14;

... if the above fixes the problem, it should be fine. I'm OK with it.

      reply	other threads:[~2022-05-24 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24 14:07 Tom de Vries
2022-05-24 15:36 ` Luis Machado [this message]

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=5ca5c802-141a-c3b3-da9f-8e102bc151e5@arm.com \
    --to=luis.machado@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).