maxcollector
maxcollector

Reputation: 53

Viewing Core Dumps

Im writing a small program. When I run one of the options I get the following error.

terminate called after throwing an instance of 'std::invalid_argument'
what():  stoi
Aborted (core dumped)

I've look in the directory where I store the .cpp and .h files, and core does appear there after I run it. I've used

ulimit -c unlimited

And I checked it with

unlimit -a.

When I run gdb in my terminal and try to access core I get the following response

not in executable format: File format not recognized

How would I look at my core dump so that I can see what's causing it?

Upvotes: 5

Views: 5713

Answers (1)

user149341
user149341

Reputation:

To analyze a core dump with GDB, pass it as the second argument to GDB, after the executable:

gdb executable core

GDB will load the state of the executable at the moment it dumped core. You will be able to examine its memory (including the stack backtrace, as well as any data in the heap or stack), but will be unable to perform actions that require the executable to run (such as stepping, continuing, or calling functions).

Upvotes: 7

Related Questions