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

GDB C++ - Inspecting STL Containers when looking at a core dump?(GDB C++ - 在查看核心转储时检查 STL 容器?)
本文介绍了GDB C++ - 在查看核心转储时检查 STL 容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 gdb 中调试我的程序的核心转储(事后分析).我打开它:gdb [程序名称] [核心名称]

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

但是,当我尝试检查 STL 向量时,例如打印 vec->size()或者打印 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 容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)