2 * arch/sh/kernel/return_address.c
4 * Copyright (C) 2009 Matt Fleming
5 * Copyright (C) 2009 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <asm/dwarf.h>
15 #ifdef CONFIG_DWARF_UNWINDER
17 void *return_address(unsigned int depth
)
19 struct dwarf_frame
*frame
;
23 for (i
= 0, frame
= NULL
, ra
= 0; i
<= depth
; i
++) {
24 struct dwarf_frame
*tmp
;
26 tmp
= dwarf_unwind_stack(ra
, frame
);
31 dwarf_free_frame(frame
);
35 if (!frame
|| !frame
->return_addr
)
38 ra
= frame
->return_addr
;
41 /* Failed to unwind the stack to the specified depth. */
42 WARN_ON(i
!= depth
+ 1);
45 dwarf_free_frame(frame
);
52 void *return_address(unsigned int depth
)
59 EXPORT_SYMBOL_GPL(return_address
);