I would like read a core-dump file dumped with gcore.
However, I would like to read a coredump file in my c++ application, not with gdb terminal command.
For instance, I have a executable program 'testEx' and it is killed by some reason then 'testEx' left a core dump.
I am creating a C++ application 'readGDB' to analyze core dump created by 'testEx'.
Any c++ library and example to read a core file?
Asked
Active
Viewed 101 times
0

John Doyle
- 898
- 2
- 9
- 22
-
Core files are just executable files (a.out or ELF or whatever it is on Mac OS X). So any library that reads executable formats will do. – n. m. could be an AI Aug 30 '15 at 12:54
-
@n.m. If you wish to execute 'dump binary memory' command with gdb on given coredump, how would you do it in c++? – John Doyle Aug 30 '15 at 13:11
-
I would read the memory with libelf or similar, then write it to a file. – n. m. could be an AI Aug 30 '15 at 13:41
1 Answers
0
Any c++ library and example to read a core file?
Reading the core
is trivial: you just open
and read
it.
What's not trivial is understanding what the contents means. A core
file is an ELF
file, so it has a lot of internal structure, and libraries such as libelf
can help you read specific sections of the core
.
But that's still long way away from what GDB does: to really understand the contents, you also need to implement symbol management, stack unwinding, and many more things. In short, you will have to re-implement half of GDB.
So why not just use GDB? You can talk to GDB from your application, and make it give you the answers you are seeking. GDB has a special machine interface mode for just that purpose.

Employed Russian
- 199,314
- 34
- 295
- 362