<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - std::string has incomplete type in gdb"
href="https://bugs.llvm.org/show_bug.cgi?id=42549">42549</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::string has incomplete type in gdb
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>leonardchan@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Printing a string in gdb gives us an incomplete type.
```
leonardchan@cp-snakewater:~/misc$ cat ~/misc/test.cpp
#include <string>
#include <iostream>
int main() {
std::string s = "a";
std::cerr << s << "\n";
}
leonardchan@cp-snakewater:~/misc$ bin/clang++ ~/misc/test.cpp -g -stdlib=libc++
leonardchan@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@cp-snakewater:~/misc$ g++ ~/misc/test.cpp -g
leonardchan@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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>