]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - binutils/testsuite/binutils-all/addr2line.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / addr2line.exp
1 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17 set testname "addr2line"
18 set opts ""
19 set dot ""
20 set exe [exeext]
21
22 # powerpc64 function symbols are on descriptors rather than code.
23 # MUSL uses the ELFv2 ABI for PowerPC, so the problem does not apply there.
24 if { [istarget powerpc64-*-*] && ![istarget powerpc64-*-musl] } {
25 set opts --synthetic
26 set dot {\.}
27 }
28
29 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
30 verbose "Unable to compile test file."
31 untested "$testname"
32 return
33 }
34
35 #testcase for default option.
36 #Run nm command and input the main symbol address to addr2line.
37 set output [binutils_run $NM "$opts tmpdir/testprog$exe"]
38 if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then {
39 fail "$testname"
40 } else {
41 set list [regexp -inline -all -- {\S+} $contents]
42 set got [binutils_run $ADDR2LINE "-e tmpdir/testprog$exe [lindex $list 0]"]
43 set want "$srcdir/$subdir/testprog.c:\[0-9\]+"
44 if ![regexp $want $got] then {
45 fail "$testname $got\n"
46 } else {
47 pass "$testname"
48 }
49 }
50
51 #testcase for -f option.
52 #Run nm command and input the fn function symbol address to addr2line.
53 if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
54 fail "$testname -f option"
55 } else {
56 set list [regexp -inline -all -- {\S+} $contents]
57 set got [binutils_run $ADDR2LINE "-f -e tmpdir/testprog$exe [lindex $list 0]"]
58 set want "fn\n$srcdir/$subdir/testprog.c:\[0-9\]+"
59 if ![regexp $want $got] then {
60 fail "$testname -f option $got\n"
61 } else {
62 pass "$testname -f option"
63 }
64
65 #testcase for -s option.
66 #Using the same fn function address used in -f option.
67 set got [binutils_run $ADDR2LINE "-s -e tmpdir/testprog$exe [lindex $list 0]"]
68 set want "testprog.c:\[0-9\]+"
69 if ![regexp $want $got] then {
70 fail "$testname -s option $got\n"
71 } else {
72 pass "$testname -s option"
73 }
74 }