The walk stopped at a frame whose LR save word didn't look like an
address. That word is only written when a function called from the
frame saves LR there. dtrace_getpcstack() and dtrace_getstackdepth()
never do, so the frame they are called from may have anything in it,
and now and then stackdepth and caller were 0. The same goes for the
caller of an interrupted function that has a frame but calls nothing.
For the frame a function was using when a trap came, the walk takes
the return address from the LR of the trap frame, as the function may
not have saved it yet. It looked at the LR save word of that frame all
the same, and ended there when the word didn't look like an address or
looked like the one of a trap from user mode. It also tested that LR
for trapexit, which is how a frame of the trap code is told. But
powerpc_interrupt() enables interrupts before it has called anything,
when LR still has its own return address, trapexit. An interrupt taken
there made the walk read a trap frame out of the frame of
powerpc_interrupt(): a register of the interrupted process ended up in
stack() as a kernel address, and the walk went on from a stack pointer
that wasn't one.
Use nothing but the back chain of the frame of an interrupted
function. Don't stop at an LR save word that isn't an address: go on
to the next frame and just leave the word out. Make
dtrace_getstackdepth() count the same way.
MFC after: 1 week