2 * linux/arch/arm/lib/backtrace.S
4 * Copyright (C) 1995, 1996 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * 27/03/03 Ian Molton Clean up CONFIG_CPU
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
17 @ fp is 0 or stack frame
31 #if !defined(CONFIG_FRAME_POINTER) || !defined(CONFIG_PRINTK)
35 stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location...
36 tst r1, #0x10 @ 26 or 32-bit?
37 moveq mask, #0xfc000003
43 ldmeqfd sp!, {r4 - r8, pc}
45 2: stmfd sp!, {pc} @ calculate offset of PC in STMIA instruction
50 3: tst frame, mask @ Check for address exceptions...
53 1001: ldr next, [frame, #-12] @ get fp
54 1002: ldr r2, [frame, #-4] @ get lr
55 1003: ldr r3, [frame, #0] @ get pc
56 sub save, r3, offset @ Correct PC for prefetching
58 1004: ldr r1, [save, #0] @ get instruction at function
65 bl dump_backtrace_entry
67 ldr r0, [frame, #-8] @ get sp
69 1005: ldr r1, [save, #4] @ get instruction at function+4
72 teq r3, r2 @ Check for stmia sp!, {args}
73 addeq save, save, #4 @ next instruction
77 1006: ldr r1, [save, #4] @ Get 'stmia sp!, {rlist, fp, ip, lr, pc}' instruction
84 * A zero next framepointer means we're done.
87 ldmeqfd sp!, {r4 - r8, pc}
90 * The next framepointer must be above the
91 * current framepointer.
99 * Fixup for LDMDB. Note that this must not be in the fixup section.
104 ldmfd sp!, {r4 - r8, pc}
107 .section __ex_table,"a"
121 .Ldumpstm: stmfd sp!, {instr, reg, stack, r7, r8, lr}
127 tst instr, r3, lsl reg
144 ldmfd sp!, {instr, reg, stack, r7, r8, pc}
146 .Lfp: .asciz " r%d = %08X%c"
148 .Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n"
150 .Ldsi: .word 0x00e92dd8 >> 2
151 .word 0x00e92d00 >> 2