From: Holger Sesterhenn <Holger.Sesterhenn@smgwtest.aachen.utimaco.de>
To: gdb@sources.redhat.com
Subject: Problem debugging statically linked c++ program with GDB 6.0
Date: Fri, 02 Apr 2004 12:08:00 -0000 [thread overview]
Message-ID: <406D578A.6010408@smgwtest.aachen.utimaco.de> (raw)
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 <string> 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 <string>
2 #include <iostream>
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 = {<allocator<char>> =
{<No data fields>}, _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 <bugs@gnu.org>.
##########################################
#>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 = {<allocator<char>> = {<No
data fields>}, _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
next reply other threads:[~2004-04-02 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-02 12:08 Holger Sesterhenn [this message]
2004-04-02 13:26 ` Bob Rossi
2004-04-02 14:48 ` Holger Sesterhenn
2004-04-02 15:16 ` Bob Rossi
2004-04-05 9:45 ` Holger Sesterhenn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=406D578A.6010408@smgwtest.aachen.utimaco.de \
--to=holger.sesterhenn@smgwtest.aachen.utimaco.de \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox