How to lookup which function in the kernel the current pc (program counter) is in.

 This debugging technique is useful if you get a
kernel panic or hang and can get into xmon to check the current pc.  Typing 'r'
or 'S' at the xmon> prompt will give you a register dump.  If the pc is greater
than 0xc0000000 then it is in the kernel, because the kernel lives above that
address.

The first think you need is to build your kernel with debugging on.  To do
this, add the flag '-g' (without the 's) to the CFLAGS line in your
arch/ppc/Makefile.  Then recompile your entire kernel.  This takes up
considerably more space than a normal compile because it builds the object
files with debugging info (line #'s and such).  This will make your vmlinux
file huge!  before you use this kernel to boot with I would suggest making a
copy of it, and stripping the copy.  Stripping removes the debugging
information that you added the -g flag to get, and is acomplished by:
(depending on your setup []) '[powerpc-eabi-]strip vmlinux'.  now you should
have two binaries, a small stripped elf file and a huge object file that has
debugging info in it.  if you're running networked you will now have to convert
the little elf file into a .coff file that you can netboot.  First objcopy it
to a coff then hack-coff it; the commands to do this are in the
arch/ppc/Makefile.

ok, now the fun part:  getting the function names and their addresses out of
the file that has debugging info in it.  There is a binary util to do this for
you called nm (or powerpc-eabi-nm or whatever...)  simply type:
'powerpc-eabi-nm vmlinux | sort > vmlinux.map'  That will write all of the
function names, and their starting addresses to the file vmlinux.map; sorted by
address.

so you have your pc that you got from xmon or something and a file that maps
all of the function addresses to function names, so find the first address that
is lower than your pc, and you have the function you're stuck in/dying
in/happen to be passing through/whatever...

you can also do a call trace from xmon>  the command is 't' it will print a
back trace of the current stack, and you can search these addresses as
described above.

sometimes I pop in and out of xmon> a few times just to see what kinds of
things are happening, if its stuck, you'll end up at the same few pc's every
time...

oh, and read /Documentation/* in the Linux source tree.