From patchwork Fri Aug 4 00:03:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 73589 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93AF1385770C for ; Fri, 4 Aug 2023 00:04:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93AF1385770C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691107454; bh=gu21D1AiSuB9uhGs8TWYWjUDbDvCo+2Qkl8cz8EvZQQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wRLYsp3SaFfZFdw1dpBANg3ECedkR1sSCO8cFlSStWUHqWqaatFbHuw32SMtQsZW6 CfRgrNFTvb5vFfY7JPr0j7ylW0dOVdrj1OylLPS4pA9/HJb6KINtvn24ccnF/TPNcw 2XGx7lLatlYWyc3H3mi5kzf5vBp+ZfAxGgBQsLjE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id A2F3F3858426 for ; Fri, 4 Aug 2023 00:03:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2F3F3858426 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 C9BA3218ED for ; Fri, 4 Aug 2023 00:03:45 +0000 (UTC) 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 B7E9C1339E for ; Fri, 4 Aug 2023 00:03:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MAbGK2FAzGQVLQAAMHmgww (envelope-from ) for ; Fri, 04 Aug 2023 00:03:45 +0000 To: gdb-patches@sourceware.org Subject: [PATCH v3 5/5] [gdb/testsuite] Extend gdb.base/index-cache.exp Date: Fri, 4 Aug 2023 02:03:29 +0200 Message-Id: <20230804000329.21405-6-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230804000329.21405-1-tdevries@suse.de> References: <20230804000329.21405-1-tdevries@suse.de> MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The test-case gdb.base/index-cache.exp uses only one source file, which contains main. While doing "file $exec", in set_initial_language a symbol lookup of "main" is done, causing the symtab containing main to be expanded. Handling of main is special, and a future optimization may skip the lookup and expansion. Reliably exercise: - the lookup of main, expanding the symtab containing main, by doing "ptype main", and - the lookup of another symbol, expanding a symtab not containing main, by: - adding another source file containing function foo, and - doing "ptype foo". This triggered a segfault with target board native-extended-gdbserver, filed as PR symtab/30712, but that seems to be fixed by a previous commit in this series. Tested on x86_64-linux. Approved-By: Tom Tromey Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30712 --- gdb/testsuite/gdb.base/index-cache-2.c | 24 ++++++++++++++++++++++++ gdb/testsuite/gdb.base/index-cache.c | 6 ++++-- gdb/testsuite/gdb.base/index-cache.exp | 22 ++++++++++++++++++++-- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 gdb/testsuite/gdb.base/index-cache-2.c diff --git a/gdb/testsuite/gdb.base/index-cache-2.c b/gdb/testsuite/gdb.base/index-cache-2.c new file mode 100644 index 00000000000..d0c10780499 --- /dev/null +++ b/gdb/testsuite/gdb.base/index-cache-2.c @@ -0,0 +1,24 @@ +/* This testcase is part of GDB, the GNU debugger. + + 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 . */ + +extern int foo (void); + +int +foo (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/index-cache.c b/gdb/testsuite/gdb.base/index-cache.c index 16521df96f5..fecba981b91 100644 --- a/gdb/testsuite/gdb.base/index-cache.c +++ b/gdb/testsuite/gdb.base/index-cache.c @@ -15,9 +15,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +extern int foo (void); + int -main () +main (void) { - return 0; + return foo (); } diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp index 9f2f53053cb..c26c4f94e65 100644 --- a/gdb/testsuite/gdb.base/index-cache.exp +++ b/gdb/testsuite/gdb.base/index-cache.exp @@ -16,9 +16,9 @@ # This test checks that the index-cache feature generates the expected files at # the expected location. -standard_testfile +standard_testfile .c -2.c -if { [build_executable "failed to prepare" $testfile $srcfile \ +if { [build_executable "failed to prepare" $testfile [list $srcfile $srcfile2] \ {debug ldflags=-Wl,--build-id}] } { return } @@ -147,6 +147,12 @@ proc_with_prefix test_cache_disabled { cache_dir test_prefix } { gdb_assert "$nfiles_created == 0" "no files were created" check_cache_stats 0 0 + + # Trigger expansion of symtab containing main, if not already done. + gdb_test "ptype main" "^type = int \\(void\\)" + + # Trigger expansion of symtab not containing main. + gdb_test "ptype foo" "^type = int \\(void\\)" } } } @@ -192,6 +198,12 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } { } else { check_cache_stats 0 0 } + + # Trigger expansion of symtab containing main, if not already done. + gdb_test "ptype main" "^type = int \\(void\\)" + + # Trigger expansion of symtab not containing main. + gdb_test "ptype foo" "^type = int \\(void\\)" } } @@ -221,6 +233,12 @@ proc_with_prefix test_cache_enabled_hit { cache_dir } { } else { check_cache_stats 0 0 } + + # Trigger expansion of symtab containing main, if not already done. + gdb_test "ptype main" "^type = int \\(void\\)" + + # Trigger expansion of symtab not containing main. + gdb_test "ptype foo" "^type = int \\(void\\)" } }