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

99封情书 提交于 2019-12-01 21:38:06

问题


I'm debugging a core dump of my program (post-mortem) inside gdb. I opened it with: gdb [program_name] [core_name]

However when I attempt to inspect a STL vector, e.g. print vec->size() or 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?


回答1:


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. Depending on how yours is done there may be an internal object that the buffer is inside of.



来源:https://stackoverflow.com/questions/10399973/gdb-c-inspecting-stl-containers-when-looking-at-a-core-dump

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!