g ++(GCC)5.2.0
clang版本3.7.1(标签/ RELEASE_371/final)
GNU gdb(GDB)7.12
由于某种原因,当使用clang编译时,Gdb无法找到std :: string的定义.我有自定义编译和构建gcc和clang,因为Centos 6.5附带了旧版本的gcc.
示例代码
#include <string>
int main()
{
std::string s("This is a string");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
用g ++编译和调试 - 工作得很好
[~]$ g++ -ggdb3 -std=c++14 stl.cpp
[~]$ gdb a.out
GNU gdb (GDB) 7.12
Reading symbols from a.out...done.
(gdb) break main
Breakpoint 1 at 0x400841: file stl.cpp, line 5.
(gdb) r
Starting program: /home/vagrant/a.out
Breakpoint 1, main () at stl.cpp:5
5 std::string s("This is a string");
(gdb) n
7 return 0;
(gdb) p s …Run Code Online (Sandbox Code Playgroud)