This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

backtrace/2352: gdb prints incorrect backtrace when on RET at end of a procedure


>Number:         2352
>Category:       backtrace
>Synopsis:       gdb prints incorrect backtrace when on RET at end of a procedure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 30 13:28:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Richard Parkins
>Release:        GNU gdb 6.5  - configured as "x86_64-suse-linux"
>Organization:
>Environment:
Linux rparkins64 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
>Description:
(gdb) bt
#0  func (x=1, y=2, z=3) at gdbtest.c:7
#1  0x0000000000400588 in main (argc=1, argv=0x7fff3e94f5c8, envp=0x7fff3e94f5d8) at gdbtest.c:14
(gdb) # this backtrace is correct
(gdb) stepi
0x0000000000400538 in func (x=0, y=0, z=0) at gdbtest.c:7
7       }
(gdb) bt
#0  0x0000000000400538 in func (x=0, y=0, z=0) at gdbtest.c:7
#1  0x00002b626c392ae4 in __libc_start_main () from /lib64/libc.so.6
#2  0x0000000000400479 in _start ()
(gdb) # this backtrace is not correct
>How-To-Repeat:
See attached file
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gdbBugReport"
Content-Disposition: inline; filename="gdbBugReport"

In any event, we also recommend that you submit bug reports for GDB.
The prefered method is to submit them directly using GDB's Bugs web
page (http://www.gnu.org/software/gdb/bugs/).  Alternatively, the
e-mail gateway <bug-gdb@gnu.org> can be used.

gdb prints incorrect backtrace when on RET at end of a procedure

rparkins@rparkins64:~/test64> cat gdbtest.c
#include <stdio.h>
#include <stdlib.h>

static void func(long x, long y, long z)
{
    printf("%d %d %d\n", x, y, z);
}

int main(int argc __attribute ((unused)),
         char *argv[] __attribute ((unused)),
         char *envp[] __attribute ((unused)))
{
    int array[10] = {0};
    func(1, 2, 3);
}
rparkins@rparkins64:~/test64> gcc -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --program-suffix=-4.1 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)
rparkins@rparkins64:~/test64> gcc -g gdbtest.c
rparkins@rparkins64:~/test64> gdb a.out
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-suse-linux"...Using host libthread_db library "/lib64/libthread_db.so.1".

(gdb) disass func
Dump of assembler code for function func:
0x0000000000400508 <func+0>:    push   %rbp
0x0000000000400509 <func+1>:    mov    %rsp,%rbp
0x000000000040050c <func+4>:    sub    $0x20,%rsp
0x0000000000400510 <func+8>:    mov    %rdi,0xfffffffffffffff8(%rbp)
0x0000000000400514 <func+12>:   mov    %rsi,0xfffffffffffffff0(%rbp)
0x0000000000400518 <func+16>:   mov    %rdx,0xffffffffffffffe8(%rbp)
0x000000000040051c <func+20>:   mov    0xffffffffffffffe8(%rbp),%rcx
0x0000000000400520 <func+24>:   mov    0xfffffffffffffff0(%rbp),%rdx
0x0000000000400524 <func+28>:   mov    0xfffffffffffffff8(%rbp),%rsi
0x0000000000400528 <func+32>:   mov    $0x400678,%edi
0x000000000040052d <func+37>:   mov    $0x0,%eax
0x0000000000400532 <func+42>:   callq  0x400428 <printf@plt>
0x0000000000400537 <func+47>:   leaveq
0x0000000000400538 <func+48>:   retq
End of assembler dump.
(gdb) break *0x400537
Breakpoint 1 at 0x400537: file gdbtest.c, line 7.
(gdb) run
Starting program: /home/rparkins/test64/a.out
1 2 3

Breakpoint 1, func (x=1, y=2, z=3) at gdbtest.c:7
7       }
(gdb) bt
#0  func (x=1, y=2, z=3) at gdbtest.c:7
#1  0x0000000000400588 in main (argc=1, argv=0x7fff3e94f5c8, envp=0x7fff3e94f5d8) at gdbtest.c:14
(gdb) # this backtrace is correct
(gdb) stepi
0x0000000000400538 in func (x=0, y=0, z=0) at gdbtest.c:7
7       }
(gdb) bt
#0  0x0000000000400538 in func (x=0, y=0, z=0) at gdbtest.c:7
#1  0x00002b626c392ae4 in __libc_start_main () from /lib64/libc.so.6
#2  0x0000000000400479 in _start ()
(gdb) # this backtrace is not correct
(gdb) q
The program is running.  Exit anyway? (y or n) y
rparkins@rparkins64:~/test64> uname -a
Linux rparkins64 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]