admin管理员组文章数量:1122846
I have the following code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s{"qwe"};
while (true){} // in order to attach
cout << s << endl;
}
I run gdbserver
with the command:
sudo gdbserver --attach localhost:2345 `pidof my_proj`
Then I run gdb
and attach to gdbserver
:
gdb
(gdb) target remote localhost:2345
As expected, it freezes on while (true){}
, and when I'm trying to read the s
variable I get the following output:
(gdb) print s
$1 = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7ffea7445190 "qwe"},
_M_string_length = 3, {_M_local_buf = "qwe", '\000' <repeats 12 times>,
_M_allocated_capacity = 6649713}}
It's not as pretty as I'd like it to be. But when I attach to my program directly with gdb
and print the same variable, it looks quite pretty:
gdb -p `pidof my_proj`
(gdb) print s
$1 = "qwe"
What is the reason of such a behavior and how can I make the pretty printing work with gdbserver
?
本文标签: cSTL containers don39t prettyprint when connected to gdbserverStack Overflow
版权声明:本文标题:c++ - STL containers don't pretty-print when connected to gdbserver? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308618a1933726.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论