[llvm-bugs] [Bug 42549] New: std::string has incomplete type in gdb

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 8 16:59:14 PDT 2019


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

            Bug ID: 42549
           Summary: std::string has incomplete type in gdb
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: leonardchan at google.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Printing a string in gdb gives us an incomplete type.

```
leonardchan at cp-snakewater:~/misc$ cat ~/misc/test.cpp
#include <string>
#include <iostream>

int main() {
  std::string s = "a";
  std::cerr << s << "\n";
}
leonardchan at cp-snakewater:~/misc$ bin/clang++ ~/misc/test.cpp -g -stdlib=libc++
leonardchan at cp-snakewater:~/misc$ gdb a.out
(gdb) list
1       #include <string>
2       #include <iostream>
3       
4       int main() {
5         std::string s = "a";
6         std::cerr << s << "\n";
7       }
(gdb) break 6
Breakpoint 1 at 0x2270ed: file test.cpp, line 6.
(gdb) r
Starting program: /usr/local/google/home/leonardchan/misc/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main () at test.cpp:6
6         std::cerr << s << "\n";
(gdb) print s
$1 = <incomplete type>
```

This was from an executable compiled with tip of tree clang. With g++ however,
we are able to get the string value.

```
leonardchan at cp-snakewater:~/misc$ g++ ~/misc/test.cpp -g
leonardchan at cp-snakewater:~/misc$ gdb a.out
(gdb) break 6
Breakpoint 1 at 0xb92: file /usr/local/google/home/leonardchan/misc/test.cpp,
line 6.
(gdb) r
Starting program: /usr/local/google/home/leonardchan/misc/a.out 

Breakpoint 1, main () at /usr/local/google/home/leonardchan/misc/test.cpp:6
6         std::cerr << s << "\n";
(gdb) print s
$1 = "a"
```

Other stl classes like std::map and std::vector still seem to get printed
normally.

-- 
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/20190708/01936c54/attachment.html>


More information about the llvm-bugs mailing list