简体   繁体   English

GDB C ++-在查看核心转储时检查STL容器?

[英]GDB C++ - Inspecting STL Containers when looking at a core dump?

I'm debugging a core dump of my program (post-mortem) inside gdb. 我正在调试gdb中我的程序的核心转储(事后调查)。 I opened it with: gdb [program_name] [core_name] 我用以下命令打开它:gdb [program_name] [core_name]

However when I attempt to inspect a STL vector, eg print vec->size() or print vec->at(0) 但是,当我尝试检查STL向量时,例如print vec-> size()或print vec-> at(0)

I get the error 我得到错误

"You can't do that without a process to debug" “如果没有调试过程,您将无法做到”

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 the vector: 打印矢量:

(gdb) print *vec

Then familiarize yourself with the internals of your implementation's vector and print the raw buffer. 然后熟悉实现向量的内部,并打印原始缓冲区。 Often called "_M_buffer" or something like that. 通常称为“ _M_buffer”或类似名称。 Depending on how yours is done there may be an internal object that the buffer is inside of. 根据您的工作方式,可能在缓冲区内部有一个内部对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM