[LLVMbugs] [Bug 24202] New: Can't print std::string in (c)gdb

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 21 13:27:48 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24202

            Bug ID: 24202
           Summary: Can't print std::string in (c)gdb
           Product: new-bugs
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: davidbrcz at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I can't print a single std::string using (c)gdb while it works perfectly fine
with g++. When running the binary from clang, gdb complains that "There is no
member named _M_dataplus.:"

Please find bellow a full copy and paste from my terminal showing the bug

[david at dhcp-38-199 code]$ g++ -v
Using built-in specs.
COLLECT_GCC=/bin/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC) 

[david at dhcp-38-199 code]$ clang -v
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /bin/../lib/gcc/x86_64-redhat-linux/5.1.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/5.1.1
Selected GCC installation: /bin/../lib/gcc/x86_64-redhat-linux/5.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

[david at dhcp-38-199 code]$ cat d.cpp
#include <iostream>
#include <string>


using namespace std;

int main(int argc, char *argv[])
{
    std::string s = "abc";
    getchar();
    return 0;
}

[david at dhcp-38-199 code]$ clang++ -g -std=c++11 d.cpp -o d
[david at dhcp-38-199 code]$ gdb ./d
GNU gdb (GDB) Fedora 7.9.1-17.fc22
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./d...done.
(gdb) b 10
Breakpoint 1 at 0x400a08: file d.cpp, line 10.
(gdb) run
Starting program: /home/david/code/d 
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.21-7.fc22.x86_64

Breakpoint 1, main (argc=1, argv=0x7fffffffdc58) at d.cpp:10
10        getchar();
Missing separate debuginfos, use: dnf debuginfo-install
libgcc-5.1.1-4.fc22.x86_64 libstdc++-5.1.1-4.fc22.x86_64
(gdb) print s
Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
$1 = 
(gdb) quit
A debugging session is active.

    Inferior 1 [process 8960] will be killed.

Quit anyway? (y or n) y

[david at dhcp-38-199 code]$ g++ -g -std=c++11 d.cpp -o d

[david at dhcp-38-199 code]$ gdb ./d
GNU gdb (GDB) Fedora 7.9.1-17.fc22
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./d...done.
(gdb) b 10
Breakpoint 1 at 0x400993: file d.cpp, line 10.
(gdb) run
Starting program: /home/david/code/d 
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.21-7.fc22.x86_64

Breakpoint 1, main (argc=1, argv=0x7fffffffdc58) at d.cpp:10
10        getchar();
Missing separate debuginfos, use: dnf debuginfo-install
libgcc-5.1.1-4.fc22.x86_64 libstdc++-5.1.1-4.fc22.x86_64
(gdb) print s
$1 = "abc"
(gdb) quit
A debugging session is active.

    Inferior 1 [process 9037] will be killed.

Quit anyway? (y or n) y

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150721/79e8aad9/attachment.html>


More information about the llvm-bugs mailing list