My program operates like this:
exe -p param1 -i param2 -o param3
It crashed and generated a core dump file core.pid
I want to analyze the core dump file by
gdb ./exe -p param1 -i param2 -o param3 core.pid
but the gdb recognize the paramters of exe
as gdb's input.
How to analyze core dump file in this situation?
You can use the core with gdb in many ways, but passing parameters which is to be passed to executable to gdb is not the way to use core file. This could also be the reason you got that error. You can use the core file in following ways:
gdb <executable> <core-file>
orgdb <executable> -c <core-file>
orWhen using core file you don't have to pass arguments. The crash scenario is shown in gdb (checked with gdb Version 7.1 on Ubuntu) . For example:
If you want to pass parameters to the executable to be debugged in gdb use
--args
.For example:
Man pages will be helpful to see other gdb options.
A slightly different approach will allow you to skip GDB entirely. If all you want is a backtrace, the linux-specific utility 'catchsegv' will catch SIGSEGV and display a backtrace.
You can analyze the core dump file using "gdb" command.
Thanks.
Simply type command
or
No need to provide any command line arguement. The code dump generated due to earlier exercise.
Just skip the params, gdb doesn't need them:
Simple usage of GDB, to debug coredump files:
Coredump file for a "process" gets created, as "core.pid" file. After you get inside the gdb-prompt, (on execution of the above command), type;
This will get you with the information, of the stack, where you can analayze the cause of crash/fault. Other command, for same purposes is;
This is same as above. By convention, it lists the whole stack info (which ultimately leads to the crash location).