From: "Potharla, Rupesh" <Rupesh.Potharla@amd.com>
To: "Potharla, Rupesh via Binutils" <binutils@sourceware.org>
Cc: "Parasuraman, Hariharan" <Hariharan.Parasuraman@amd.com>,
"George, Jini Susan" <JiniSusan.George@amd.com>,
"Kumar N, Bhuvanendra" <Bhuvanendra.KumarN@amd.com>
Subject: [PATCH] Binutils: Adding new testcase for addr2line.
Date: Fri, 14 Oct 2022 13:29:40 +0000 [thread overview]
Message-ID: <DM6PR12MB4219611F6CC2A0702884A602E7249@DM6PR12MB4219.namprd12.prod.outlook.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 3588 bytes --]
[Public]
* binutils/testsuite/config/default.exp: Set ADDR2LINE and ADDR2LINEFLAGS.
* binutils/testsuite/binutils-all/addr2line.exp: New file.
---
binutils/testsuite/binutils-all/addr2line.exp | 61 +++++++++++++++++++
binutils/testsuite/config/default.exp | 6 ++
2 files changed, 67 insertions(+)
create mode 100644 binutils/testsuite/binutils-all/addr2line.exp
diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/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-1301, USA.
+
+global $NM
+global $ADDR2LINE
+
+set testname "addr2line"
+if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
+ 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/config/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]
}
--
2.25.1
[-- Attachment #2: 0001-Binutils-Adding-new-testcase-for-addr2line.patch --]
[-- Type: application/octet-stream, Size: 3708 bytes --]
From 2c48e181f8ac4efc63072ccd56e319aebaf7a818 Mon Sep 17 00:00:00 2001
From: rupesh potharla <rupesh.potharla@amd.com>
Date: Fri, 14 Oct 2022 18:47:49 +0530
Subject: [PATCH] Binutils: Adding new testcase for addr2line.
* binutils/testsuite/config/default.exp: Set ADDR2LINE and ADDR2LINEFLAGS.
* binutils/testsuite/binutils-all/addr2line.exp: New file.
---
binutils/testsuite/binutils-all/addr2line.exp | 61 +++++++++++++++++++
binutils/testsuite/config/default.exp | 6 ++
2 files changed, 67 insertions(+)
create mode 100644 binutils/testsuite/binutils-all/addr2line.exp
diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/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-1301, USA.
+
+global $NM
+global $ADDR2LINE
+
+set testname "addr2line"
+if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
+ 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/config/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]
}
--
2.25.1
next reply other threads:[~2022-10-14 13:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 13:29 Potharla, Rupesh [this message]
2022-10-17 13:20 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM6PR12MB4219611F6CC2A0702884A602E7249@DM6PR12MB4219.namprd12.prod.outlook.com \
--to=rupesh.potharla@amd.com \
--cc=Bhuvanendra.KumarN@amd.com \
--cc=Hariharan.Parasuraman@amd.com \
--cc=JiniSusan.George@amd.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).