I am working on assembly profiler for MIPS using EmulateInstruction.
I have set the ContextType to eContextPopRegisterOffStack in the function which emulates “ld ra,40(sp)”
(i.e. load/restore ra from stack) instruction.
0xffffffff802009a4 :
0xffffffff802009a4: 67bdffd0 daddiu sp,sp,-48
0xffffffff802009a8: ffbf0028 sd ra,40(sp) -----> store return address
0xffffffff802009ac: ffbe0020 sd s8,32(sp)
0xffffffff802009b0: 03a0f02d move s8,sp
<…end of prologue…>
<…some other instructions…>
<…start of epilogue…>
0xffffffff802009f4: 03c0e82d move sp,s8
0xffffffff802009f8: dfbf0028 ld ra,40(sp) ------> restore return address
0xffffffff802009fc: dfbe0020 ld s8,32(sp)
0xffffffff80200a00: 67bd0030 daddiu sp,sp,48
0xffffffff80200a04: 03e00008 jr ra
0xffffffff80200a08: 00000000 nop
With this setting, the unwinder fails when we try to unwind from 0xffffffff802009fc.
The call sequence is main()->foo()->bar() however, backtrace displays only current frame.