1

In c or c++ While debugging a core dump,i.e., if we are left with a coredump file and try to debug using that core file is there a way we can see the last few lines of code before the dump occured.the stack trace only shows the function call.

for eg:during debugging a running process in dbx or gdb list command

list Display lines of a source file

will give the part of the code currently under execution.in the same way do we have the option while looking into a core dump? i am working on solaris mdb

Vijay
  • 65,327
  • 90
  • 227
  • 319

3 Answers3

2

The list command in gdb should provide details of source code line numbers and the corresponding source listing from a core file if:

  • The executable was compiled with debug symbols enabled (eg. -g in gcc and g++)
  • A non-stripped version of the executable is available (ie. has not had the debug information removed by running strip)
  • The debugger is able to find the relevant source files

The debugger should still be able to provide file and line numbers even if it is unable to find the source files as the line number information forms a part of the debug symbols. This information should be available through the bt (backtrace) command, as well as the info symbol command.

Note that even if the core file was generated from a stripped executable, as long as you have access to a non-stripped version you can load that in gdb as well as specifying the core file.

Take a look at chapter 13 and 15 of the gdb manual to assist in giving gdb access to your source files.

Andrew Edgecombe
  • 39,594
  • 3
  • 35
  • 61
0

If you compiled with -g option you can display source lines. In dbx you can use use command to set dbx source directories.

You can use list (l) command to display source lines.

See help command to learn how to use dbx and gdb commands.

Tio Pepe
  • 3,071
  • 1
  • 17
  • 22
0

If you have set your source path properly using use command in dbx or started it with -I option, then there's hardly any difference between debugging a core dump and a normal process when it comes to reading source lines.

Pavan Manjunath
  • 27,404
  • 12
  • 99
  • 125