public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/106400] New: Wrong debug info for function parameter in aarch64
@ 2022-07-22  5:34 liyd2021 at gmail dot com
  0 siblings, 0 replies; only message in thread
From: liyd2021 at gmail dot com @ 2022-07-22  5:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106400

            Bug ID: 106400
           Summary: Wrong debug info for function parameter in aarch64
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liyd2021 at gmail dot com
  Target Milestone: ---

This bug occured in aarch64, not in x86. GDB print the parameter x=65535 while
the correct value should be 3. It seems the value has not been stored in stack
at the breakpoint, and x has correct value after executing the store
instruction.

Affected versions:  gcc 12.1.0 (Ubuntu 20.04.2)
(terminal) $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc-12.1.0/libexec/gcc/aarch64-unknown-linux-gnu/12.1.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: /var/tmp/gcc-12.1.0_source/gcc-12.1.0/configure
--prefix=/opt/gcc-12.1.0 --enable-bootstrap --enable-shared
--enable-threads=posix --enable-checking=release --without-included-gettext
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC)

(terminal) $ cat a.c && gcc -g -OO a.c
int bar(int x) {
    return x;
}

__attribute__((optimize("Og"))) int foo(const char *fmt, ...) {
    return bar(3);
}

int main() {
    return foo("fmt") == 3;
}

--------------------

(terminal) $ gdb a.out
(gdb) b bar
Breakpoint 1 at 0x4005e4: file a.c, line 1.
(gdb) r
Breakpoint 1, bar (x=65535) at a.c:1  <-- bug : should be 3
1       int bar(int x) {


B+>0x4005e4 <bar>:      sub     sp, sp, #0x10  <- x=65535
   0x4005e8 <bar+4>:    str     w0, [sp, #12]  
   0x4005ec <bar+8>:    ldr     w0, [sp, #12]  <- x=3
   0x4005f0 <bar+12>:   add     sp, sp, #0x10

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-22  5:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  5:34 [Bug debug/106400] New: Wrong debug info for function parameter in aarch64 liyd2021 at gmail dot com

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).