Skip to content

Commit

Permalink
fix SP not being updated after instruction 0x80
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Manowiecki authored and sgstreet committed Dec 30, 2023
1 parent a438f64 commit 3f6ceab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions backtrace/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ static int unwind_execute_instruction(unwind_control_block_t *ucb)
vsp = (uint32_t *)ucb->vrs[13];
mask = instruction & 0xfff;

/* Update the vrs sp as usual if r13 (sp) was not in the mask,
* otherwise leave the popped r13 as is. */
if ((mask & (1 << (13 - 4))) == 0)
ucb->vrs[13] = (uint32_t)vsp;

/* Loop through the mask */
reg = 4;
while (mask != 0) {
Expand All @@ -152,6 +147,10 @@ static int unwind_execute_instruction(unwind_control_block_t *ucb)
++reg;
}

/* Update the vrs sp as usual if r13 (sp) was not in the mask,
* otherwise leave the popped r13 as is. */
if ((mask & (1 << (13 - 4))) == 0)
ucb->vrs[13] = (uint32_t)vsp;

} else if ((instruction & 0xf0) == 0x90 && instruction != 0x9d && instruction != 0x9f) {
/* vsp = r[nnnn] */
Expand Down

0 comments on commit 3f6ceab

Please sign in to comment.