我正在使用 gdb 7.2 以及 Dan Marinescu 的配置,该配置允许打印 STL 矢量字符串等(pstring、pvector 等)
看起来不太好。因此,查看下面的答案之一,我清理并使用了 7.0 及更高版本中可用的漂亮打印机。
为了做到这一点,我将以下内容放入我的 .gdbinit 中。
python
import sys
sys.path.insert(0, '/home/me/gdb_printers/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
set print elements 0
说明说将代码从 svn 下载到 /home/me/gdb_printers/python 但那是不久前的事了。我注意到 gdb 7.3 中有代码。所以我删除了上面的内容,基础知识有效,但 stl 没有。这是一个包含字符串的对象:
{a = 2, b = 97 'a', c = 2469135780247, d = 1.1363636363636362, e = {
静态npos = 18446744073709551615,
_M_dataplus = {>; = {<__gnu_cxx::new_allocator>; = {}, }, _M_p = 0x602028 "foo"}}}
./gdb-7.3.50.20110526/gdb/data-directory/python/gdb:
为了使用 STL,我需要下载 archer 项目的代码:
svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
并将其放在上面的目录中,确保所有其他垃圾都消失了,并且它工作得很好。
I am using gdb 7.2 with the configuration by Dan Marinescu that allows printing STL vectors strings, etc. (pstring, pvector, etc)
It doesn't seem very good. So looking at one of the answers below, I cleaned out and used the pretty printers available in 7.0 and better.
In order to do so, I put the following in my .gdbinit
python
import sys
sys.path.insert(0, '/home/me/gdb_printers/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
set print elements 0
The instructions say to download the code from svn into /home/me/gdb_printers/python but that was a while ago. I noticed that there was code is in gdb 7.3. So I deleted the above and the basics work but stl does not. Here's an object containing a string:
{a = 2, b = 97 'a', c = 2469135780247, d = 1.1363636363636362, e = {
static npos = 18446744073709551615,
_M_dataplus = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x602028 "foo"}}}
./gdb-7.3.50.20110526/gdb/data-directory/python/gdb:
In order to work with STL, I needed to download the code for the archer project:
svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
and put it in the above directory, making sure all the other junk was gone, and it works beautifully.
发布评论
评论(1)
您想要做的是在 GDB 7.0 及更高版本中使用 Python 漂亮打印机。
您不需要
pstring
,常规print
就可以工作(也适用于嵌入字符串)。What you want to do is addressed in GDB 7.0 and above with Python pretty printers.
You don't need
pstring
, regularprint
just works (for embedded strings too).