summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.S
blob: 268745275f4340a2144fa53a2d6b3ad4bf3adf68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* Copyright 2020-2022 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#include <asm/unistd.h>

/* Define these for each architecture:

   1) RETURN_ADDRESS_REGNO: The register number representing the return
      address in the DWARF CFI.  It can be easily be looked up using
      `readelf --debug-dump=frames-interp` on an existing binary of that
      architecture, where it says `ra=X`.

   2) exit_0: a sequence of instruction to execute the exit syscall with
      argument 0.  */

#if defined(__x86_64__)

# define RETURN_ADDRESS_REGNO 16

.macro exit_0
	mov $__NR_exit, %rax
	mov $0, %rdi
	syscall
.endm

#elif defined(__i386__)

# define RETURN_ADDRESS_REGNO 8

.macro exit_0
	mov $__NR_exit, %eax
	mov $0, %ebx
	int $0x80
.endm

#elif defined(__aarch64__)

# define RETURN_ADDRESS_REGNO 30

.macro exit_0
	mov x0, #0
	mov x8, #__NR_exit
	svc #0
.endm

#elif defined(__arm__)

# define RETURN_ADDRESS_REGNO 14

.macro exit_0
	ldr r7, =__NR_exit
	ldr r0, =0
	swi 0x0
.endm

#elif defined __powerpc64__

# define RETURN_ADDRESS_REGNO 65

.macro exit_0
	li 0, __NR_exit  /* r0 - contains system call number */
	li 3, 0          /* r3 - contains first argument for sys call */
	sc
.endm

#else
# error "Unsupported architecture"
#endif

/* The following assembly program mimics this pseudo C program, where
   everything has been inlined:

    1 void bar(void) {
    2   nop;
    3 }
    4
    5 void foo(void) {
    6   nop;
    7   bar();
    8   nop;
    9 }
   10
   11 void _start(void) {
   12   nop;
   13   foo();
   14   nop;
   15   exit(0);
   16 }
*/

#if defined __powerpc64__
#  if _CALL_ELF == 2
.abiversion 2   /* Tell gdb what ELF version to use. */
.global _start
_start:
#  else
.abiversion 1   /* Tell gdb what ELF version to use. */
.align 2
.global _start
.section ".opd", "aw"
.align 3
_start:
.quad ._start,.TOC.@tocbase,0
.previous
.type ._start,@function
._start:
#  endif
#else
.global _start
_start:
#endif
.cfi_startproc

/* State that the return address for this frame is undefined. */
.cfi_undefined RETURN_ADDRESS_REGNO

.global __cu_low_pc
__cu_low_pc:

.global __start_low_pc
__start_low_pc:
	/* Line 12 */
	nop

.global __foo_low_pc
__foo_low_pc:
	/* Line 6 */
	nop

.global __bar_low_pc
__bar_low_pc:
	/* Line 2 */
	nop

.global __bar_high_pc
__bar_high_pc:
	/* Line 8 */
	nop

.global __foo_high_pc
__foo_high_pc:
	/* Line 14 */
	nop

	/* Line 15 */
	exit_0

.cfi_endproc

.global __start_high_pc
__start_high_pc:

.global __cu_high_pc
__cu_high_pc: