[3/3] Add "-5" flag to cc-with-tweaks

Message ID 20250323-dwz-dwarf-5-v2-v1-3-3c0775ca5514@tromey.com
State New
Headers
Series Support DWARF 5 .debug_sup section |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey March 23, 2025, 7:20 p.m. UTC
  This adds a "-5" flag to cc-with-tweaks, mirroring dwz's "-5" flag,
and also adds a new cc-with-dwz-5 target board.

The "-5" flag tells dwz to use the DWARF 5 .debug_sup section in
multi-file mode.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32808
---
 gdb/contrib/cc-with-tweaks.sh          |  5 ++++-
 gdb/testsuite/boards/cc-with-dwz-5.exp | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index 4214b9292955a8b5f4602d329a93ee0ab606a70a..5677f29493828a9e9fb6041fd03cb85452e04199 100755
--- a/gdb/contrib/cc-with-tweaks.sh
+++ b/gdb/contrib/cc-with-tweaks.sh
@@ -42,6 +42,7 @@ 
 # -Z invoke objcopy --compress-debug-sections
 # -z compress using dwz
 # -m compress using dwz -m
+# -5 compress using dwz -m -5
 # -i make an index (.gdb_index)
 # -c make an index (currently .gdb_index) in a cache dir
 # -n make a dwarf5 index (.debug_names)
@@ -88,6 +89,7 @@  want_index=false
 index_options=""
 want_index_cache=false
 want_dwz=false
+dwz_5flag=
 want_multi=false
 want_dwp=false
 want_objcopy_compress=false
@@ -101,6 +103,7 @@  while [ $# -gt 0 ]; do
 	-n) want_index=true; index_options=-dwarf-5;;
 	-c) want_index_cache=true ;;
 	-m) want_multi=true ;;
+	-5) want_multi=true; dwz_5flag=-5 ;;
 	-p) want_dwp=true ;;
 	-l) want_gnu_debuglink=true ;;
 	*) break ;;
@@ -269,7 +272,7 @@  elif [ "$want_multi" = true ]; then
     rm -f "$dwz_file"
 
     cp "$output_file" "${output_file}.alt"
-    $DWZ -m "$dwz_file" "$output_file" "${output_file}.alt" > /dev/null
+    $DWZ $dwz_5flag -m "$dwz_file" "$output_file" "${output_file}.alt" > /dev/null
     rm -f "${output_file}.alt"
 
     # Validate dwz's work by checking if the expected output file exists.
diff --git a/gdb/testsuite/boards/cc-with-dwz-5.exp b/gdb/testsuite/boards/cc-with-dwz-5.exp
new file mode 100644
index 0000000000000000000000000000000000000000..b254f91e79557a5600a894f0bb0727fd2bcf02f1
--- /dev/null
+++ b/gdb/testsuite/boards/cc-with-dwz-5.exp
@@ -0,0 +1,28 @@ 
+# Copyright 2025 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, see <http://www.gnu.org/licenses/>.
+
+# This file is a dejagnu "board file" and is used to run the testsuite
+# with contrib/cc-with-tweaks.sh -5.
+#
+# NOTE: We assume dwz is in $PATH.
+#
+# Example usage:
+# bash$ cd $objdir
+# bash$ make check-gdb \
+#   RUNTESTFLAGS='--target_board=cc-with-dwz-5'
+#
+
+set CC_WITH_TWEAKS_FLAGS "-5"
+load_board_description "cc-with-tweaks"