This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
Re: backtrace/1547: corrupt stack?
- From: Francois Taiani <f dot taiani at computer dot org>
- To: chastain at sourceware dot org
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 27 Oct 2005 13:08:01 -0000
- Subject: Re: backtrace/1547: corrupt stack?
- Reply-to: Francois Taiani <f dot taiani at computer dot org>
The following reply was made to PR backtrace/1547; it has been noted by GNATS.
From: Francois Taiani <f.taiani@computer.org>
To: gdb-gnats@sources.redhat.com
Cc: adq_dvb@lidskialf.net
Subject: Re: backtrace/1547: corrupt stack?
Date: Thu, 27 Oct 2005 14:03:08 +0100
Dear GDB team,
This problems looks similar to the one reported by Andrew de Quincey
here [1] (copied below). Andrew provides a far smaller and
easy-to-repeat example:
[1] http://sourceware.org/ml/gdb/2004-11/msg00060.html
Basically gdb seems to struggle to analyse stack frames from code
compiled with the options "-O2 -fPIC". If you happen to debug a program
that uses optimised libraries, you tipically run into this kind of
problems, even if your program does not use those options.
For information, the problem does not seem to be limited to PPC405 code.
I've got the same issue on my G4 powerbook (with gdb 2.3, gcc 4.0.2, and
a 2.6x kernel), it has been reported to happen on x86 as well. See [2]:
[2] http://lists.debian.org/debian-powerpc/2005/05/msg00202.html
Older versions of gdb do not seem to suffer from this. It might be
related to the use of newer gcc versions as well.
Regards
Francois
--------------------------------------------------------
From: Andrew de Quincey <adq_dvb at lidskialf dot net>
To: gdb at sources dot redhat dot com
Date: Mon, 8 Nov 2004 00:19:19 +0000
Subject: GDB, g++, backtrace problem
Hi, I've now patched my PPC405 kernel so GDB's breakpoints work
correctly. I now have another problem.
GDB 6.2.1
GCC 3.3.4
linux 2.4.20
uclibc latest snapshot
test program:
-------
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
class test{
public:
int testmethod();
};
int main(int argc, char* argv[])
{
test* test1 = new test();
test1->testmethod();
}
int test::testmethod()
{
printf("hi\n");
}
---------
Compiled with: g++ -g -O2 -fPIC test.cpp
I put a breakpoint on test::testmethod. GDB gives the following in the
backtrace:
#0 test::testmethod (this=0x10011050) at test.cpp:22
#1 0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
#2 0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
#3 0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
Previous frame inner to this frame (corrupt stack?)
It needs -O2 (or -O3) and -fPIC to do it - if you use -O, or miss off
-fPIC,
the backtrace is correct.
Does anyone have any suggestions what might be causing this?