1#! /bin/sh
2# Variant of run-get-files that uses dwarf_next_lines.
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
21testfiles testfile testfile2
22
23testrun_compare ${abs_builddir}/next-files testfile testfile2 <<\EOF
24off = 0
25 dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
26 file[0] = "???"
27 file[1] = "/home/drepper/gnu/new-bu/build/ttt/m.c"
28off = 75
29 dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
30 file[0] = "???"
31 file[1] = "/home/drepper/gnu/new-bu/build/ttt/b.c"
32 file[2] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h"
33 file[3] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h"
34 file[4] = "/usr/include/bits/types.h"
35 file[5] = "/usr/include/bits/sched.h"
36 file[6] = "/usr/include/bits/pthreadtypes.h"
37 file[7] = "/usr/include/stdio.h"
38 file[8] = "/usr/include/libio.h"
39 file[9] = "/usr/include/wchar.h"
40 file[10] = "/usr/include/_G_config.h"
41 file[11] = "/usr/include/gconv.h"
42off = 480
43 dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
44 file[0] = "???"
45 file[1] = "/home/drepper/gnu/new-bu/build/ttt/f.c"
46off = 0
47 dirs[0] = "/shoggoth/drepper"
48 file[0] = "???"
49 file[1] = "/shoggoth/drepper/b.c"
50 file[2] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stddef.h"
51 file[3] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stdarg.h"
52 file[4] = "/shoggoth/drepper/<built-in>"
53 file[5] = "/usr/include/bits/types.h"
54 file[6] = "/usr/include/stdio.h"
55 file[7] = "/usr/include/libio.h"
56 file[8] = "/usr/include/_G_config.h"
57off = 418
58 dirs[0] = "/shoggoth/drepper"
59 file[0] = "???"
60 file[1] = "/shoggoth/drepper/f.c"
61off = 485
62 dirs[0] = "/shoggoth/drepper"
63 file[0] = "???"
64 file[1] = "/shoggoth/drepper/m.c"
65EOF
66
67# see tests/testfile-dwarf-45.source
68testfiles testfile-splitdwarf-4 testfile-hello4.dwo testfile-world4.dwo
69testfiles testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo
70
71testrun_compare ${abs_builddir}/next-files testfile-splitdwarf-4 testfile-hello4.dwo testfile-world4.dwo <<\EOF
72off = 0
73 dirs[0] = "/home/mark/src/elfutils/tests"
74 dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
75 file[0] = "???"
76 file[1] = "/home/mark/src/elfutils/tests/hello.c"
77 file[2] = "/home/mark/src/elfutils/tests/hello.h"
78 file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
79off = 612
80 dirs[0] = "/home/mark/src/elfutils/tests"
81 dirs[1] = "/usr/include"
82 file[0] = "???"
83 file[1] = "/home/mark/src/elfutils/tests/world.c"
84 file[2] = "/home/mark/src/elfutils/tests/hello.h"
85 file[3] = "/usr/include/stdlib.h"
86off = 0
87 dirs[0] = "/home/mark/src/elfutils/tests"
88 dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
89 file[0] = "???"
90 file[1] = "/home/mark/src/elfutils/tests/hello.c"
91 file[2] = "/home/mark/src/elfutils/tests/hello.h"
92 file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
93off = 0
94 dirs[0] = "/home/mark/src/elfutils/tests"
95 dirs[1] = "/usr/include"
96 file[0] = "???"
97 file[1] = "/home/mark/src/elfutils/tests/world.c"
98 file[2] = "/home/mark/src/elfutils/tests/hello.h"
99 file[3] = "/usr/include/stdlib.h"
100EOF
101
102# No problem with dirs[0] for DWARF5 line tables.
103testrun_compare ${abs_builddir}/next-files testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo <<\EOF
104off = 0
105 dirs[0] = "/home/mark/src/elfutils/tests"
106 dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
107 file[0] = "/home/mark/src/elfutils/tests/hello.c"
108 file[1] = "/home/mark/src/elfutils/tests/hello.c"
109 file[2] = "/home/mark/src/elfutils/tests/hello.h"
110 file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
111off = 655
112 dirs[0] = "/home/mark/src/elfutils/tests"
113 dirs[1] = "/usr/include"
114 file[0] = "/home/mark/src/elfutils/tests/world.c"
115 file[1] = "/home/mark/src/elfutils/tests/world.c"
116 file[2] = "/home/mark/src/elfutils/tests/hello.h"
117 file[3] = "/usr/include/stdlib.h"
118off = 0
119 dirs[0] = "/home/mark/src/elfutils/tests"
120 dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
121 file[0] = "/home/mark/src/elfutils/tests/hello.c"
122 file[1] = "/home/mark/src/elfutils/tests/hello.c"
123 file[2] = "/home/mark/src/elfutils/tests/hello.h"
124 file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
125off = 0
126 dirs[0] = "/home/mark/src/elfutils/tests"
127 dirs[1] = "/usr/include"
128 file[0] = "/home/mark/src/elfutils/tests/world.c"
129 file[1] = "/home/mark/src/elfutils/tests/world.c"
130 file[2] = "/home/mark/src/elfutils/tests/hello.h"
131 file[3] = "/usr/include/stdlib.h"
132EOF
133
134# Created from testfile using
135# cp testfile testfile-only-debug-line
136# eu-strip -g --keep-section .debug_line
137#
138# Note how the comp dir cannot be retrieved and some files become relative.
139testfiles testfile-only-debug-line
140testrun_compare ${abs_builddir}/next-files testfile-only-debug-line <<\EOF
141off = 0
142 dirs[0] = (null)
143 file[0] = "???"
144 file[1] = "m.c"
145off = 75
146 dirs[0] = (null)
147 file[0] = "???"
148 file[1] = "b.c"
149 file[2] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h"
150 file[3] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h"
151 file[4] = "/usr/include/bits/types.h"
152 file[5] = "/usr/include/bits/sched.h"
153 file[6] = "/usr/include/bits/pthreadtypes.h"
154 file[7] = "/usr/include/stdio.h"
155 file[8] = "/usr/include/libio.h"
156 file[9] = "/usr/include/wchar.h"
157 file[10] = "/usr/include/_G_config.h"
158 file[11] = "/usr/include/gconv.h"
159off = 480
160 dirs[0] = (null)
161 file[0] = "???"
162 file[1] = "f.c"
163EOF
164
165exit 0
166