减少 gdb 打印中的垃圾

发布于 2024-11-09 03:16:04 字数 917 浏览 0 评论 0 原文

我正在使用 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只等公子 2024-11-16 03:16:04

您想要做的是在 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, regular print just works (for embedded strings too).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文