DragonMinded / libdragon

Open source library for N64 development.
https://libdragon.dev
The Unlicense
704 stars 102 forks source link

Backtrace broken in case exception is triggered in tail call #559

Open rasky opened 4 months ago

rasky commented 4 months ago
80003570 <xflow>:
80003570:       27bdffe8        addiu   sp,sp,-24
80003574:       ffa50008        sd      a1,8(sp)
80003578:       10800006        beqz    a0,80003594 <xflow+0x24>
8000357c:       ffa50010        sd      a1,16(sp)
80003580:       dfa30008        ld      v1,8(sp)
80003584:       2402ffff        li      v0,-1
80003588:       000217fc        dsll32  v0,v0,0x1f
8000358c:       00621026        xor     v0,v1,v0
80003590:       ffa20010        sd      v0,16(sp)
80003594:       d7a00010        ldc1    $f0,16(sp)
80003598:       24050022        li      a1,34
8000359c:       f7a00000        sdc1    $f0,0(sp)
800035a0:       d7ac0000        ldc1    $f12,0(sp)
800035a4:       d7a00008        ldc1    $f0,8(sp)
800035a8:       27bd0018        addiu   sp,sp,24
800035ac:       08000d50        j       80003540 <with_errno>
800035b0:       462c0302        mul.d   $f12,$f0,$f12                  <--------------
800035b4:       00000000        nop

Backtrace is broken if an exception is triggered in the specified instruction, because the stack frame was already popped but the tracing engine doesn't know it.