From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /4HMM5utoGEFJwAAWB0awg (envelope-from ) for ; Fri, 26 Nov 2021 04:49:15 -0500 Received: by simark.ca (Postfix, from userid 112) id C15CA1F0CE; Fri, 26 Nov 2021 04:49:15 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E6CDA1EDF0 for ; Fri, 26 Nov 2021 04:49:13 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05CEC3858035 for ; Fri, 26 Nov 2021 09:49:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05CEC3858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637920153; bh=306oflNo1ykBGR5Yi6w6SyaD6WuuhCw8OatJlqz6PMA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=B6TQxvxdOdbTMDHYqv+7UEZEPIUwlO/Qaq5UxleN4CqrniZ9lHsyqNKV2ufo7j5qJ NPZUtBFuyV1K071jcg+BfrkwoBlc7vJ96l8Maf7lXwtHJBoOOMDiHHk1yJ+Jz0ll/L MXtu+pFyCG/n0gQfX4bRwzSqtY9Igvp1Y/ui1BXc= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A7E743858037 for ; Fri, 26 Nov 2021 09:48:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7E743858037 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-out2.suse.de (Postfix) with ESMTPS id AD16E1FD37; Fri, 26 Nov 2021 09:48:52 +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 94D3A13BAE; Fri, 26 Nov 2021 09:48:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UX1II4StoGH3SQAAMHmgww (envelope-from ); Fri, 26 Nov 2021 09:48:52 +0000 To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Add gdb.base/include-main.exp Date: Fri, 26 Nov 2021 10:48:52 +0100 Message-Id: <20211126094852.32283-1-tdevries@suse.de> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" The test-case gdb.ada/dgopt.exp uses the -gnatD switch, in combination with -gnatG. This causes the source file $src/gdb/testsuite/gdb.ada/dgopt/x.adb to be expanded into $build/gdb/testsuite/outputs/gdb.ada/dgopt/x.adb.dg, and the debug information should refer to the x.adb.dg file. That is the case for the .debug_line part: ... The Directory Table is empty. The File Name Table (offset 0x1c): Entry Dir Time Size Name 1 0 0 0 x.adb.dg ... but not for the .debug_info part: ... <11> DW_AT_name : $src/gdb/testsuite/gdb.ada/dgopt/x.adb <15> DW_AT_comp_dir : $build/gdb/testsuite/outputs/gdb.ada/dgopt ... Filed as PR gcc/103436. In C we can generate similar debug information, using a source file that does not contain any code, but includes another one that does: ... $ cat gdb/testsuite/gdb.base/include-main.c #include "main.c" ... such that in the .debug_line part we have: ... The Directory Table (offset 0x1c): 1 /home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.base The File Name Table (offset 0x57): Entry Dir Time Size Name 1 1 0 0 main.c ... and in the .debug_info part: ... <11> DW_AT_name : $src/gdb/testsuite/gdb.base/include-main.c <15> DW_AT_comp_dir : $build/gdb/testsuite ... Add a C test-case that mimics gdb.ada/dgopt.exp, that is: - generate debug info as described above, - issue a list of a line in include-main.c, while the corresponding CU is not expanded yet. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/include-main.c | 18 ++++++++++ gdb/testsuite/gdb.base/include-main.exp | 47 +++++++++++++++++++++++++ gdb/testsuite/gdb.base/main.c | 22 ++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 gdb/testsuite/gdb.base/include-main.c create mode 100644 gdb/testsuite/gdb.base/include-main.exp create mode 100644 gdb/testsuite/gdb.base/main.c diff --git a/gdb/testsuite/gdb.base/include-main.c b/gdb/testsuite/gdb.base/include-main.c new file mode 100644 index 00000000000..ef5ac0a9f3e --- /dev/null +++ b/gdb/testsuite/gdb.base/include-main.c @@ -0,0 +1,18 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2021 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 . */ + +#include "main.c" diff --git a/gdb/testsuite/gdb.base/include-main.exp b/gdb/testsuite/gdb.base/include-main.exp new file mode 100644 index 00000000000..5e5e9495198 --- /dev/null +++ b/gdb/testsuite/gdb.base/include-main.exp @@ -0,0 +1,47 @@ +# Copyright 2021 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 . + +# C test-case that mimics gdb.ada/dgopt.exp. + +standard_testfile .c main.c + +if { [build_executable "failed to prepare" $testfile $srcfile {debug}] } { + return -1 +} + +clean_restart + +# Set language explicitly, to avoid expanding the include-main.c CU for the +# language lookup (this is currently not required, but may be after +# integration of the no-more-psym branch). +# This to make sure that the source file lookup we do later triggers the +# symtab expansion. +gdb_test_no_output "set language c" + +gdb_load $binfile + +# Verify that no CU was expanded. +gdb_test_no_output "maint info symtab" + +# List a line in include-main.c. The tricky bit is that there's no code in +# include-main.c, so the file should not occur in the .debug_line info. +# GDB needs to find the file based on the CU's DW_AT_name/DW_AT_comp_dir. +set line [gdb_get_line_number "include" $srcfile] +gdb_test "list $srcfile:$line" "$line\[ \t\]*#include \"main.c\"" + +# For completeness, also try to list a line in the file that does contain +# code. +set line [gdb_get_line_number "main" $srcfile2] +gdb_test "list $srcfile2:$line" "$line\[ \t\]*main \\(void\\)\r\n.*" diff --git a/gdb/testsuite/gdb.base/main.c b/gdb/testsuite/gdb.base/main.c new file mode 100644 index 00000000000..bfe52c018d4 --- /dev/null +++ b/gdb/testsuite/gdb.base/main.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2021 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 . */ + +int +main (void) +{ + return 0; +} base-commit: 4780e5e4933a2497a5aecc4ceabbbb8e82aaf822 -- 2.31.1