]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - binutils/testsuite/binutils-all/addr2line.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / addr2line.exp
CommitLineData
fd67aa11 1# Copyright (C) 2018-2024 Free Software Foundation, Inc.
740a19d9 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
740a19d9 17set testname "addr2line"
2b06e59d
AM
18set opts ""
19set dot ""
20set exe [exeext]
21
22# powerpc64 function symbols are on descriptors rather than code.
c4e0d285
W
23# MUSL uses the ELFv2 ABI for PowerPC, so the problem does not apply there.
24if { [istarget powerpc64-*-*] && ![istarget powerpc64-*-musl] } {
2b06e59d
AM
25 set opts --synthetic
26 set dot {\.}
27}
28
740a19d9 29if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
30 verbose "Unable to compile test file."
2b06e59d 31 untested "$testname"
740a19d9 32 return
33}
34
35#testcase for default option.
36#Run nm command and input the main symbol address to addr2line.
2b06e59d 37set output [binutils_run $NM "$opts tmpdir/testprog$exe"]
76a2bcc6 38if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then {
2b06e59d 39 fail "$testname"
740a19d9 40} else {
2b06e59d
AM
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 }
740a19d9 49}
50
51#testcase for -f option.
52#Run nm command and input the fn function symbol address to addr2line.
76a2bcc6 53if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
2b06e59d 54 fail "$testname -f option"
740a19d9 55} else {
2b06e59d
AM
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 }
740a19d9 64
65#testcase for -s option.
66#Using the same fn function address used in -f option.
2b06e59d
AM
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 }
740a19d9 74}