public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Test script modifications to use llvm-dwarfdump when compiler is clang
@ 2021-05-16 11:35 E, Nagajyothi
  2021-05-24 12:18 ` E, Nagajyothi
  0 siblings, 1 reply; 5+ messages in thread
From: E, Nagajyothi @ 2021-05-16 11:35 UTC (permalink / raw)
  To: Mark Wielaard, dwz
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar,
	Parasuraman, Hariharan, E, Nagajyothi

[-- Attachment #1: Type: text/plain, Size: 3387 bytes --]

[AMD Official Use Only - Internal Distribution Only]

Hi,

This testsuite patch may be used while running
	 make check CC="clang -gdwarf-5" CXX="clang++ -gdwarf-5"
to avoid test failures due to readelf.

This checks if $CC/$CXX is clang/clang++ and uses llvm-dwarfdump in place of readelf in the test scripts. This is needed as readelf produces errors/warnings with clang-generated DWARF5 sections/forms, causing many test failures. The latest llvm-dwarfdump (27 April, 2021) is to be used, which has a fix in printing headers of DW_UT_partial type.

Thanks,
Nagajyothi

-----Original Message-----
From: Mark Wielaard <mark@klomp.org>
Sent: Thursday, February 18, 2021 8:15 PM
To: E, Nagajyothi <Nagajyothi.E@amd.com>; dwz@sourceware.org
Cc: George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>
Subject: Re: Plan to contribute for supporting split dwarf (-gsplit-dwarf) in dwz

[CAUTION: External Email]

Hi Nagajyothi,

On Wed, 2021-02-17 at 05:53 +0000, E, Nagajyothi via Dwz wrote:
> I am working on adding support for the dwarf5 .debug_str_offsets, 
> .debug_addr sections and the related forms DW_FORM_strx[1234], DW_FORM_addrx[1234].
> Please let me know if anyone has already started work on these.

Thanks, I don't believe anybody is working on this right now.

There is already a bug for .debug_addr/DW_FORM_addrx[1234] support:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceware.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D27375&amp;data=04%7C01%7CNagajyothi.E%40amd.com%7C37c0fb4399464264b01808d8d41bcb9c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637492563147320988%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=7AjB%2BXKo9J5gTlW1CeEhHXZykYKB2vFZ%2BTnBQvW4%2BIA%3D&amp;reserved=0
I think this shouldn't be too hard. Any DIE that references an address cannot be moved to an alt file, so simply mark it with die_no_multifile. We do try to optimize DW_AT_low/high_pc attribute pairs, so double check that doesn't interfere with DW_FORM_addrx[1234] processing.

Also note that there are two new location operations DW_OP_addrx and DW_OP_constx that can reference the .debug_addr section index.

As a followup you could try optimizing things, but then you need to keep track of all the addresses used and see if there are duplicates that could be turned into a (smaller) DW_FORM_addrx[1234] index. But I would keep that separate from the initial implementation.

For .debug_str_offset/DW_FORM_strx[1234] I opened a new bug.
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceware.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D27434&amp;data=04%7C01%7CNagajyothi.E%40amd.com%7C37c0fb4399464264b01808d8d41bcb9c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637492563147330979%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=AqQRLjgKh9h7YHPIr4wDiqP1rRTXz2kG6IZlAT0SaSQ%3D&amp;reserved=0

This is a little trickier than DW_FORM_addrx[1234] since such DIEs using DW_FORM_strx may be moved to a multifile. You also probably want to make them equal to DW_FORM_strp entries pointing (indirectly) to the same string.

You might want to add a note to the the bugs that you are working on them.

Thanks,

Mark

[-- Attachment #2: 0002-testsuite-Use-llvm-dwarfdump-when-compiler-is-clang.patch --]
[-- Type: application/octet-stream, Size: 28733 bytes --]

From 1ef8e9cd745fcddcaa6a6f03cdadcdc76d2b8663 Mon Sep 17 00:00:00 2001
From: Nagajyothi Eggone <Nagajyothi.E@amd.com>
Date: Sun, 16 May 2021 16:09:58 +0530
Subject: [PATCH 2/2] [testsuite] Use llvm-dwarfdump when compiler is clang

This checks if $CC/$CXX is clang/clang++ and uses llvm-dwarfdump in place of
readelf in the test scripts. This is needed as readelf produces errors/warnings
with clang-generated DWARF5 sections/forms, causing many test failures. The
latest llvm-dwarfdump (27 April, 2021) is to be used, which has a fix in
printing headers of DW_UT_partial type.

	Changelog:
        testsuite/scripts/smaller-than.sh: Use llvm-dwarfdump when compiler
                                           is clang.
	testsuite/dwz.tests/cycle.sh: Use llvm-dwarfdump when compiler is clang.
        testsuite/dwz.tests/devel-ignore-locus.sh         : Likewise.
        testsuite/dwz.tests/devel-ignore-size.sh          : Likewise.
        testsuite/dwz.tests/low-mem-die-limit-at-limit.sh : Likewise.
        testsuite/dwz.tests/low-mem-die-limit-one-above.sh: Likewise.
        testsuite/dwz.tests/low-mem-die-limit-one-below.sh: Likewise.
	testsuite/dwz.tests/odr-class-ns.sh		  : Likewise.
        testsuite/dwz.tests/odr-class.sh		  : Likewise.
        testsuite/dwz.tests/odr-def-decl.sh		  : Likewise.
	testsuite/dwz.tests/odr-loc.sh			  : Likewise.
        testsuite/dwz.tests/odr-struct-multifile.sh	  : Likewise.
	testsuite/dwz.tests/odr-struct-ns.sh		  : Likewise.
	testsuite/dwz.tests/odr-struct.sh		  : Likewise.
	testsuite/dwz.tests/odr-union-ns.sh		  : Likewise.
	testsuite/dwz.tests/odr-union.sh		  : Likewise.
	testsuite/dwz.tests/two-files-too-many-dies-2.sh  : Likewise.
---
 testsuite/dwz.tests/cycle.sh                  | 16 ++++++--
 testsuite/dwz.tests/devel-ignore-locus.sh     | 38 +++++++++++++-----
 testsuite/dwz.tests/devel-ignore-size.sh      | 33 +++++++++++----
 .../dwz.tests/low-mem-die-limit-at-limit.sh   | 12 +++++-
 .../dwz.tests/low-mem-die-limit-one-above.sh  | 12 +++++-
 .../dwz.tests/low-mem-die-limit-one-below.sh  | 12 +++++-
 testsuite/dwz.tests/odr-class-ns.sh           | 40 +++++++++++++++----
 testsuite/dwz.tests/odr-class.sh              | 40 +++++++++++++++----
 testsuite/dwz.tests/odr-def-decl.sh           | 16 ++++++--
 testsuite/dwz.tests/odr-loc.sh                | 22 ++++++++--
 testsuite/dwz.tests/odr-struct-multifile.sh   | 36 ++++++++++++++---
 testsuite/dwz.tests/odr-struct-ns.sh          | 40 +++++++++++++++----
 testsuite/dwz.tests/odr-struct.sh             | 40 +++++++++++++++----
 testsuite/dwz.tests/odr-union-ns.sh           | 40 +++++++++++++++----
 testsuite/dwz.tests/odr-union.sh              | 40 +++++++++++++++----
 .../dwz.tests/two-files-too-many-dies-2.sh    | 12 +++++-
 testsuite/scripts/smaller-than.sh             | 20 ++++++++--
 17 files changed, 383 insertions(+), 86 deletions(-)

diff --git a/testsuite/dwz.tests/cycle.sh b/testsuite/dwz.tests/cycle.sh
index 85aa556..d0aadda 100644
--- a/testsuite/dwz.tests/cycle.sh
+++ b/testsuite/dwz.tests/cycle.sh
@@ -1,3 +1,4 @@
+echo $CC > comp 2>/dev/null
 readelf_flags=""
 if readelf -h 2>&1 | grep -q "\-wN,"; then
     readelf_flags=-wN
@@ -23,10 +24,19 @@ rm -f DUMP.1 DUMP.2 LINE.1 LINE.2
 cp 1 2
 $execs/dwz-for-test -m 3 1 2 --devel-no-checksum-cycle-opt --devel-ignore-size
 
-cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*: s$")
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 3 | grep -c "DW_AT_name.*s")
+else
+    cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*: s$")
+fi
+
 [ $cnt -eq 1 ]
 
-cnt=$(readelf -wi $readelf_flags 1 | grep -c "DW_AT_name.*: s$" || true)
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_name.*s" || true)
+else
+    cnt=$(readelf -wi $readelf_flags 1 | grep -c "DW_AT_name.*: s$" || true)
+fi
 [ $cnt -eq 0 ]
 
-rm -f 1 2 3
+rm -f 1 2 3 comp
diff --git a/testsuite/dwz.tests/devel-ignore-locus.sh b/testsuite/dwz.tests/devel-ignore-locus.sh
index caa9d78..16245c9 100644
--- a/testsuite/dwz.tests/devel-ignore-locus.sh
+++ b/testsuite/dwz.tests/devel-ignore-locus.sh
@@ -1,27 +1,45 @@
 cp $execs/two-typedef 1
 
-cnt=$(readelf -wi 1 \
-	    | grep 'DW_AT_name.*: aaa' \
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_AT_name*' | grep 'aaa' \
+	    | wc -l)
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_AT_name.*: aaa'        \
 	    | wc -l)
+fi
 
 [ $cnt -eq 2 ]
 
  $execs/dwz-for-test 1 2>/dev/null
 
-cnt=$(readelf -wi 1 \
-	    | grep 'DW_AT_name.*: aaa' \
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_AT_name*' | grep 'aaa' \
 	    | wc -l)
-
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_AT_name.*: aaa'        \
+	    | wc -l)
+fi
 [ $cnt -eq 2 ]
 
 cp $execs/two-typedef 1
 
- $execs/dwz-for-test --devel-ignore-locus --devel-ignore-size 1
+$execs/dwz-for-test --devel-ignore-locus --devel-ignore-size 1
 
-cnt=$(readelf -wi 1 \
-	    | grep 'DW_AT_name.*: aaa' \
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_AT_name*' | grep 'aaa' \
 	    | wc -l)
-
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_AT_name.*: aaa'        \
+	    | wc -l)
+fi
 [ $cnt -eq 1 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/devel-ignore-size.sh b/testsuite/dwz.tests/devel-ignore-size.sh
index 78d28a2..70c421c 100644
--- a/testsuite/dwz.tests/devel-ignore-size.sh
+++ b/testsuite/dwz.tests/devel-ignore-size.sh
@@ -1,16 +1,29 @@
 cp $execs/min 1
 
-cnt=$(readelf -wi 1 \
-	    | grep '(DW_TAG_partial_unit' \
+echo $CC > comp 2>/dev/null
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG_partial_unit' \
 	    | wc -l)
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_TAG_partial_unit' \
+	    | wc -l)
+fi
 
 [ $cnt -eq 0 ]
 
  $execs/dwz-for-test 1 2>/dev/null
 
-cnt=$(readelf -wi 1 \
-	    | grep '(DW_TAG_partial_unit' \
+if grep -q "clang" comp; then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG_partial_unit' \
+	    | wc -l)
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_TAG_partial_unit' \
 	    | wc -l)
+fi
 
 if [ $cnt -ne 0 ]; then
     exit 77
@@ -20,10 +33,16 @@ cp $execs/min 1
 
  $execs/dwz-for-test --devel-ignore-size 1
 
-cnt=$(readelf -wi 1 \
-	    | grep '(DW_TAG_partial_unit' \
+if grep -q "clang" comp; then
+    cnt=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG_partial_unit' \
+	    | wc -l)
+else
+    cnt=$(readelf -wi 1 \
+	    | grep 'DW_TAG_partial_unit' \
 	    | wc -l)
+fi
 
 [ $cnt -gt 0 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/low-mem-die-limit-at-limit.sh b/testsuite/dwz.tests/low-mem-die-limit-at-limit.sh
index 03ff273..0cfc6b5 100644
--- a/testsuite/dwz.tests/low-mem-die-limit-at-limit.sh
+++ b/testsuite/dwz.tests/low-mem-die-limit-at-limit.sh
@@ -1,8 +1,16 @@
 cp $execs/hello 1
 
-count=$(readelf -wi 1 \
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    count=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG' \
+	    | wc -l)
+else
+    count=$(readelf -wi 1 \
 	    | grep '(DW_TAG' \
 	    | wc -l)
+fi
 limit=$count
 
 $execs/dwz-for-test \
@@ -15,4 +23,4 @@ if grep -q "Compressing 1 in low-mem mode" dwz.err; then
     exit 1
 fi
 
-rm -f 1 dwz.err
+rm -f 1 dwz.err comp
diff --git a/testsuite/dwz.tests/low-mem-die-limit-one-above.sh b/testsuite/dwz.tests/low-mem-die-limit-one-above.sh
index 9b9a6ff..f33353d 100644
--- a/testsuite/dwz.tests/low-mem-die-limit-one-above.sh
+++ b/testsuite/dwz.tests/low-mem-die-limit-one-above.sh
@@ -1,8 +1,16 @@
 cp $execs/hello 1
 
-count=$(readelf -wi 1 \
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    count=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG' \
+	    | wc -l)
+else
+    count=$(readelf -wi 1 \
 	    | grep '(DW_TAG' \
 	    | wc -l)
+fi
 limit=$((count + 1))
 
 $execs/dwz-for-test \
@@ -15,4 +23,4 @@ if grep -q "Compressing 1 in low-mem mode" dwz.err; then
     exit 1
 fi
 
-rm -f 1 dwz.err
+rm -f 1 dwz.err comp
diff --git a/testsuite/dwz.tests/low-mem-die-limit-one-below.sh b/testsuite/dwz.tests/low-mem-die-limit-one-below.sh
index 4136336..f2cb1a4 100644
--- a/testsuite/dwz.tests/low-mem-die-limit-one-below.sh
+++ b/testsuite/dwz.tests/low-mem-die-limit-one-below.sh
@@ -1,8 +1,16 @@
 cp $execs/hello 1
 
-count=$(readelf -wi 1 \
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    count=$(llvm-dwarfdump --debug-info 1 \
+	    | grep 'DW_TAG' \
+	    | wc -l)
+else
+    count=$(readelf -wi 1 \
 	    | grep '(DW_TAG' \
 	    | wc -l)
+fi
 limit=$((count - 1))
 
 $execs/dwz-for-test \
@@ -15,4 +23,4 @@ if ! grep -q "Compressing 1 in low-mem mode" dwz.err; then
     exit 1
 fi
 
-rm -f 1 dwz.err
+rm -f 1 dwz.err comp
diff --git a/testsuite/dwz.tests/odr-class-ns.sh b/testsuite/dwz.tests/odr-class-ns.sh
index 4b890a3..b5ab455 100644
--- a/testsuite/dwz.tests/odr-class-ns.sh
+++ b/testsuite/dwz.tests/odr-class-ns.sh
@@ -6,24 +6,50 @@ cp $execs/odr-class-ns 1
 
 verify-dwarf.sh 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 2 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 2 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 2 ]
 
 $execs/dwz-for-test --odr 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 1 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 1 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 1 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-class.sh b/testsuite/dwz.tests/odr-class.sh
index 872c3ca..103400f 100644
--- a/testsuite/dwz.tests/odr-class.sh
+++ b/testsuite/dwz.tests/odr-class.sh
@@ -6,24 +6,50 @@ cp $execs/odr-class 1
 
 verify-dwarf.sh 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 2 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 2 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 2 ]
 
 $execs/dwz-for-test --odr 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 1 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 1 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep 'DW_AT_name*' | grep -c 'ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 1 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-def-decl.sh b/testsuite/dwz.tests/odr-def-decl.sh
index 8905e52..00658d5 100644
--- a/testsuite/dwz.tests/odr-def-decl.sh
+++ b/testsuite/dwz.tests/odr-def-decl.sh
@@ -6,14 +6,24 @@ cp $execs/def-decl 1
 
 verify-dwarf.sh 1
 
-cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*ao_ref" || true)
+echo $CC > comp 2>/dev/null
+
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_name.*ao_ref" || true)
+else
+    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*ao_ref" || true)
+fi
 [ $cnt -eq 5 ]
 
 $execs/dwz-for-test --odr 1 --devel-ignore-size
 
 verify-dwarf.sh 1
 
-cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*ao_ref" || true)
+if (grep -q "clang" comp); then
+    cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_name.*ao_ref" || true)
+else
+    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*ao_ref" || true)
+fi
 [ $cnt -eq 2 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-loc.sh b/testsuite/dwz.tests/odr-loc.sh
index a8b3318..a05488a 100644
--- a/testsuite/dwz.tests/odr-loc.sh
+++ b/testsuite/dwz.tests/odr-loc.sh
@@ -2,10 +2,16 @@ if ! $execs/dwz-for-test --odr -v 2>/dev/null; then
     exit 77
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-loc 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 2 ]
 done
 
@@ -14,7 +20,11 @@ $execs/dwz-for-test --odr 1 --devel-ignore-size
 verify-dwarf.sh 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+       cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     case $name in
 	aaa)
 	    [ $cnt -eq 2 ]
@@ -32,8 +42,12 @@ $execs/dwz-for-test --odr --devel-ignore-locus 1
 verify-dwarf.sh 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-struct-multifile.sh b/testsuite/dwz.tests/odr-struct-multifile.sh
index 20b682b..68b8156 100644
--- a/testsuite/dwz.tests/odr-struct-multifile.sh
+++ b/testsuite/dwz.tests/odr-struct-multifile.sh
@@ -7,16 +7,26 @@ if readelf -h 2>&1 | grep -q "\-wN,"; then
     readelf_flags=-wN
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-struct 1
 cp 1 2
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 2 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     case $name in
 	member_one|member_two)
 	    [ $cnt -eq 2 ]
@@ -27,7 +37,11 @@ for name in member_one member_two member_three member_four; do
 	esac
 done
 
-decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+if (grep -q "clang" comp); then
+    decl_cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_declaration" || true)
+else
+    decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+fi
 
 $execs/dwz-for-test --odr 1 2 -m 3
 
@@ -35,24 +49,34 @@ verify-dwarf.sh 1
 verify-dwarf.sh 3
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 3 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 3 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 3 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 
 for name in aaa bbb ccc; do
+#   There is no flag equivalent to "-wN" in llvm-dwarfdump, so use readelf
     cnt=$(readelf -wi $readelf_flags 1 | grep -c "DW_AT_name.*:.*$name" || true)
     [ $cnt -eq 0 ]
 done
 
 for name in member_one member_two member_three member_four; do
+#   There is no flag equivalent to "-wN" in llvm-dwarfdump, so use readelf
     cnt=$(readelf -wi $readelf_flags 1 | grep -c "DW_AT_name.*:.*$name" || true)
     [ $cnt -eq 0 ]
 done
 
-rm -f 1 2 3
+rm -f 1 2 3 comp
diff --git a/testsuite/dwz.tests/odr-struct-ns.sh b/testsuite/dwz.tests/odr-struct-ns.sh
index 4fd00af..0de93c4 100644
--- a/testsuite/dwz.tests/odr-struct-ns.sh
+++ b/testsuite/dwz.tests/odr-struct-ns.sh
@@ -2,15 +2,25 @@ if ! $execs/dwz-for-test --odr -v 2>/dev/null; then
     exit 77
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-struct-ns 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 2 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     case $name in
 	member_one|member_two)
 	    [ $cnt -eq 2 ]
@@ -21,25 +31,41 @@ for name in member_one member_two member_three member_four; do
 	esac
 done
 
-decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+if (grep -q "clang" comp); then
+    decl_cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_declaration" || true)
+else
+    decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+fi
 
 $execs/dwz-for-test --odr 1
 
 verify-dwarf.sh 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 # We expect two decls to be removed, for bbb and ccc.
 expected_decl_cnt=$(($decl_cnt - 2))
-decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+if (grep -q "clang" comp); then
+    decl_cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_declaration" || true)
+else
+    decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+fi
 [ $expected_decl_cnt -eq $decl_cnt ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-struct.sh b/testsuite/dwz.tests/odr-struct.sh
index d0fddf9..20e6125 100644
--- a/testsuite/dwz.tests/odr-struct.sh
+++ b/testsuite/dwz.tests/odr-struct.sh
@@ -2,15 +2,25 @@ if ! $execs/dwz-for-test --odr -v 2>/dev/null; then
     exit 77
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-struct 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 2 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     case $name in
 	member_one|member_two)
 	    [ $cnt -eq 2 ]
@@ -21,25 +31,41 @@ for name in member_one member_two member_three member_four; do
 	esac
 done
 
-decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+if (grep -q "clang" comp); then
+    decl_cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_declaration" || true)
+else
+    decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+fi
 
 $execs/dwz-for-test --odr 1
 
 verify-dwarf.sh 1
 
 for name in aaa bbb ccc; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 for name in member_one member_two member_three member_four; do
-    cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    if (grep -q "clang" comp); then
+        cnt=$(llvm-dwarfdump --debug-info 1 | grep "DW_AT_name*" | grep -c "$name" || true)
+    else
+        cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true)
+    fi
     [ $cnt -eq 1 ]
 done
 
 # We expect two decls to be removed, for bbb and ccc.
 expected_decl_cnt=$(($decl_cnt - 2))
-decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+if (grep -q "clang" comp); then
+    decl_cnt=$(llvm-dwarfdump --debug-info 1 | grep -c "DW_AT_declaration" || true)
+else
+    decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true)
+fi
 [ $expected_decl_cnt -eq $decl_cnt ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-union-ns.sh b/testsuite/dwz.tests/odr-union-ns.sh
index 7d86dba..44c0969 100644
--- a/testsuite/dwz.tests/odr-union-ns.sh
+++ b/testsuite/dwz.tests/odr-union-ns.sh
@@ -2,28 +2,54 @@ if ! $execs/dwz-for-test --odr -v 2>/dev/null; then
     exit 77
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-union-ns 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 2 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 2 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 2 ]
 
 $execs/dwz-for-test --odr 1
 
 verify-dwarf.sh 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 1 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 1 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 1 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/odr-union.sh b/testsuite/dwz.tests/odr-union.sh
index a32a46c..f0ed1e7 100644
--- a/testsuite/dwz.tests/odr-union.sh
+++ b/testsuite/dwz.tests/odr-union.sh
@@ -2,28 +2,54 @@ if ! $execs/dwz-for-test --odr -v 2>/dev/null; then
     exit 77
 fi
 
+echo $CC > comp 2>/dev/null
+
 cp $execs/odr-union 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 2 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 2 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 2 ]
 
 $execs/dwz-for-test --odr 1
 
 verify-dwarf.sh 1
 
-aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+if (grep -q "clang" comp); then
+    aaa=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*aaa')
+else
+    aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa')
+fi
 [ $aaa -eq 1 ]
 
-bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+if (grep -q "clang" comp); then
+    bbb=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*bbb')
+else
+    bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb')
+fi
 [ $bbb -eq 1 ]
 
-ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+if (grep -q "clang" comp); then
+    ccc=$(llvm-dwarfdump --debug-info 1 | grep -c 'DW_AT_name.*ccc')
+else
+    ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc')
+fi
 [ $ccc -eq 1 ]
 
-rm -f 1
+rm -f 1 comp
diff --git a/testsuite/dwz.tests/two-files-too-many-dies-2.sh b/testsuite/dwz.tests/two-files-too-many-dies-2.sh
index 91b5ccc..5b73e8a 100644
--- a/testsuite/dwz.tests/two-files-too-many-dies-2.sh
+++ b/testsuite/dwz.tests/two-files-too-many-dies-2.sh
@@ -1,9 +1,17 @@
+echo $CC > comp 2>/dev/null
+
 cp $execs/hello 1
 cp $execs/dwz-for-test 2
 
-limit=$(readelf -wi 2 \
+if (grep -q "clang" comp); then
+    limit=$(llvm-dwarfdump --debug-info 2 \
+	    | grep ':[ ]*DW_TAG' \
+	    | wc -l)
+else
+    limit=$(readelf -wi 2 \
 	    | grep '(DW_TAG' \
 	    | wc -l)
+fi
 limit=$((limit - 1))
 
 if dwz -L$limit 2 1 2>dwz.err; status=$?; then
@@ -19,4 +27,4 @@ fi
 smaller-than.sh 1 $execs/hello
 cmp 2 $execs/dwz-for-test
 
-rm -f 1 2 dwz.err
+rm -f 1 2 dwz.err comp
diff --git a/testsuite/scripts/smaller-than.sh b/testsuite/scripts/smaller-than.sh
index 3b452dc..539f5fd 100755
--- a/testsuite/scripts/smaller-than.sh
+++ b/testsuite/scripts/smaller-than.sh
@@ -3,16 +3,26 @@
 f1=$1
 f2=$2
 
+echo $CC > comp 2>/dev/null
+
 section_size ()
 {
     local f="$1"
     local section="$2"
 
     local s
-    s=$(readelf -S -W $f \
+
+    if (grep -q "clang" comp); then
+        s=$(llvm-dwarfdump --show-section-sizes $f \
+		| grep -w "\.debug_$section" \
+		| sed 's/.*\.debug_//' \
+		| awk '{print $2}')
+    else
+        s=$(readelf -S -W $f \
 	    | grep "\.debug_$section" \
 	    | sed 's/.*\.debug_//' \
-	    | awk '{print $5}')
+      	    | awk '{print $5}')
+    fi
 
     if [ "$s" = "" ]; then
        echo 0
@@ -20,7 +30,9 @@ section_size ()
     fi
 
     # Convert hex to decimal.
-    s=$(printf "%d" $((16#$s)))
+    if ( ! grep -q "clang" comp); then
+        s=$(printf "%d" $((16#$s)))
+    fi
 
     echo $s
 }
@@ -45,4 +57,6 @@ if [ $s1 -ge $s2 ]; then
     exit 1
 fi
 
+rm -f comp
+
 exit 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-25 17:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16 11:35 [PATCH 2/2] Test script modifications to use llvm-dwarfdump when compiler is clang E, Nagajyothi
2021-05-24 12:18 ` E, Nagajyothi
2021-06-03 16:56   ` E, Nagajyothi
2021-07-13  3:56     ` E, Nagajyothi
2021-07-25 17:35       ` E, Nagajyothi

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).