4

I am testing a new driver on FreeBSD kernel.

This might be trivial for experienced developers, but I can't figure out the solution to this problem.

I have a kernel panic and when it panics, I get the backtrace of the panic.

The backtrace says that the panic occurred at say foo_bar() + 0x94. How can I extract the line no corresponding to foo_bar() + 0x94?

The kernel is built with debugging symbols. I have tried grepping nm kernel but it only contains debugging symbols.

What can I do to find the exact line no?

CL.
  • 173,858
  • 17
  • 217
  • 259
Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97
  • If you working with FreeBSD, please remove tag [linux-kernel] – myaut Apr 20 '15 at 06:54
  • I added that tag, because more people follow linux kernel than freebsd kernel. The basic technique remains the same ,so If a person answers for linux kernel that can also be applied to freebsd kernel with slight modifications. Anyway, I was able to resolve my issue. – Pratik Singhal Apr 20 '15 at 08:28

2 Answers2

2

I suggest to read the FreeBSD Handbook on Kernel debugging

https://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug.html

It has detailed explanation of how to create a core file and how to invoke the gdb.

arved
  • 4,401
  • 4
  • 30
  • 53
2

Configure crashdumps - it's usually just adding 'dumpdev="AUTO"' to /etc/rc.conf and rebooting - and, after crash and subsequent reboot, analyze the dump with debugger, like this: "kgdb /boot/kernel/kernel /var/crash/vmcore.latest". The "kgdb" thing is basically GDB hacked up to support kernel debugging; the "where" command should show you the backtrace.