xref: /aosp_15_r20/external/elfutils/tests/run-readelf-multi-noline.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1#! /bin/sh
2# Copyright (C) 2021 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20# = a.c =
21# int a;
22
23# = b.c =
24# int b;
25
26# = m.c =
27# int main () { }
28
29# gcc -g -o testfile_multi_noline a.c b.c m.c
30
31testfiles testfile_multi_noline
32
33testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=line testfile_multi_noline <<\EOF
34
35DWARF section [29] '.debug_line' at offset 0x1221:
36
37Table at offset 0:
38
39 Length:                         32
40 DWARF version:                  3
41 Prologue length:                26
42 Address size:                   8
43 Segment selector size:          0
44 Min instruction length:         4
45 Max operations per instruction: 1
46 Initial value if 'is_stmt':     1
47 Line base:                      -5
48 Line range:                     14
49 Opcode base:                    13
50
51Opcodes:
52  [ 1]  0 arguments
53  [ 2]  1 argument
54  [ 3]  1 argument
55  [ 4]  1 argument
56  [ 5]  1 argument
57  [ 6]  0 arguments
58  [ 7]  0 arguments
59  [ 8]  0 arguments
60  [ 9]  1 argument
61  [10]  0 arguments
62  [11]  0 arguments
63  [12]  1 argument
64
65Directory table:
66
67File name table:
68 Entry Dir   Time      Size      Name
69 1     0     0         0         a.c
70
71No line number statements.
72
73Table at offset 36:
74
75 Length:                         32
76 DWARF version:                  3
77 Prologue length:                26
78 Address size:                   8
79 Segment selector size:          0
80 Min instruction length:         4
81 Max operations per instruction: 1
82 Initial value if 'is_stmt':     1
83 Line base:                      -5
84 Line range:                     14
85 Opcode base:                    13
86
87Opcodes:
88  [ 1]  0 arguments
89  [ 2]  1 argument
90  [ 3]  1 argument
91  [ 4]  1 argument
92  [ 5]  1 argument
93  [ 6]  0 arguments
94  [ 7]  0 arguments
95  [ 8]  0 arguments
96  [ 9]  1 argument
97  [10]  0 arguments
98  [11]  0 arguments
99  [12]  1 argument
100
101Directory table:
102
103File name table:
104 Entry Dir   Time      Size      Name
105 1     0     0         0         b.c
106
107No line number statements.
108
109Table at offset 72:
110
111 Length:                         54
112 DWARF version:                  3
113 Prologue length:                26
114 Address size:                   8
115 Segment selector size:          0
116 Min instruction length:         4
117 Max operations per instruction: 1
118 Initial value if 'is_stmt':     1
119 Line base:                      -5
120 Line range:                     14
121 Opcode base:                    13
122
123Opcodes:
124  [ 1]  0 arguments
125  [ 2]  1 argument
126  [ 3]  1 argument
127  [ 4]  1 argument
128  [ 5]  1 argument
129  [ 6]  0 arguments
130  [ 7]  0 arguments
131  [ 8]  0 arguments
132  [ 9]  1 argument
133  [10]  0 arguments
134  [11]  0 arguments
135  [12]  1 argument
136
137Directory table:
138
139File name table:
140 Entry Dir   Time      Size      Name
141 1     0     0         0         m.c
142
143Line number statements:
144 [    6c] set column to 13
145 [    6e] extended opcode 2:  set address to +0x724 <main>
146 [    79] copy
147 [    7a] set column to 15
148 [    7c] special opcode 32: address+4 = +0x728 <main+0x4>, line+0 = 1
149 [    7d] advance address by 4 to +0x72c
150 [    7f] extended opcode 1:  end of sequence
151EOF
152
153testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedline testfile_multi_noline <<\EOF
154
155DWARF section [29] '.debug_line' at offset 0x1221:
156
157 CU [b] a.c
158  line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
159 CU [44] b.c
160  line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
161 CU [7d] m.c
162  line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
163  /tmp/m.c (mtime: 0, length: 0)
164     1:13  S        0   0  0 +0x0000000000000724 <main>
165     1:15  S        0   0  0 +0x0000000000000728 <main+0x4>
166     1:15  S   *    0   0  0 +0x000000000000072b <main+0x7>
167
168EOF
169
170exit 0
171