[英]gdb not loading pretty printers in thread?
I am currently trying to setup a VSCode project (the Godot sources for anyone interested), with compilation and debugging, however I can't get the pretty printers of GDB (version 8.1.1) to work.我目前正在尝试通过编译和调试来设置 VSCode 项目(任何感兴趣的人的 Godot 源代码),但是我无法让 GDB(版本 8.1.1)的漂亮打印机工作。
In a regular application (a simple helloworld.cpp), if I compile, and debug, then get the pretty printer info, I get the foolowing:在一个普通的应用程序(一个简单的 helloworld.cpp)中,如果我编译和调试,然后得到漂亮的打印机信息,我就会明白:
(gdb) info pretty-printer
global pretty-printers:
builtin
mpx_bound128
objfile /usr/lib/x86_64-linux-gnu/libstdc++.so.6 pretty-printers:
libstdc++-v6 [disabled]
__gnu_cxx::_Slist_iterator
__gnu_cxx::__8::_Slist_iterator
__gnu_cxx::__8::__normal_iterator
__gnu_cxx::__8::slist
__gnu_cxx::__normal_iterator
__gnu_cxx::slist
__gnu_debug::_Safe_iterator
std::_Deque_const_iterator
std::_Deque_iterator
std::_Fwd_list_const_iterator
std::_Fwd_list_iterator
std::_List_const_iterator
std::_List_iterator
std::_Node_handle
std::_Rb_tree_const_iterator
std::_Rb_tree_iterator
std::__8::_Deque_const_iterator
std::__8::_Deque_iterator
std::__8::_Fwd_list_const_iterator
std::__8::_Fwd_list_iterator
std::__8::_List_const_iterator
std::__8::_List_iterator
std::__8::_Node_handle
std::__8::_Rb_tree_const_iterator
std::__8::_Rb_tree_iterator
std::__8::__cxx11::__cxx1998::list
std::__8::__cxx11::basic_string
(...)
However, in my other project, when I launch the debugger and try to get info on the pretty printers, I get the following:但是,在我的另一个项目中,当我启动调试器并尝试获取有关漂亮打印机的信息时,我得到以下信息:
(gdb) info pretty-printer
global pretty-printers:
builtin
mpx_bound128
objfile /lib/x86_64-linux-gnu/libpthread.so.0 pretty-printers:
glibc-pthread-locks
pthread_cond_t
pthread_condattr_t
pthread_mutex_t
pthread_mutexattr_t
pthread_rwlock_t
pthread_rwlockattr_t
And nothing more.仅此而已。 If I put a breakpoint in the program and get data, it won't get pretty printed, eg:如果我在程序中放置一个断点并获取数据,它就不会被很好地打印出来,例如:
$2 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0xc9115d0 "salut mec ça va ?"}, _M_string_length = 18, {
_M_local_buf = "\022\000\000\000\000\000\000\000\370\245\377\377\377\177\000", _M_allocated_capacity = 18}}
At the beginning of the debugging of my nonworking example, I get the following message:在开始调试我的非工作示例时,我收到以下消息:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Which hints me that the pretty print is not working (compared to my working example) because of the use of threads ?这暗示我由于使用了线程,漂亮的打印件不起作用(与我的工作示例相比)?
To ensure that gdb uses the pretty printer, I have created a ~/.gdbinit
file with the following content:为了确保 gdb 使用漂亮的打印机,我创建了一个~/.gdbinit
文件,内容如下:
python
import sys
sys.path.insert(0, '/usr/share/gcc-8/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
end
Which doesn't seem to have any effect.这似乎没有任何影响。
However, in my other project, when I launch the debugger and try to get info on the pretty printers, I get the following:但是,在我的另一个项目中,当我启动调试器并尝试获取有关漂亮打印机的信息时,我得到以下信息:
This is most likely happening because your other project did not link libstdc++.so.6
-- possibly because you used -static-libstdc++
.这很可能是因为您的其他项目没有链接libstdc++.so.6
—— 可能是因为您使用了-static-libstdc++
。
To ensure that gdb uses the pretty printer, I have created为了确保 gdb 使用漂亮的打印机,我创建了
Your file imports the register_libstdcxx_printers
function, but doesn't call it.您的文件导入register_libstdcxx_printers
函数,但不调用它。 To actually instantiate all the libstdc++
printers, add a call:要实际实例化所有libstdc++
打印机,请添加一个调用:
python
import sys
sys.path.insert(0, '/usr/share/gcc-8/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers(None)
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.