1#! /bin/sh 2# Copyright (C) 2013 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# Tests readelf --debug-dump=line and --debug-dump=decodedline 21# See run-readelf-aranges for testfiles. 22 23testfiles testfilefoobarbaz 24 25testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=line testfilefoobarbaz <<EOF 26 27DWARF section [30] '.debug_line' at offset 0x15f6: 28 29Table at offset 0: 30 31 Length: 83 32 DWARF version: 2 33 Prologue length: 43 34 Minimum instruction length: 1 35 Maximum operations per instruction: 1 36 Initial value if 'is_stmt': 1 37 Line base: -5 38 Line range: 14 39 Opcode base: 13 40 41Opcodes: 42 [ 1] 0 arguments 43 [ 2] 1 argument 44 [ 3] 1 argument 45 [ 4] 1 argument 46 [ 5] 1 argument 47 [ 6] 0 arguments 48 [ 7] 0 arguments 49 [ 8] 0 arguments 50 [ 9] 1 argument 51 [10] 0 arguments 52 [11] 0 arguments 53 [12] 1 argument 54 55Directory table: 56 57File name table: 58 Entry Dir Time Size Name 59 1 0 0 0 foo.c 60 2 0 0 0 foobarbaz.h 61 62Line number statements: 63 [ 35] extended opcode 2: set address to 0x80482f0 <main> 64 [ 3c] advance line by constant 15 to 16 65 [ 3e] copy 66 [ 3f] special opcode 159: address+10 = 0x80482fa <main+0xa>, line+1 = 17 67 [ 40] special opcode 117: address+7 = 0x8048301 <main+0x11>, line+1 = 18 68 [ 41] advance line by constant -9 to 9 69 [ 43] special opcode 200: address+13 = 0x804830e <main+0x1e>, line+0 = 9 70 [ 44] special opcode 48: address+2 = 0x8048310 <main+0x20>, line+2 = 11 71 [ 45] special opcode 58: address+3 = 0x8048313 <main+0x23>, line-2 = 9 72 [ 46] special opcode 48: address+2 = 0x8048315 <main+0x25>, line+2 = 11 73 [ 47] special opcode 44: address+2 = 0x8048317 <main+0x27>, line-2 = 9 74 [ 48] advance line by constant 13 to 22 75 [ 4a] special opcode 46: address+2 = 0x8048319 <main+0x29>, line+0 = 22 76 [ 4b] advance line by constant -13 to 9 77 [ 4d] special opcode 60: address+3 = 0x804831c <main+0x2c>, line+0 = 9 78 [ 4e] advance line by constant 12 to 21 79 [ 50] special opcode 60: address+3 = 0x804831f <main+0x2f>, line+0 = 21 80 [ 51] special opcode 61: address+3 = 0x8048322 <main+0x32>, line+1 = 22 81 [ 52] advance address by 2 to 0x8048324 82 [ 54] extended opcode 1: end of sequence 83 84Table at offset 87: 85 86 Length: 72 87 DWARF version: 2 88 Prologue length: 28 89 Minimum instruction length: 1 90 Maximum operations per instruction: 1 91 Initial value if 'is_stmt': 1 92 Line base: -5 93 Line range: 14 94 Opcode base: 13 95 96Opcodes: 97 [ 1] 0 arguments 98 [ 2] 1 argument 99 [ 3] 1 argument 100 [ 4] 1 argument 101 [ 5] 1 argument 102 [ 6] 0 arguments 103 [ 7] 0 arguments 104 [ 8] 0 arguments 105 [ 9] 1 argument 106 [10] 0 arguments 107 [11] 0 arguments 108 [12] 1 argument 109 110Directory table: 111 112File name table: 113 Entry Dir Time Size Name 114 1 0 0 0 bar.c 115 116Line number statements: 117 [ 7d] extended opcode 2: set address to 0x8048330 <nobar> 118 [ 84] advance line by constant 12 to 13 119 [ 86] copy 120 [ 87] special opcode 19: address+0 = 0x8048330 <nobar>, line+1 = 14 121 [ 88] advance address by 11 to 0x804833b 122 [ 8a] extended opcode 1: end of sequence 123 [ 8d] extended opcode 2: set address to 0x8048440 <bar> 124 [ 94] advance line by constant 18 to 19 125 [ 96] copy 126 [ 97] special opcode 19: address+0 = 0x8048440 <bar>, line+1 = 20 127 [ 98] advance line by constant -12 to 8 128 [ 9a] special opcode 200: address+13 = 0x804844d <bar+0xd>, line+0 = 8 129 [ 9b] advance line by constant 14 to 22 130 [ 9d] special opcode 74: address+4 = 0x8048451 <bar+0x11>, line+0 = 22 131 [ 9e] advance address by 1 to 0x8048452 132 [ a0] extended opcode 1: end of sequence 133 134Table at offset 163: 135 136 Length: 106 137 DWARF version: 2 138 Prologue length: 43 139 Minimum instruction length: 1 140 Maximum operations per instruction: 1 141 Initial value if 'is_stmt': 1 142 Line base: -5 143 Line range: 14 144 Opcode base: 13 145 146Opcodes: 147 [ 1] 0 arguments 148 [ 2] 1 argument 149 [ 3] 1 argument 150 [ 4] 1 argument 151 [ 5] 1 argument 152 [ 6] 0 arguments 153 [ 7] 0 arguments 154 [ 8] 0 arguments 155 [ 9] 1 argument 156 [10] 0 arguments 157 [11] 0 arguments 158 [12] 1 argument 159 160Directory table: 161 162File name table: 163 Entry Dir Time Size Name 164 1 0 0 0 baz.c 165 2 0 0 0 foobarbaz.h 166 167Line number statements: 168 [ d8] extended opcode 2: set address to 0x8048340 <nobaz> 169 [ df] advance line by constant 12 to 13 170 [ e1] copy 171 [ e2] special opcode 19: address+0 = 0x8048340 <nobaz>, line+1 = 14 172 [ e3] advance address by 11 to 0x804834b 173 [ e5] extended opcode 1: end of sequence 174 [ e8] extended opcode 2: set address to 0x8048460 <baz> 175 [ ef] advance line by constant 18 to 19 176 [ f1] copy 177 [ f2] special opcode 74: address+4 = 0x8048464 <baz+0x4>, line+0 = 19 178 [ f3] special opcode 75: address+4 = 0x8048468 <baz+0x8>, line+1 = 20 179 [ f4] extended opcode 4: set discriminator to 1 180 [ f8] special opcode 78: address+4 = 0x804846c <baz+0xc>, line+4 = 24 181 [ f9] special opcode 187: address+12 = 0x8048478 <baz+0x18>, line+1 = 25 182 [ fa] special opcode 87: address+5 = 0x804847d <baz+0x1d>, line-1 = 24 183 [ fb] special opcode 61: address+3 = 0x8048480 <baz+0x20>, line+1 = 25 184 [ fc] special opcode 101: address+6 = 0x8048486 <baz+0x26>, line-1 = 24 185 [ fd] special opcode 61: address+3 = 0x8048489 <baz+0x29>, line+1 = 25 186 [ fe] special opcode 87: address+5 = 0x804848e <baz+0x2e>, line-1 = 24 187 [ ff] advance line by constant -16 to 8 188 [ 101] special opcode 46: address+2 = 0x8048490 <baz+0x30>, line+0 = 8 189 [ 102] advance line by constant 20 to 28 190 [ 104] special opcode 186: address+12 = 0x804849c <baz+0x3c>, line+0 = 28 191 [ 105] advance line by constant -20 to 8 192 [ 107] special opcode 88: address+5 = 0x80484a1 <baz+0x41>, line+0 = 8 193 [ 108] advance line by constant 13 to 21 194 [ 10a] advance address by constant 17 to 0x80484b2 <baz+0x52> 195 [ 10b] special opcode 32: address+1 = 0x80484b3 <baz+0x53>, line+0 = 21 196 [ 10c] advance address by 9 to 0x80484bc 197 [ 10e] extended opcode 1: end of sequence 198EOF 199 200testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedline testfilefoobarbaz <<\EOF 201 202DWARF section [30] '.debug_line' at offset 0x15f6: 203 204 CU [b] foo.c 205 line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End) 206 /home/mark/src/tests/foobarbaz/foo.c (mtime: 0, length: 0) 207 16:0 S 0 0 0 0x080482f0 <main> 208 17:0 S 0 0 0 0x080482fa <main+0xa> 209 18:0 S 0 0 0 0x08048301 <main+0x11> 210 9:0 S 0 0 0 0x0804830e <main+0x1e> 211 11:0 S 0 0 0 0x08048310 <main+0x20> 212 9:0 S 0 0 0 0x08048313 <main+0x23> 213 11:0 S 0 0 0 0x08048315 <main+0x25> 214 9:0 S 0 0 0 0x08048317 <main+0x27> 215 22:0 S 0 0 0 0x08048319 <main+0x29> 216 9:0 S 0 0 0 0x0804831c <main+0x2c> 217 21:0 S 0 0 0 0x0804831f <main+0x2f> 218 22:0 S 0 0 0 0x08048322 <main+0x32> 219 22:0 S * 0 0 0 0x08048323 <main+0x33> 220 221 CU [141] bar.c 222 line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End) 223 /home/mark/src/tests/foobarbaz/bar.c (mtime: 0, length: 0) 224 13:0 S 0 0 0 0x08048330 <nobar> 225 14:0 S 0 0 0 0x08048330 <nobar> 226 14:0 S * 0 0 0 0x0804833a <nobar+0xa> 227 228 19:0 S 0 0 0 0x08048440 <bar> 229 20:0 S 0 0 0 0x08048440 <bar> 230 8:0 S 0 0 0 0x0804844d <bar+0xd> 231 22:0 S 0 0 0 0x08048451 <bar+0x11> 232 22:0 S * 0 0 0 0x08048451 <bar+0x11> 233 234 CU [1dc] baz.c 235 line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End) 236 /home/mark/src/tests/foobarbaz/baz.c (mtime: 0, length: 0) 237 13:0 S 0 0 0 0x08048340 <nobaz> 238 14:0 S 0 0 0 0x08048340 <nobaz> 239 14:0 S * 0 0 0 0x0804834a <nobaz+0xa> 240 241 19:0 S 0 0 0 0x08048460 <baz> 242 19:0 S 0 0 0 0x08048464 <baz+0x4> 243 20:0 S 0 0 0 0x08048468 <baz+0x8> 244 24:0 S 1 0 0 0x0804846c <baz+0xc> 245 25:0 S 0 0 0 0x08048478 <baz+0x18> 246 24:0 S 0 0 0 0x0804847d <baz+0x1d> 247 25:0 S 0 0 0 0x08048480 <baz+0x20> 248 24:0 S 0 0 0 0x08048486 <baz+0x26> 249 25:0 S 0 0 0 0x08048489 <baz+0x29> 250 24:0 S 0 0 0 0x0804848e <baz+0x2e> 251 8:0 S 0 0 0 0x08048490 <baz+0x30> 252 28:0 S 0 0 0 0x0804849c <baz+0x3c> 253 8:0 S 0 0 0 0x080484a1 <baz+0x41> 254 21:0 S 0 0 0 0x080484b3 <baz+0x53> 255 21:0 S * 0 0 0 0x080484bb <baz+0x5b> 256 257EOF 258 259exit 0 260