From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 28FAE3858D35 for ; Fri, 8 Sep 2023 14:44:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28FAE3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4134D21D08 for ; Fri, 8 Sep 2023 14:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694184243; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+muOP8GiNCwBlIQWtL3FMYQPGjSM9JT4NSp7DARui20=; b=cHyS2fThF45UMeuVSUKd6a7GPCkqkAxzjPOVflI/ZAMPblNBpDFTKHgzkxHHKSdpDAbpuj WkCxUhXFyWWfGJerE6tb/v8ZBo4fQOSzomFRUrPPXFP/4InPQbci42V7FC/g+iLOwfAqXv FjREsxwOZKNkchOgXZUHRSUom1Ia/Xo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694184243; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+muOP8GiNCwBlIQWtL3FMYQPGjSM9JT4NSp7DARui20=; b=9quEVwIpCpakc1PQ2XQq/9+H89n4Vjy5kRJPIk19QpyAe7wQwYN0u+cf5NnHW26AbOjN0j Oj50zK30t87JZ5Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2F367132F2 for ; Fri, 8 Sep 2023 14:44:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IyNiCjMz+2QsfwAAMHmgww (envelope-from ) for ; Fri, 08 Sep 2023 14:44:03 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Add boards/cc-with-index-cache.exp Date: Fri, 8 Sep 2023 16:44:02 +0200 Message-Id: <20230908144402.13924-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: We have a target board cc-with-gdb-index that uses the gdb-add-index script to add a .gdb_index index to an exec. There is however an alternative way of adding a .gdb_index: the index-cache. Add a new target board cc-with-index-cache. This is not superfluous for two reasons: - there is functionality that gdb-add-index doesn't support, but the index-cache does: the index-cache can add an index to an exec with a .gnu_debugaltlink (note that when using the cc-with-gdb-index board this case is quietly ignored), and - using the index-cache is excercised in only a few test-cases, and having this target board extends the test coverage to the entire test suite. This is for instance relevant because the index-cache is written by a worker thread in the background, so we can check more thoroughly for data races (see PR symtab/30837). Tested on x86_64-linux. Shell script changes checked with shellcheck. --- gdb/contrib/cc-with-tweaks.sh | 12 ++++++ gdb/testsuite/boards/cc-with-index-cache.exp | 40 ++++++++++++++++++++ gdb/testsuite/make-check-all.sh | 1 + 3 files changed, 53 insertions(+) create mode 100644 gdb/testsuite/boards/cc-with-index-cache.exp diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh index 62d3bcf9707..abf22ca8519 100755 --- a/gdb/contrib/cc-with-tweaks.sh +++ b/gdb/contrib/cc-with-tweaks.sh @@ -43,6 +43,7 @@ # -z compress using dwz # -m compress using dwz -m # -i make an index (.gdb_index) +# -c make an index (currently .gdb_index) in a cache dir # -n make a dwarf5 index (.debug_names) # -p create .dwp files (Fission), you need to also use gcc option -gsplit-dwarf # -l creates separate debuginfo files linked to using .gnu_debuglink @@ -85,6 +86,7 @@ output_file=a.out want_index=false index_options="" +want_index_cache=false want_dwz=false want_multi=false want_dwp=false @@ -97,6 +99,7 @@ while [ $# -gt 0 ]; do -z) want_dwz=true ;; -i) want_index=true ;; -n) want_index=true; index_options=-dwarf-5;; + -c) want_index_cache=true ;; -m) want_multi=true ;; -p) want_dwp=true ;; -l) want_gnu_debuglink=true ;; @@ -209,6 +212,15 @@ if [ "$want_index" = true ]; then [ $rc != 0 ] && exit $rc fi +if [ "$want_index_cache" = true ]; then + $GDB -q -batch \ + -ex "set index-cache directory $INDEX_CACHE_DIR" \ + -ex "set index-cache enabled on" \ + -ex "file $output_file" + rc=$? + [ $rc != 0 ] && exit $rc +fi + if [ "$want_dwz" = true ] || [ "$want_multi" = true ]; then # Require dwz version with PR dwz/24468 fixed. dwz_version_major_required=0 diff --git a/gdb/testsuite/boards/cc-with-index-cache.exp b/gdb/testsuite/boards/cc-with-index-cache.exp new file mode 100644 index 00000000000..079c0365de2 --- /dev/null +++ b/gdb/testsuite/boards/cc-with-index-cache.exp @@ -0,0 +1,40 @@ +# Copyright 2023 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 . + +# This file is a dejagnu "board file" and is used to run the testsuite +# with contrib/cc-with-tweaks.sh -c. +# +# Example usage: +# bash$ cd $objdir +# bash$ make check-gdb \ +# RUNTESTFLAGS='--target_board=cc-with-index-cache' +# + +# Choose location of index-cache directory. +setenv INDEX_CACHE_DIR [pwd]/cc-with-index-cache + +# Start with empty index-cache directory. +file delete -force $env(INDEX_CACHE_DIR) +file mkdir $env(INDEX_CACHE_DIR) + +# Make sure index-cache entries are generated for each executable. +set CC_WITH_TWEAKS_FLAGS "-c" +load_board_description "cc-with-tweaks" + +# Make sure gdb knowns how to find the index-cache. +append GDBFLAGS " -iex \"set index-cache directory $env(INDEX_CACHE_DIR)\"" + +# Make sure gdb uses the index-cache. +append GDBFLAGS " -iex \"set index-cache enabled on\"" diff --git a/gdb/testsuite/make-check-all.sh b/gdb/testsuite/make-check-all.sh index 7d8adb58e87..947e6e32eaa 100755 --- a/gdb/testsuite/make-check-all.sh +++ b/gdb/testsuite/make-check-all.sh @@ -66,6 +66,7 @@ host_target_boards=( # Boards that run everything on local target and local host. target_boards=( cc-with-gdb-index + cc-with-index-cache cc-with-debug-names cc-with-dwz cc-with-dwz-m base-commit: 9c5bc1bd1399c11427deec1f8de6c537ab249087 -- 2.35.3