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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to