From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2114) id D4323385800A; Wed, 19 Oct 2022 07:05:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4323385800A Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alok Kumar Sharma To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Binutils: Adding new testcase for addr2line. X-Act-Checkin: binutils-gdb X-Git-Author: rupesh potharla X-Git-Refname: refs/heads/master X-Git-Oldrev: a16c96980d9593a14237725af695f52e9f211bc9 X-Git-Newrev: 740a19d914a83423122fe81eec9508fa1dbb0559 Message-Id: <20221019070535.D4323385800A@sourceware.org> Date: Wed, 19 Oct 2022 07:05:35 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2022 07:05:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D740a19d914a8= 3423122fe81eec9508fa1dbb0559 commit 740a19d914a83423122fe81eec9508fa1dbb0559 Author: rupesh potharla Date: Fri Oct 14 18:47:49 2022 +0530 Binutils: Adding new testcase for addr2line. =20 * binutils/testsuite/config/default.exp: Set ADDR2LINE and ADDR2LINEFLA= GS. * binutils/testsuite/binutils-all/addr2line.exp: New file. Diff: --- binutils/testsuite/binutils-all/addr2line.exp | 61 +++++++++++++++++++++++= ++++ binutils/testsuite/config/default.exp | 6 +++ 2 files changed, 67 insertions(+) diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/tests= uite/binutils-all/addr2line.exp new file mode 100644 index 00000000000..15e60366ac2 --- /dev/null +++ b/binutils/testsuite/binutils-all/addr2line.exp @@ -0,0 +1,61 @@ +# Copyright (C) 2018-2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-130= 1, USA. + +global $NM +global $ADDR2LINE + +set testname "addr2line" +if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable= debug] !=3D "" } { + verbose "Unable to compile test file." + untested "addr2line" + return +} + +#testcase for default option. +#Run nm command and input the main symbol address to addr2line. +set output [binutils_run $NM "tmpdir/testprog"] +regexp -line {^([0-9a-fA-F]+)?[ ]+T main} $output contents +set list [regexp -inline -all -- {\S+} $contents] +set got [binutils_run $ADDR2LINE "-e tmpdir/testprog [lindex $list 0]"] +set want "$srcdir/$subdir/testprog.c:\[0-9\]+" +if ![regexp $want $got] then { + fail "$testname $got\n" +} else { + pass "$testname" +} + +#testcase for -f option. +#Run nm command and input the fn function symbol address to addr2line. +regexp -line {^([0-9a-fA-F]+)?[ ]+T fn} $output contents +pass "output is $output \n contents is $contents\n" +set list [regexp -inline -all -- {\S+} $contents] +set got [binutils_run $ADDR2LINE "-f -e tmpdir/testprog [lindex $list 0]"] +set want "fn\n$srcdir/$subdir/testprog.c:\[0-9\]+" +if ![regexp $want $got] then { + fail "$testname -f option $got\n" +} else { + pass "$testname -f option" +} + +#testcase for -s option. +#Using the same fn function address used in -f option. +set got [binutils_run $ADDR2LINE "-s -e tmpdir/testprog [lindex $list 0]"] +set want "testprog.c:\[0-9\]+" +if ![regexp $want $got] then { + fail "$testname -s option $got\n" +} else { + pass "$testname -s option" +} diff --git a/binutils/testsuite/config/default.exp b/binutils/testsuite/con= fig/default.exp index 68f5bcb1102..64edebe985f 100644 --- a/binutils/testsuite/config/default.exp +++ b/binutils/testsuite/config/default.exp @@ -40,6 +40,12 @@ if ![info exists NM] then { if ![info exists NMFLAGS] then { set NMFLAGS "" } +if ![info exists ADDR2LINE] then { + set ADDR2LINE [findfile $base_dir/addr2line] +} +if ![info exists ADDR2LINEFLAGS] then { + set ADDR2LINEFLAGS "" +} if ![info exists SIZE] then { set SIZE [findfile $base_dir/size] }