mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 09:50:04 +00:00
5933f6d220
Update license to use SPDX-License-Identifier instead of verbose license text. Link: http://lkml.kernel.org/r/8736rccswn.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Cc: Rich Felker <dalias@libc.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
56 lines
901 B
C
56 lines
901 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* arch/sh/kernel/return_address.c
|
|
*
|
|
* Copyright (C) 2009 Matt Fleming
|
|
* Copyright (C) 2009 Paul Mundt
|
|
*/
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <asm/dwarf.h>
|
|
|
|
#ifdef CONFIG_DWARF_UNWINDER
|
|
|
|
void *return_address(unsigned int depth)
|
|
{
|
|
struct dwarf_frame *frame;
|
|
unsigned long ra;
|
|
int i;
|
|
|
|
for (i = 0, frame = NULL, ra = 0; i <= depth; i++) {
|
|
struct dwarf_frame *tmp;
|
|
|
|
tmp = dwarf_unwind_stack(ra, frame);
|
|
if (!tmp)
|
|
return NULL;
|
|
|
|
if (frame)
|
|
dwarf_free_frame(frame);
|
|
|
|
frame = tmp;
|
|
|
|
if (!frame || !frame->return_addr)
|
|
break;
|
|
|
|
ra = frame->return_addr;
|
|
}
|
|
|
|
/* Failed to unwind the stack to the specified depth. */
|
|
WARN_ON(i != depth + 1);
|
|
|
|
if (frame)
|
|
dwarf_free_frame(frame);
|
|
|
|
return (void *)ra;
|
|
}
|
|
|
|
#else
|
|
|
|
void *return_address(unsigned int depth)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
#endif
|
|
|
|
EXPORT_SYMBOL_GPL(return_address);
|