rkeeler78
rkeeler78

Reputation: 117

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

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?

Upvotes: 4

Views: 3711

Answers (1)

Edward Strange
Edward Strange

Reputation: 40877

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.

Upvotes: 2

Related Questions