GDB, g++, backtrace problem

Andrew de Quincey adq_dvb@lidskialf.net
Mon Nov 8 16:30:00 GMT 2004


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?



More information about the Gdb mailing list