views:

219

answers:

2

Valgrind produced a vgcore.NNNN file -- how do I debug the core using GDB? Do I need to use the original executable and supply the core, or is there some other way to do it?

Using valgrind as the root executable doesn't seem to work, and using the executable that was being run under valgrind directly in GDB with the core seems to produce bad backtraces.

A: 

you probably tried the command

gdb vgcore.####

perhaps this will do what you want

gdb exe vgcore.####
DarenW
Just to be clear, only the #### is to be replaced by some particular characters for your situation. The "exe" is literally "exe".
DarenW
that doesn't seem to work - when I run "gdb exe vgcore.16657" I get "exe: No such file or directory.Core was generated by `'."
psychotik
was the program compiled with the -g option?
DarenW
Yes it was. I can debug non valgrind cores just fine...
psychotik
+1  A: 

This works fine for me:

gdb ./a.out vgcore.21650

and that's how you are supposed to use the vgcore.

If your program corrupted stack before crashing, then obviously you wouldn't get good stack traces from vgcore. You might want to expand your question with actual Valgrind report that led to the crash.

Employed Russian