Skip to content

Commit

Permalink
backtrace.c: Add function which reads and returns the current PSP.
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Reichl <[email protected]>
  • Loading branch information
Timo Reichl committed Jan 2, 2017
1 parent 675de15 commit 18233a0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backtrace/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ static int unwind_execute_instruction(unwind_control_block_t *ucb)
return instruction != -1;
}

static inline __attribute__((always_inline)) unsigned int *readPSP(void)
{
/* Read the current PSP and return its value as a pointer */
unsigned int psp;

__asm volatile (
" mrs %0, psp \n"
: "=r" (psp) : :
);

return (unsigned int*)psp;
}

/* TODO How do I range check the stack pointer */
static int unwind_frame(backtrace_frame_t *frame)
{
Expand Down

0 comments on commit 18233a0

Please sign in to comment.