[Committed] objdump, readelf: Emit "CU:" format only when wide output is requested

Message ID 20220112045419.7643B2040E@pchp3.se.axis.com
State New
Headers show
  • [Committed] objdump, readelf: Emit "CU:" format only when wide output is requested
Related show

Commit Message

H.J. Lu via Binutils Jan. 12, 2022, 4:54 a.m.
As pre-approved by Alan in
and I believe people have run into getting testsuite failures for
test-environments with "long" directory names, at least once more
since that time.  Enough.  I grepped the gas, binutils and ld
testsuites for "CU:" to catch target-specific occurrences, but I
noticed none.  I chose to remove "CU:" on the objdump tests instead of
changing options to get the wide format, so as to keep the name of the
test consistent with actual options; but added it to the readelf
options for the gas test as I believe the "CU:" format is preferable.

Tested for cris-elf and native x86_64-pc-linux-gnu.

	* dwarf.c (display_debug_lines_decoded): Don't check the
	string length of the directory, instead emit the "CU: dir/name"
	format only if wide output is requested.
	* testsuite/binutils-all/dw5.W, testsuite/binutils-all/objdump.WL:
	Adjust accordingly.

	* testsuite/gas/elf/dwarf-5-loc0.d: Add -W to readelf options.
 binutils/dwarf.c                           | 2 +-
 binutils/testsuite/binutils-all/dw5.W      | 2 +-
 binutils/testsuite/binutils-all/objdump.WL | 2 +-
 gas/testsuite/gas/elf/dwarf-5-loc0.d       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)



diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 52d4dd1cad5f..bc33e9f08143 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -5137,7 +5137,7 @@  display_debug_lines_decoded (struct dwarf_section *  section,
 		directory = (char *) directory_table[ix - 1];
-	      if (do_wide || strlen (directory) < 76)
+	      if (do_wide)
 		printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
 		printf ("%s:\n", file_table[0].name);
diff --git a/binutils/testsuite/binutils-all/dw5.W b/binutils/testsuite/binutils-all/dw5.W
index 562b64fe2209..ebab8b7d3b09 100644
--- a/binutils/testsuite/binutils-all/dw5.W
+++ b/binutils/testsuite/binutils-all/dw5.W
@@ -347,7 +347,7 @@  Raw dump of debug contents of section .debug_line:
 Contents of the .debug_line section:
-CU: ./main.c:
 File name                            Line number    Starting address    View    Stmt
 main.c                                         6              0x1234               x
 main.c                                         6             0x12346               x
diff --git a/binutils/testsuite/binutils-all/objdump.WL b/binutils/testsuite/binutils-all/objdump.WL
index e16d5bad4374..f02a9e638398 100644
--- a/binutils/testsuite/binutils-all/objdump.WL
+++ b/binutils/testsuite/binutils-all/objdump.WL
@@ -3,7 +3,7 @@ 
 Contents of the \.debug_line section:
-CU: \./dw2-decodedline\.c:
 File name                            Line number    Starting address    View    Stmt
diff --git a/gas/testsuite/gas/elf/dwarf-5-loc0.d b/gas/testsuite/gas/elf/dwarf-5-loc0.d
index eb752c9caed2..7e8473a486f5 100644
--- a/gas/testsuite/gas/elf/dwarf-5-loc0.d
+++ b/gas/testsuite/gas/elf/dwarf-5-loc0.d
@@ -1,5 +1,5 @@ 
 #as: -gdwarf-5
-#readelf: -wL
+#readelf: -W -wL
 #name: DWARF5 .loc 0
 # The am33 cr16 crx ft32 mn10 msp430 nds32 and rl78 targets do not evaluate the subtraction of symbols at assembly time.
 # The riscv targets do not support the subtraction of symbols.