From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5800 invoked by alias); 2 Apr 2004 12:08:40 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 5784 invoked from network); 2 Apr 2004 12:08:37 -0000 Received: from unknown (HELO thingol.ac.utimaco.de) (194.245.91.1) by sources.redhat.com with SMTP; 2 Apr 2004 12:08:37 -0000 Received: (from mail@localhost) by thingol.ac.utimaco.de (8.12.10/8.12.10) id i32CFYoQ010914 for ; Fri, 2 Apr 2004 14:15:34 +0200 Message-ID: <406D578A.6010408@smgwtest.aachen.utimaco.de> Date: Fri, 02 Apr 2004 12:08:00 -0000 From: Holger Sesterhenn Organization: Utimaco Safeware AG, NL Aachen User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821 MIME-Version: 1.0 To: gdb@sources.redhat.com Subject: Problem debugging statically linked c++ program with GDB 6.0 X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2004-04/txt/msg00010.txt.bz2 Hi, I have a bug in my statically linked c++ program and would like to use DDD with GDB to see whats wrong. I use from the stdlibc++. DDD/GDB shows a SIGSGV if I call a member function e.g. c_str() to take a look at the value of the string. I have written a little program to reproduce the problem (don't need DDD). If the program is linked dynamically, everything works as expected! If somebody can confirm the problem I would submit a bug report. Searching the bug database I did not find any hint. Running Linux 2.4.21 (IA86/32), compiled gcc 3.3.3, glibc 2.3.2 and gdb 6.0 myself (chrooted). The problem can be reproduced with a plain SuSE 9.0 installation (gcc 3.3.1, glibc 2.3.2, gdb 5.3.92). Here is my screen dump. #>g++ -g -static mytest.cpp ###################################### #>../gdb-6.0/gdb/gdb ./a.out GNU gdb 6.0 Copyright 2003 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 "i686-pc-linux-gnu"... (gdb) l 1 #include 2 #include 3 4 int main () { 5 std::string a("Hello"); 6 7 std::cout << a << std::endl; 8 } // main() 9 (gdb) b 7 Breakpoint 1 at 0x8048254: file mytest.cpp, line 7. (gdb) r Starting program: /src/fw/proxy/smtp/smtpd/test/a.out Breakpoint 1, main () at mytest.cpp:7 7 std::cout << a << std::endl; (gdb) p a $1 = {static npos = 4294967295, _M_dataplus = {> = {}, _M_p = 0x8117d2c "Hello"}, static _S_empty_rep_storage = {0, 0, 0, 0}} (gdb) p a.c_str() Program received signal SIGSEGV, Segmentation fault. 0x08088546 in __libc_start_main () The program being debugged was signaled while in a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior use "set unwindonsignal on" Evaluation of the expression containing the function (std::string::c_str() const) will be abandoned. (gdb) ######################################### #>/lib/libc.so.6 GNU C Library stable release version 2.3.2, by Roland McGrath et al. Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 3.3.3. Compiled on a Linux 2.4.23 system on 2004-04-01. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others linuxthreads-0.10 by Xavier Leroy BIND-8.2.3-T5B libthread_db work sponsored by Alpha Processor Inc NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk Report bugs using the `glibcbug' script to . ########################################## #>g++ -g mytest.cpp #>ldd a.out libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40015000) libm.so.6 => /lib/libm.so.6 (0x4013f000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x40162000) libc.so.6 => /lib/libc.so.6 (0x401cf000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) ###################################### #>../gdb-6.0/gdb/gdb ./a.out GNU gdb 6.0 Copyright 2003 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 "i686-pc-linux-gnu"... (gdb) b 7 Breakpoint 1 at 0x80488c8: file mytest.cpp, line 7. (gdb) r Starting program: /src/fw/proxy/smtp/smtpd/test/a.out Breakpoint 1, main () at mytest.cpp:7 7 std::cout << a << std::endl; (gdb) p a $1 = {static npos = 4294967295, _M_dataplus = {> = {}, _M_p = 0x8049db4 "Hello"}, static _S_empty_rep_storage = {0, 0, 0, 0}} (gdb) p a.c_str() $2 = 0x8049db4 "Hello" ######################################## Any hints? -- Best Regards, Holger Sesterhenn --- Internet http://www.utimaco.com