This is the mail archive of the mailing list for the libstdc++ project.

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

Severe problems debugging c++ code (g++ 3.0)

Though debugging c++ programs (especially code from libstdc++) is
getting better, there are still severe problems which should be fixed
before gcc 3.0 is released. On the one these are a regression with
respect to gcc 2.95 and on the other make debugging more difficult
than it is already is. 

For example consider the following code tp.C from PR/1819.

Source code tp.C


int main()
    std::cout << " ";

Compiling the program:
g++ -v -o tp tp.C -W -Wall -g
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.0 20010605 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tp.C -D__GNUG__=3 -D_GNU_SOURCE -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase tp.C -g -W -Wall -version -o /tmp/ccxTgf1P.s
GNU CPP version 3.0 20010605 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010605 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010605 (prerelease).
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../../../i686-pc-linux-gnu/bin/as --traditional-format -V -Qy -o /tmp/ccSPPh3W.o /tmp/ccxTgf1P.s
GNU assembler version (i686-pc-linux-gnu) using BFD version
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/collect2 -m elf_i386 -dynamic-linker /lib/ -o tp /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../.. /tmp/ccSPPh3W.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/crtend.o /usr/lib/crtn.o

Debugging the program:

Starting program: /home/peter/trans/c++/breymann/examples/k8/tp 

Breakpoint 1, main () at tp.C:5
(gdb) s
std::ios_base::width(int) (this=0x804def0, __wide=28)
    at /usr/local/include/g++-v3/bits/ios_base.h:359
(gdb) s
(gdb) s
(gdb) s
(gdb) s
main () at tp.C:6
(gdb) s
std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (
    __out=@0x804dee8, __s=0x804bec0 " ")
    at /usr/local/include/g++-v3/bits/std_ostream.h:678
Line number 678 out of range; /usr/local/include/g++-v3/bits/std_ostream.h has 283 lines.

You see single stepping through the program does not work if you step
into the std::cout << " " line. The file or line number information is
simply wrong. If I compile tp.C by gcc 2.95.2, this problem does not
occur. I assume that the line number is indeed correct but the file
name is wrong: The correct file name is bits/ostream.tcc, I suppose.

I believe this is the same problem as reported in PR 2234.

Could someone please fix this really disturbing and long standing
problem or at least mark this PR as a high priority problem or file a
new PR with a test case that is easier to comprehend.

Hope this helps,

Peter Schmid


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