GDB C ++ - 在查看核心转储时检查STL容器? [英] GDB C++ - Inspecting STL Containers when looking at a core dump?
问题描述
我正在调试gdb中我的程序(验尸)的核心转储。我打开它:
gdb [program_name] [core_name]
I'm debugging a core dump of my program (post-mortem) inside gdb. I opened it with: gdb [program_name] [core_name]
然而,当我试图检查一个STL向量,
print vec-> size()
或
print vec-> at(0)
However when I attempt to inspect a STL vector, e.g. print vec->size() or print vec->at(0)
我得到错误
如果没有调试过程就不能这样做
"You can't do that without a process to debug"
我只是想检查这些容器的内容和大小。有没有办法将一个虚拟进程附加到核心转储gdb检查,所以我可以这样做?
I'm just trying to inspect the contents and sizes of these containers. Is there any way to attach a dummy process to a core-dump gdb inspection so I can do this?
推荐答案
(gdb) print *vec
然后熟悉实现向量的内部并打印原始缓冲区。通常称为_M_buffer或类似的东西。根据你的操作方式,缓冲区可能是一个内部对象。
Then familiarize yourself with the internals of your implementation's vector and print the raw buffer. Often called "_M_buffer" or something like that. Depending on how yours is done there may be an internal object that the buffer is inside of.
这篇关于GDB C ++ - 在查看核心转储时检查STL容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!