1#!/usr/local/bin/bash
2# Test for dwarf_getcfi.
3# Copyright (C) 2018 Red Hat, Inc.
4# This file is part of elfutils.
5#
6# This file is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# elfutils is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19. $srcdir/test-subr.sh
20
21# Test files come from run-addrcfi with all sections stripped except
22# the .debug_frame.
23# for i in <testfiles>
24#   eu-strip -f $i-debugframe $i
25#   eu-strip -g --remove-comment --keep-section=.debug_frame $i-debugframe
26# done
27testfiles testfile11-debugframe testfile12-debugframe
28testfiles testfileaarch64-debugframe
29testfiles testfilearm-debugframe
30testfiles testfileppc32-debugframe
31testfiles testfileppc64-debugframe
32
33testfiles testfile11-debugframe
34testrun_compare ${abs_builddir}/dwarfcfi testfile11-debugframe 0x080489b8 <<\EOF
350x80489b8 => [0x80489b8, 0x80489b9):
36	return address in reg8
37	CFA location expression: bregx(4,4)
38	reg0: undefined
39	reg1: undefined
40	reg2: undefined
41	reg3: same_value
42	reg4: location expression: call_frame_cfa stack_value
43	reg5: same_value
44	reg6: same_value
45	reg7: same_value
46	reg8: location expression: call_frame_cfa plus_uconst(-4)
47	reg9: undefined
48EOF
49
50testfiles testfile12-debugframe
51testrun_compare ${abs_builddir}/dwarfcfi testfile12-debugframe 0x00000000000009d0 <<\EOF
520x9d0 => [0x9d0, 0x9d1):
53	return address in reg16
54	CFA location expression: bregx(7,8)
55	reg0: same_value
56	reg1: undefined
57	reg2: undefined
58	reg3: undefined
59	reg4: undefined
60	reg5: undefined
61	reg6: same_value
62	reg7: location expression: call_frame_cfa stack_value
63	reg8: undefined
64	reg9: undefined
65EOF
66
67testfiles testfileppc32-debugframe
68testrun_compare ${abs_builddir}/dwarfcfi testfileppc32-debugframe 0x100004c0 <<\EOF
690x100004c0 => [0x100004c0, 0x100004d0):
70	return address in reg65
71	CFA location expression: bregx(1)
72	reg0: undefined
73	reg1: location expression: call_frame_cfa stack_value
74	reg2: same_value
75	reg3: undefined
76	reg4: undefined
77	reg5: undefined
78	reg6: undefined
79	reg7: undefined
80	reg8: undefined
81	reg9: undefined
82EOF
83
84testfiles testfileppc64-debugframe
85testrun_compare ${abs_builddir}/dwarfcfi testfileppc64-debugframe 0x00000000100005b0 <<\EOF
860x100005b0 => [0x100005b0, 0x100005d0):
87	return address in reg65
88	CFA location expression: bregx(1)
89	reg0: undefined
90	reg1: location expression: call_frame_cfa stack_value
91	reg2: same_value
92	reg3: undefined
93	reg4: undefined
94	reg5: undefined
95	reg6: undefined
96	reg7: undefined
97	reg8: undefined
98	reg9: undefined
99EOF
100
101testfiles testfilearm-debugframe
102testrun_compare ${abs_builddir}/dwarfcfi testfilearm-debugframe 0x00008510 <<\EOF
1030x8510 => [0x8510, 0x8524):
104	return address in reg14
105	CFA location expression: bregx(13)
106	reg0: undefined
107	reg1: undefined
108	reg2: undefined
109	reg3: undefined
110	reg4: same_value
111	reg5: same_value
112	reg6: same_value
113	reg7: same_value
114	reg8: same_value
115	reg9: undefined
116EOF
117
118testfiles testfileaarch64-debugframe
119testrun_compare ${abs_builddir}/dwarfcfi testfileaarch64-debugframe 0x400550 <<\EOF
1200x400550 => [0x400550, 0x400568):
121	return address in reg30
122	CFA location expression: bregx(31)
123	reg0: undefined
124	reg1: undefined
125	reg2: undefined
126	reg3: undefined
127	reg4: undefined
128	reg5: undefined
129	reg6: undefined
130	reg7: undefined
131	reg8: undefined
132	reg9: undefined
133EOF
134