how to get current PC register value on MIPS arch?

backtrace, mips, program-counter

Solution

Make a subroutine that looks somewhat like:

.text 
.globl GetIP 

GetIP:
move $v0, $ra
jr $ra

And then call the routine; it'll give you the address of the first instruction after the call.

Problem

I'd like to do backtrace on MIPS. Then, I face one problem: how do I get the current PC register value, since it doesn't belong to 32 normal registers.. Thanks for your suggestion..

Original source