2011-05-16 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / thumb-prologue.c
CommitLineData
29d73ae4
DJ
1/* Unwinder test program.
2
7b6bb8da 3 Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
29d73ae4
DJ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
29d73ae4 10 (at your option) any later version.
a9762ec7 11
29d73ae4
DJ
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
a9762ec7 16
29d73ae4 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
29d73ae4
DJ
19
20void tpcs_frame (void);
21
22int
23main (void)
24{
25 tpcs_frame ();
26 return 0;
27}
28
29/* Normally Thumb functions use r7 as the frame pointer. However,
fd20f75b
DJ
30 with the GCC option -mtpcs-frame, they may use fp instead. Make
31 sure that the prologue analyzer can handle this. */
29d73ae4
DJ
32
33asm(".text\n"
34 " .align 2\n"
35 " .thumb_func\n"
36 " .code 16\n"
37 "tpcs_frame_1:\n"
38 " sub sp, #16\n"
39 " push {r7}\n"
40 " add r7, sp, #20\n"
41 " str r7, [sp, #8]\n"
42 " mov r7, pc\n"
43 " str r7, [sp, #16]\n"
44 " mov r7, fp\n"
45 " str r7, [sp, #4]\n"
46 " mov r7, lr\n"
47 " str r7, [sp, #12]\n"
48 " add r7, sp, #16\n"
49 " mov fp, r7\n"
50 " mov r7, sl\n"
51 " push {r7}\n"
52
fd20f75b
DJ
53 /* We'll set a breakpoint at this call. We can't hardcode a trap
54 instruction; the right instruction to use varies too much. And
55 we can't use a global label, because GDB will think that's the
56 start of a new function. So, this slightly convoluted
57 technique. */
58 ".Ltpcs:\n"
59 " nop\n"
29d73ae4
DJ
60
61 " pop {r2}\n"
62 " mov sl, r2\n"
63 " pop {r7}\n"
64 " pop {r1, r2}\n"
65 " mov fp, r1\n"
66 " mov sp, r2\n"
67 " bx lr\n"
68
fd20f75b
DJ
69 " .align 2\n"
70 " .type tpcs_offset, %object\n"
71 "tpcs_offset:\n"
72 " .word .Ltpcs - tpcs_frame_1\n"
73
29d73ae4
DJ
74 " .align 2\n"
75 " .thumb_func\n"
76 " .code 16\n"
77 "tpcs_frame:\n"
78 " sub sp, #16\n"
79 " push {r7}\n"
80 " add r7, sp, #20\n"
81 " str r7, [sp, #8]\n"
82 " mov r7, pc\n"
83 " str r7, [sp, #16]\n"
84 " mov r7, fp\n"
85 " str r7, [sp, #4]\n"
86 " mov r7, lr\n"
87 " str r7, [sp, #12]\n"
88 " add r7, sp, #16\n"
89 " mov fp, r7\n"
90 " mov r7, sl\n"
91 " push {r7}\n"
92
fd20f75b 93 /* Clobber saved regs around the call. */
29d73ae4
DJ
94 " mov r7, #0\n"
95 " mov lr, r7\n"
96 " bl tpcs_frame_1\n"
97
98 " pop {r2}\n"
99 " mov sl, r2\n"
100 " pop {r7}\n"
fd20f75b 101 " pop {r1, r2, r3}\n"
29d73ae4
DJ
102 " mov fp, r1\n"
103 " mov sp, r2\n"
fd20f75b 104 " mov lr, r3\n"
29d73ae4
DJ
105 " bx lr\n"
106);
This page took 0.493064 seconds and 4 git commands to generate.