GDB | Core file analysis

All that is required to use the GNU Debugger (gdb) is the core file and the binary/executable file (with debugging symbols included) that actually caused the core. If the same version is not available, the closest one can be used.

Run the gdb using the following command:
$ gdb <binary_file_path> <core_file_path>
On the gdb prompt, use the following commands for further debugging:
$ bt                    
(short for backtrace, to get a stack trace and each frame's number from the time of the crash)

$ where
(an alternative to backtrace)

$ frame <stack_frame_number>
(replace number with the corresponding number in the stack trace to select a particular stack frame)

$ list
(to see code around that function)

$ info locals 
(to see the local variables)

$ print <name_of_variable> 
(replacing "name_of_variable" with a variable name, to see its value)

$ help
(to see additional commands)

No comments:

Post a Comment